PDA

Click to See Complete Forum and Search --> : A simple SQL question


tzachari
Mar 9th, 2000, 11:44 PM
Hi All,
I have 3 text boxes in my VB app and I want to insert the values in this text box into a access 97 table using ADO code. I am getting an SQL syntax error. I am really not familiar using SQL within VB.

I have already established the connection to by db. Here is a part of the code

Public objCmd As New ADODB.Command

objCmd.CommandType = adCmdText

objCmd.CommandText = "INSERT INTO Table(FName,LName,City)Values(Text1.text,text2.text,text3.text)

objCmd.Execute

I am getting a "Insert into" SQL syntax error. Please help

Zack

JHausmann
Mar 10th, 2000, 12:17 AM
try replacing:

objCmd.CommandText = "INSERT INTO Table(FName,LName,City)Values(Text1.text,text2.text,text3.text)



with

objCmd.CommandText = "INSERT INTO Table(FName,LName,City)Values('"Text1.text" & "','" & text2.text & "','" & text3.text & "')"