How do you insert a decimal number in a SQL Database. In my code I've set
Cost_DC and Liter_Kilo_DC to data type decimal in SQL Enterprise manager.
When I run it I get the error message:
Error converting data type varchar to numeric.
/indkøbsregnskab/index.asp, line 475
Here's my code:
Line 475 is the last line.
If Request.Form("WhatWasChosenX") = "InsertProduct" Then
Dim strSupermarket, lngPrice, lngKgL, bitLiquid
Dim objCmd
strSupermarket = Request.Form("Supermarket")
strProduct = Request.Form("Product")
strProductType = Request.Form("ProductType")
lngPrice = Request.Form("Price")
lngKgL = Request.Form("KgL")
If Request.Form("Liquid") = "on" Then
bitLiquid = 1
Else
bitLiquid = 0
End If
Set objConn = Server.Createobject("ADODB.Connection")
strConnString = "Provider=SQLOLEDB;" & _
"Persist Security Info=FALSE;" & _
"User ID=sa;" & _
"Password=pb16950;" & _
"Initial Catalog=Indkøbsregnskab;" & _
"Initial File Name = C:\Programmer\Microsoft SQL
Server\" & _
"MSSQL\DATA\Indkøbsregnskab_Data.mdf;"
objConn.Open strConnString
strSQL = "INSERT INTO Product_T (Product_VC, Product_Type_VC,
Cost_DC, " & _
"Liquid_BT, Liter_Kilo_DC, Supermarket_VC) VALUES ('" &
_
strProduct & "', '" & strProductType & "', '" & lngPrice
& _
"', '" & bitLiquid & "', '" & lngKgL & "', '" & _
strSupermarket & "')"
Set objCmd = Server.Createobject("ADODB.Command")
Set objCmd.ActiveConnection = objConn
objCmd.CommandText = strSQL
objCmd.CommandType = adCmdText
objCmd.Execute
What's the problem?
Best regards
Christian Dygaard