Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
robert_645
Starting Member
4 Posts |
Posted - 2015-01-09 : 05:06:04
|
Hello all,I insert data from excel to sql using vba.In this case I try to insert numbers in a sql column with data type decimal (18, 6)In excel the format of the cells are 'number'Below a part of the code[CODE]Dim as3000 As DoubleDim rec As Double'...'...as3000 = CDec(Cells(mytel2, soort).Value)rec = CDec(Range("U" & mytel2).Value)rc.Open "INSERT INTO dbo.QHSE_2ndline_history (AS3000, Rec) VALUES ('" & as3000 & "', '" & rec & "')", con'...[/CODE]But when starting the code, it results in an error converting data type varchar to numeric.What have I done wrong, please helpThanks in advance |
|
robert_645
Starting Member
4 Posts |
Posted - 2015-01-09 : 08:09:04
|
I have found the problem(s). First there were to many quotes. ...VALUES ('" & as3000 --> ...VALUES ( " & as3000after that the next problem was the decimal separationMy decimal separator was set to a comma. Which gave the problem that it seems there were more results than columns.Conclusion, use a point as decimal sep. This item can be closed. |
|
|
Blackcap145
Starting Member
1 Post |
Posted - 2015-02-17 : 01:28:55
|
when starting the code, it results in an error converting data type varchar to numeric...???watson |
|
|
|
|
|