Decimal tal i SQL Database
Hvordan indsætter man decimal tal ind i en SQL database?Jeg har sat data typen for cost_DC og Liter_Kilo_DC til decimal i SQL Server Enterprise Manager.
I min kode får jeg følgende fejlmeddelelse:
Error converting data type varchar to numeric.
/indkøbsregnskab/index.asp, line 475
Her er min kode:
Linje 475 er sidte linje.
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
Hvad er der galt?
