Insert SQL syntax (data from form's post)

Results 1 to 2 of 2

Thread: Insert SQL syntax (data from form's post)

  1. #1
    Join Date
    Dec 1969

    Default Insert SQL syntax (data from form's post)

    If you dont mind, please take a look at my code. I&#039;ve been building little test pages as I learn different ASP topics. I have a page called InsertTestPage1.asp. It just has 2 fields called SubmitFirstName and SubmitLastName and for posts to a second page called InsertTestPage2.asp. The second page should Request the posted data from the 1st page and insert it into a table. <BR><BR>The code below shows the ASP from InsertTestPage2.asp. It shoud just update the table but it seems to have a problem with my SQL string. How can I write it so that the inserted values are the variables defined as the Requested data?<BR><BR>Hope this makes sense. Thanks!<BR><BR><BR><BR>&#060;%<BR>Option Explicit<BR>Dim OBJdbConnection, SQLInsertQuery, RecordSet, SQLQuery, strFirstName, strLastName<BR><BR>strFirstname = Request.Form("SubmitFirstName")<BR>strLastname = Request.Form("SubmitLastName")<BR><BR>Response.Exp ires=0<BR><BR>Set OBJdbConnection = Server.CreateObject("ADODB.Connection") <BR>OBJdbConnection.Open "test" <BR>SQLInsertQuery = "INSERT INTO Names (FirstName, LastName) VALUES (strFirstName,strLastName)" <BR>OBJdbConnection.Execute(SQLInsertQuery)<BR>SQL Query = "SELECT * FROM Names" <BR>Set RecordSet = OBJdbConnection.Execute(SQLQuery)<BR>%&#062;<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Insert SQL syntax (data from form's post)

    SQLInsertQuery = "INSERT INTO Names (FirstName, LastName) VALUES (&#039;" & strFirstName & "&#039;,&#039;" & strLastName & "&#039;)" <BR><BR>Check out the post below this on tips for debuggin problems with SQL strings...

Posting Permissions

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