Asp sql error

Results 1 to 3 of 3

Thread: Asp sql error

  1. #1
    Join Date
    Dec 1969

    Default Asp sql error

    Hi I&#039;m trying to add an entry into a database using the values from a form using asp. The code I&#039;m using is<BR><BR>conn.Execute ("Insert into users (firstname,surname,email,dateofbirth,username,pass word) values &#039;" & Request.form("firstname") & "&#039;,&#039;" & request.form("surname") &"&#039;,&#039;" & request.form("email") &"&#039;,&#039;" & request.form("dateofbirth") &"&#039;,&#039;" & request.form("username") &"&#039;,&#039;" & request.form("password") &"&#039;")<BR>Response.Write("Your record has been added")<BR><BR>I keep getting the following error<BR><BR>Microsoft OLE DB Provider for ODBC Drivers error &#039;80040e14&#039; <BR><BR>[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near &#039;&#039;. <BR><BR>Can anyone help<BR><BR>Also if i&#039;m trying to split a query/code into a number of lines do i need to use _& at the end of the line<BR><BR>cheers<BR>Mal<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Asp sql error

    A better way to write this so you can debug it, is to set a variable to contain the SQL line, say call it strSQL, and then do:<BR>conn.execute strSQL<BR><BR>First do that, but before this line, put:<BR>Response.Write strSQL<BR>Response.End<BR><BR>This will show you on the screen what your SQL line is, without crashing the page. By seeing the SQL code your page generates, you should be able to spot an error in it.<BR><BR>Personally, I would write your code like this to make it more readable:<BR><BR>strSQL= "Insert into users (" & _ <BR> "firstname," & _ <BR> "surname," & _<BR> "email," & _<BR> "dateofbirth," & _<BR> "username," & _<BR> "password" & _<BR> ") values &#039;" & _<BR> Request.form("firstname") & "&#039;,&#039;" & _<BR> request.form("surname") & "&#039;,&#039;"<BR> ...etc<BR><BR>Conn.Execute strSQL

  3. #3
    Join Date
    Dec 1969

    Default Input syntax

    The correct syntax for an Input statemant is:<BR>INPUT INTO Table (column1, column2, ...) VALUES (value1, value2, ...)<BR>You will get errors if you don&#039;t have ( ) around your VALUES. You will need to use the _ & if your statemant needs to be more than one line.

Posting Permissions

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