what's wrong in this code?
-
I am trying to use an insert into command, but getting error in insert statement. Can anybody please tell me whats wrong with following code:
Dim cmd As OleDbCommand = New OleDbCommand("INSERT INTO [Joint Coordinates](Joint, CoordSys, CoordType, XorR, Y, Z, SpecialJt, GlobalX, GlobalY, GlobalZ, GUID) Values('" & dgr1.Cells(0).Value & "','" & dgr1.Cells(1).Value & "', '" & dgr1.Cells(2).Value & "', '" & dgr1.Cells(3).Value & "', '" & dgr1.Cells(4).Value & "', '" & dgr1.Cells(5).Value & "', '" & dgr1.Cells(6).Value & "', '" & dgr1.Cells(7).Value & "', '" & dgr1.Cells(8).Value & "', '" & dgr1.Cells(9).Value & "', '" & dgr1.Cells(10).Value & "')", con)
-
I am trying to use an insert into command, but getting error in insert statement. Can anybody please tell me whats wrong with following code:
Dim cmd As OleDbCommand = New OleDbCommand("INSERT INTO [Joint Coordinates](Joint, CoordSys, CoordType, XorR, Y, Z, SpecialJt, GlobalX, GlobalY, GlobalZ, GUID) Values('" & dgr1.Cells(0).Value & "','" & dgr1.Cells(1).Value & "', '" & dgr1.Cells(2).Value & "', '" & dgr1.Cells(3).Value & "', '" & dgr1.Cells(4).Value & "', '" & dgr1.Cells(5).Value & "', '" & dgr1.Cells(6).Value & "', '" & dgr1.Cells(7).Value & "', '" & dgr1.Cells(8).Value & "', '" & dgr1.Cells(9).Value & "', '" & dgr1.Cells(10).Value & "')", con)
Maybe it's because the last parameter is expecting a GUID and you're supplying a string? Obviously I could be wrong but worth looking at :)
-
I am trying to use an insert into command, but getting error in insert statement. Can anybody please tell me whats wrong with following code:
Dim cmd As OleDbCommand = New OleDbCommand("INSERT INTO [Joint Coordinates](Joint, CoordSys, CoordType, XorR, Y, Z, SpecialJt, GlobalX, GlobalY, GlobalZ, GUID) Values('" & dgr1.Cells(0).Value & "','" & dgr1.Cells(1).Value & "', '" & dgr1.Cells(2).Value & "', '" & dgr1.Cells(3).Value & "', '" & dgr1.Cells(4).Value & "', '" & dgr1.Cells(5).Value & "', '" & dgr1.Cells(6).Value & "', '" & dgr1.Cells(7).Value & "', '" & dgr1.Cells(8).Value & "', '" & dgr1.Cells(9).Value & "', '" & dgr1.Cells(10).Value & "')", con)
Rewrite this to use a parameterized query instead of the unsupportable monstrosity this is and it would be easier to fix. Google results for "parameterized query[^]".
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Rewrite this to use a parameterized query instead of the unsupportable monstrosity this is and it would be easier to fix. Google results for "parameterized query[^]".
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008definitely
Take a look at my corner of the net at Code Research Center