I can find the following possiblities:
1. Your FORM from the previous page is not sending any values for one of
your decimal variables. Thus causing the INSERT command for those values
to look like the following where field2DC is your SQL Decimal Field.
"INSERT INTO (field1, field2DC) VALUES('Hello', '')"
Therefor causing a T-SQL error stating that it could not convert the
VarChar data to numeric becuase it does not see any numeric data it simply
sees a varchar string which is blank.
2. You do not have any data validation one this handler page. First
verify that the information coming to the page is not blank, and that it
is numeric. SEE EXAMPLE CODE BELOW.
I would rewrite your code to the following: (EXAMPLE CODE)
_______________________________________________________________
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
'**** VERIFY DATA INFORMATION *****
If (isNumeric(lngPrice) AND isNumeric(lngKgl)) AND _
(lngPrice <> "" AND lngKgl <> "") Then
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
Else
'Redirect user to the page that was submitting
'the invalid data with an error message.
'You can easilly add on what type of handling you want
'But do something
Response.Redirect Request.ServerVariables("HTTP_REFERER")
End If
' CONTINUE ONTO THE REST OF YOUR CODE HERE
________________________________________________________________
Brent Allen VanderMeide
Senior Web/Application Engineer
brent@s...