I have created a table...
"CREATE TABLE ImportantProcessParameters ([id] int PRIMARY KEY IDENTITY(1,1) NOT NULL,"& _
"[lot] varchar(19) NOT NULL UNIQUE,"& _
"[product] varchar(19) NOT NULL,"& _
"[assay] decimal(10,5),"& _
"[fpy] decimal(10,5),"& _
"[na] int,"& _
"[molar_ratio] decimal(10,5));"
and I insert data from an excel table using vba code.
The problem is in molar ratio
column, in the excel table I have 8.40 but in SQL this number is 8.00 or if I have 3.42 in SQL it is 3.00. Code that sends data to SQL is bellow
"IF EXISTS (SELECT lot FROM ImportantProcessParameters WHERE lot = "& exLot & ") "& _
"UPDATE ImportantProcessParameters SET product = '"& Empty2Null(exProduct) & "', assay = "& Empty2Null(exAssay) & ", fpy = "& Empty2Null(exFpy) & ", na = "& Empty2Null(exNa) & ", molar_ratio = "& Empty2Null(exMR) & " WHERE lot = "& exLot & " ELSE "& _
"INSERT INTO ImportantProcessParameters (lot, product, assay, fpy, na, molar_ratio) "& _
"VALUES("& Empty2Null(exLot) & ", '"& Empty2Null(exProduct) & "', "& Empty2Null(exAssay) & ", "& Empty2Null(exFpy) & ", "& Empty2Null(exNa) & ", "& Empty2Null(exMR) & ");"
also i have function to sent null if excel cell is empty
Function Empty2Null(oValue As Variant) As String
If oValue = Empty Then
Empty2Null = "null"
Else
Empty2Null = oValue
End If
End Function