I am new at asp so go slow. I have 2 different forms writing to 2 different access databases (Thanks to Web Wiz!). The one works fine - the other is giving me the following error code:
-------------------------------------------------------------------------------
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.
/Bridal/add_to_registry.asp, line 30
--------------------------------------------------------------------------------
I have been over the code - comparing the 2 asp pages - and the only changes I made are the names of the fields, db, table, etc. The one which works is being used for a guestbook app and this one is for a registration app. The db and asp files are in the same directory. Names are: db - main
table - bgreg
form - form
Any help would be appreciated!!
Here's the code (with comments):
---------------------------------------------------------------------------------
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsAddReg 'Holds the recordset for the new record to be added to the database
Dim strSQL 'Holds the SQL query for the database
'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("main.mdb")
'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=main"
'Create an ADO recordset object
Set rsAddReg = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblbgreg.bride_first, tblbgreg.bride_last, tblbgreg.bride_add, tblbgreg.bride_city, tblbgreg.bride_state, tblbgreg.bride_zip, tblbgreg.groom_first, tblbgreg.groom_last, tblbgreg.groom_add, tblbgreg.groom_city, tblbgreg.groom_state, tblbgreg.groom_zip, tblbgreg.b_parentsname, tblbgreg.b_parentscity, tblbgreg.b_parentsstate, tblbgreg.b_parentszip, tblbgreg.g_parentsname, tblbgreg.g_parentscity, tblbgreg.g_parentsstate, tblbgreg.g_parentszip, tblbgreg.engagement, tblbgreg.wedding, tblbgreg.location, tblbgreg.comments, tblbgreg.email, tblbgreg.password, tblbgreg.timestamp, FROM tblbgreg;"
'Set the cursor type we are using so we can navigate through the recordset
rsAddReg.CursorType = 2
'Set the lock type so that the record is locked by ADO when it is updated
rsAddReg.LockType = 3
'Open the tblbgreg table using the SQL query held in the strSQL varaiable
rsAddReg.Open strSQL, adoCon
'Tell the recordset we are adding a new record to it
rsAddReg.AddNew
'Add a new record to the recordset
rsAddReg.Fields("bride_first") = Request.Form("bride_first")
rsAddReg.Fields("bride_last") = Request.Form("bride_last")
rsAddReg.Fields("bride_add") = Request.Form("bride_add")
rsAddReg.Fields("bride_city") = Request.Form("bride_city")
rsAddReg.Fields("bride_state") = Request.Form("bride_state")
rsAddReg.Fields("bride_zip") = Request.Form("bride_zip")
rsAddReg.Fields("groom_first") = Request.Form("groom_first")
rsAddReg.Fields("groom_last") = Request.Form("groom_last")
rsAddReg.Fields("groom_add") = Request.Form("groom_add")
rsAddReg.Fields("groom_city") = Request.Form("groom_city")
rsAddReg.Fields("groom_state") = Request.Form("groom_state")
rsAddReg.Fields("groom_zip") = Request.Form("groom_zip")
rsAddReg.Fields("b_parentsname") = Request.Form("b_parentsname")
rsAddReg.Fields("b_parentscity") = Request.Form("b_parentscity")
rsAddReg.Fields("b_parentsstate") = Request.Form("b_parentsstate")
rsAddReg.Fields("b_parentszip") = Request.Form("b_parentszip")
rsAddReg.Fields("g_parentsname") = Request.Form("g_parentsname")
rsAddReg.Fields("g_parentscity") = Request.Form("g_parentscity")
rsAddReg.Fields("g_parentsstate") = Request.Form("g_parentsstate")
rsAddReg.Fields("g_parentszip") = Request.Form("g_parentszip")
rsAddReg.Fields("engagement") = Request.Form("engagement")
rsAddReg.Fields("wedding") = Request.Form("wedding")
rsAddReg.Fields("location") = Request.Form("location")
rsAddReg.Fields("comments") = Request.Form("comments")
rsAddReg.Fields("email") = Request.Form("email")
rsAddReg.Fields("password") = Request.Form("password")
rsAddReg.Fields("timestamp") = Request.Form("timestamp")
'Write the updated recordset to the database
rsAddReg.Update
'Reset server objects
rsAddReg.Close
Set rsAddReg = Nothing
Set adoCon = Nothing
'Redirect to the index.htm page
Response.Redirect "index.htm"
%>