Newsgroups: microsoft.public.vi.general
From: "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
Date: Thu, 10 Mar 2005 11:52:00 -0500
Subject: Re: Syntax error on insert from ASP to Access. Help please !
Lee Holsenbeck wrote: Do NOT use an expensive recordset object to run a query that will not return > hi, > i am trying to write records from an ASP page to a access database, > strFirstName = Request.Form("FirstName") > curDir = Server.MapPath("\registrationdb.mdb") > set oConn = Server.CreateObject("ADODB.Connection") records! Use the Connection's Execute method, and use the Execute options argument to let ADO know that you are not expecting any records back. See below > Set oRs.ActiveConnection = oConn If you wish to keep using dynamic sql, then you are going to need to learn > oRs.Source = "INSERT INTO tblCustomerInfo (FirstName, LastName, > CompanyName, Telephone, FAX, StreetAddress, City, StateProvince, > ZipPostalCode, Username, Password) VALUES ('" & strFirstName & "', '" > & strLastName & "', '" & strCompanyName & "', '" & strTelephone & "', > '" & strFAX & "', '" & strStreetAddress & "', '" & strCity & "', '" & > strStateProvince & "', '" & strZipPostalCode & "', '" & strUsername & > "', '" & strPassword & "')" > oRs.Open to debug it. You need to use Response.Write to see the result of your concatenation. It is always best to assign the concat result to a variable to make it easier to handle. Like this: sSQL = "INSERT ... "', '" & strPassword & "')" oConn.Execute sSQL..129 The 129 is a combination of two constants: 1 (adCmdText - it tells ADO you However, you should make it easy on yourself and learn to use parameters. dim cmd,sSQL, arParms(10), oConn arParms(0) = Request.Form("FirstName") 'open connection as above, then: sSQL = "INSERT INTO tblCustomerInfo (FirstName, LastName," & _ set cmd=createobject("adodb.command") See? No delimiters to worry about ... simple HTH, -- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||