Saturday, May 22, 2010

I am having a problem with an insert statement in Visual Basic 8 connecting to an Access Database.?

Getting syntax error in INSERT TO statement. That is all the information I get. Here is my code. Parameters are set after last statement








Dim Cmd As OleDb.OleDbCommand


Dim Con As OleDb.OleDbConnection


Dim Sql As String = Nothing


Con = New OleDb.OleDbConnection("Provider=Microsof... source=" %26amp; "C:\Documents and Settings\MPAXTON1\My Documents\Visual Studio 2008\Projects\GunLog\GunLog\TeklogixRetu... %26amp; "")


Sql = "INSERT INTO GunLog(date, sc_num, wh_id, gun, model, send_tek, sendRMA, return_tek, returnRMA, problem, employee, call_tek, tek_assoc, tek_sc) VALUES (@date, @sc_num, @wh_id, @gun, @model, @send_tek, @sendRMA, @return_tek, @returnRMA, @problem, @employee, @call_tek, @tek_assoc, @tek_sc)"


Cmd = New OleDb.OleDbCommand(Sql, Con)

I am having a problem with an insert statement in Visual Basic 8 connecting to an Access Database.?
I think your problem is that you are not concidering the diference between numeric and string


try this


if the column is string have single qutes aroud the item for example


'{0}'


Sql = String.Format("INSERT INTO GunLog(date, sc_num, wh_id, gun, model, send_tek, sendRMA, return_tek, returnRMA, problem, employee, call_tek, tek_assoc, tek_sc)


VALUES ({0} , {1} , {2} , {3} , {4} , {5} , {6} , {7} , {8} , {9} , {10} , {11}, {12} , {13} ) ",


date, sc_num, wh_id, gun, model, send_tek, sendRMA, return_tek, returnRMA, problem, employee, call_tek, tek_assoc, tek_sc )

flower beds

No comments:

Post a Comment