(Solved) – SQL round on whole numbers during inserting | VBA

  • by
(solved)-–-sql-round-on-whole-numbers-during-inserting-|-vba

I have create 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 excel table using vba code.
The problem is in molar ratio column, in 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 send 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) & ");"

Leave a Reply

Your email address will not be published. Required fields are marked *