Insert string problem

Results 1 to 3 of 3

Thread: Insert string problem

  1. #1
    Mike Mazanec Guest

    Default Insert string problem

    I keep getting the error "[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement." for the following code. I think it has to have some delimiters for the variables, but I&#039m not exactly sure how to do it. Can anyone help me out? Thanks in advance<BR><BR>&#060;% Dim conn, exe, rs<BR> Set conn = server.createobject("adodb.connection")<BR><BR>&#0 39Server Side form validation to keep our database clean<BR><BR> dim emailaddr,ip,day,firstname,lastname, name<BR> name= Request.Form("fname")<BR> &#039lastname = Request.Form("lname")<BR> emailaddr = Request.Form("EmailAddr")<BR> ip = Request.Form("IpAddr")<BR> day = Request.Form("Day")<BR><BR> if emailaddr = "" then<BR> error = "You have not entered an email address."<BR> Response.Redirect "email_error.asp"<BR> Response.End<BR> end if<BR><BR>&#039If we pass through validation then store the information in the db<BR><BR> conn.Open "DSN=emaildb"<BR> exe = "INSERT INTO Addresses (Name, EmailAddr, IpAddr, Date) VALUES (" & name & "," & emailaddr & ","& ip & ","& day &")"<BR> &#039set rs =<BR> conn.execute exe<BR><BR> conn.Close<BR> set conn = Nothing

  2. #2
    Join Date
    Dec 1969

    Default here ya go!!

    your problem is quite simply solved my friend:<BR><BR>exe = "INSERT INTO Addresses (Name, EmailAddr, IpAddr, Date) VALUES (&#039" & name & "&#039,&#039" & emailaddr & "&#039,&#039"& ip & "&#039,&#039"& day &"&#039)"<BR><BR>there, just replace that!!<BR><BR>

  3. #3
    Mike Mazanec Guest

    Default RE: here ya go!!

    I tried replacing the insert code with your fixes, and I still get the same error. Does it matter that I&#039m using an Access db?

Posting Permissions

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