Results 1 to 3 of 3

Thread: This is really dumb

  1. #1
    Join Date
    Jan 2003
    Posts
    2

    Question This is really dumb

    What's the syntax error in this insert statement?

    String sql = "INSERT INTO Feedback ( Name, Email, Extn, Date, Description, Alternate, Type) VALUES(" +rname+ ", " +email+ ", " +extn+ ", #" +date+ "#, " +description+ ", " +alternate+ ", " +type+ ")" ;


    rname, email etc are all variables I've defined already.

    date is a Date
    extn is a Number
    the rest are all text

    the DB I'm using is MS Access.

    I'm really rusty on this right now.

    Thanks

  2. #2
    Join Date
    Dec 2002
    Posts
    5
    If you're doing this in Access, try replacing the + signs with &, and insert a space between it and your variables. Also, you shouldn't need the semi colon at the end.

    If I was doing it in ms-access vba I would think the line(s) would look similar to the following

    Dim sSql As String
    sSQL = "INSERT INTO Feedback (Name, Email, Extn, Date, Description, Alternate, Type) VALUES(" & rname & ", " & email & ", " & extn & ", #" & date & "#, " & description & ", " & alternate & ", " & type & ")"

  3. #3
    Join Date
    Feb 2003
    Posts
    1,048
    In addition to what bannor said, I am assuming that fields like name, email, description, etc., are text fields. Your text needs to be delimited. Also, if you are using the semi-colon because it is Access, put the semi-colon inside the double quotes, not out.

    Like this:

    sSQL = "INSERT INTO Feedback (Name, Email, Extn, Date, Description, Alternate, Type) VALUES ('" & rname & "', '" & email & "', " & extn & ", #" & date & "#, '" & description & "', '" & alternate & "', '" & type & "');"

Posting Permissions

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