Results 1 to 2 of 2

Thread: A simple SQL question

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Location
    Medford,MA,USA
    Posts
    23

    Post

    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

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    You have to get the values of the text boxes, like this:

    Code:
    objCmd.CommandText = "INSERT INTO Table(FName,LName,City)Values('" & Text1.text & "','" & text2.text & "','" & Text3.text & "'")
    That should work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width