| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have this basic INSERT INTO code
there is a Syntax error in INSERT INTO statement. at line 32 been al over the net tryed everything looked at the database and the code can anyone help are my eyes missing something!!!! Thanks (i have marked line 32) <% Dim Connection Dim RS Dim SQLStmt Dim FilePath strlastname = Request.Form("lastname") strfirstname = Request.Form("firstname") straddressline1 = Request.Form("addressline1") straddressline2 = Request.Form("addressline2") strpostcode = Request.Form("postcode") strdob = Request.Form("dob") strusername = Request.Form("username") strpassword = Request.Form("password") stremail = Request.Form("email") Set Connection = Server.CreateObject("ADODB.Connection") FilePath = "D:\Inetpub\wwwroot\Rhondda Life\database1.mdb" Connection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source =" & FilePath & ";" SQLStmt = "INSERT INTO Login (Lastname,Firstname,AddressLine,AddressLine2,Postc ode,dob,Username,Password,Email)" SQLStmt = SQLStmt & "VALUES ('"& strlastname &"','"& strfirstname &"','"& straddressline1 &"','"& straddressline2 &"','"& strdob &"','"& strpostcode &"','"& strusername &"','"& strpassword &"','"& stremail &"')" Line 32 --------> Connection.Execute(SQLStmt) %> Thanks ed |
|
#2
|
||||
|
||||
|
Bit hard to read - spaces between the statement elements help. However, try adding a space in front of "VALUES" and change Username to [Username] and Password to [Password]
__________________
selwonk If I've posted some code above, you might think it looks a bit simplistic. It might be. I'd rather people tried the next step themselves rather than getting a full solution on a plate. That way they learn more!
|
|
#3
|
|||
|
|||
|
I kept at it and here is my solution (Still not perfect a lot of work to do but it works),
<%@Language=VBScript %> <%Option Explicit %> <! - - # include virtual="/adovbs.inc" - -> <% Dim Connection Dim RS Dim FilePath Const adLockOptimistic = 3 Const adCmdTable = &H0002 Set Connection = Server.CreateObject("ADODB.Connection") FilePath = "D:\Inetpub\wwwroot\Rhondda Life\database1.mdb" Connection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source =" & FilePath & ";" Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "Login", Connection, , adLockOptimistic, adCmdTable RS.AddNew RS("Lastname") = Request.Form("lastname") RS("Firstname") = Request.Form("firstname") RS("dob") = Request.Form("dob") RS("AddressLine1") = Request.Form("addressline1") RS("AddressLine2") = Request.Form("addressline2") RS("Postcode") = Request.Form("postcode") RS("Username") = Request.Form("username") RS("Password") = Request.Form("password") RS("Email") = Request.Form("email") RS.Update Set RS = Nothing Connection.Close Set Connection = Nothing Response.Write ("<meta http-equiv=refresh content=4;URL=main.htm>") %> Hope this can be of help to someone else now thanks for your help Ed |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Basic INSERT INTO problem! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|