Syntax error in INSERT INTO statement

Dreniaceard

New Member
i have this code thats trying to insert data in to Access but i get a ASP.NET error: <BR>---------------------------------------------------------------- <BR>Syntax error in INSERT INTO statement. <BR>---------------------------------------------------------------- <BR>If i debug and print out strSQl and pass it it in to the database i have to delete " for it to run at the end and at the begining ot the string. <BR><BR>Public Sub NewRecord() <BR> Dim strConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:inetpubwwwrootGlenviewSysDatabaseGlenSys. mdb" <BR> Dim objConn As New System.Data.OleDb.OleDbConnection(strConnection) <BR> Dim strSQL As String = "INSERT INTO CustomerService (Name, Position, Company, Address, City, State, Zip, Country, Phone, Fax, Email, Information)" & _ <BR> "VALUES('" & _Name & "', '" & _Position & "', '" & _Company & "', '" & _Address & "', '" & _City & "', '" & _State & "', '" & _Zip & "', '" & _Country & "', '" & _Phone & "', '" & _Fax & "', '" & _Email & "', '" & _Info & "')" <BR> objConn.Open() <BR> Dim objCommand As New System.Data.OleDb.OleDbCommand(strSQL, objConn) <BR> objCommand.ExecuteNonQuery() <BR> objConn.Close() <BR><BR> End Sub <BR>Maybe problems with quotes, I'm not using sql, but my last string in the into statement is:<BR><BR>....<BR><BR>VALUES (" & "'" & value1 & "'," & "'" & value2 & "'," & "'" & value3 & "')"<BR><BR>Try it...<BR><BR>Salvador Gallego.
 
Back
Top