DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   VB.NET (http://www.daniweb.com/forums/forum58.html)
-   -   syntax error in INSERT INTO statement (http://www.daniweb.com/forums/thread201751.html)

babbu Jul 5th, 2009 6:36 am
syntax error in INSERT INTO statement
 
here is my code

Dim oledbcom As New OleDb.OleDbCommand
oledbcom.CommandText = ("INSERT INTO Customer Company, Address, Telephone values ?,?,?")
oledbcom.Connection = oledbcon

Dim oledbparam As OleDb.OleDbParameter = _
oledbcom.Parameters.Add("@Company", OleDb.OleDbType.VarChar, 30)
oledbparam.Value = txtCompName.Text.Trim()

oledbparam = oledbcom.Parameters.Add("@Address", OleDb.OleDbType.VarChar, 80)
oledbparam.Value = txtAddress.Text.Trim

oledbparam = oledbcom.Parameters.Add("@Telephone", OleDb.OleDbType.VarChar, 15)
oledbparam.Value = txtContact.Text.Trim

oledbcom.ExecuteNonQuery()

Teme64 Jul 5th, 2009 6:51 am
Re: syntax error in INSERT INTO statement
 
Didn't test it but if I remember right
oledbcom.CommandText = ("INSERT INTO Customer Company, Address, Telephone values ?,?,?")
should be
oledbcom.CommandText = ("INSERT INTO Customer (Company, Address, Telephone) values (?,?,?)")

HTH

babbu Jul 5th, 2009 6:59 am
Re: syntax error in INSERT INTO statement
 
thnx a ton.
tht worked grt.

Teme64 Jul 5th, 2009 7:05 am
Re: syntax error in INSERT INTO statement
 
Hi! Nice to hear that you got answer to your problem. Could you please mark the thread as solved. Thank you!


All times are GMT -4. The time now is 9:09 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC