PDA

View Full Version : Microsoft JET Database Engine error '80040e14'


BCRandCo
10-16-2008, 06:22 PM
Microsoft JET Database Engine error '80040e14'

Invalid use of '.', '!', or '()'. in query expression 'maillist."Last name"'.

/rsfsurv/rsf.asp, line 191

I'm new to this part of asp. Unfortunately the database is too complex to get rid of the spaces in the names - it seems to me that is where the problem lies, and I assume I'm using the wrong method to overcome them. Any insights greatly appreciated. Below is the part of the code I assume is relevant.
line 191 refers to :rsAddComments.Open strSQL, adoCon
Thanks
Michael
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsAddComments 'Holds the recordset for the new record to be added
Dim strSQL 'Holds the SQL query to query the database
'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("rosem2008rsf.mdb")
'Create an ADO recordset object
Set rsAddComments = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT maillist.FirstName, maillist.""Last name"", maillist.""Maiden name"", maillist.""New submission or update"", maillist.e-mail, maillist.AddressLine1, maillist.AddressLine2, maillist.City, maillist.""Province/State"", maillist.""Postal Code"", maillist.Country, maillist.""phone number:"", maillist.""International phone:"", maillist.""Present Relationship to Roslyn"", maillist.""Clarification of other connection to Roslyn:"", maillist.association, maillist.""Years of association"", maillist.Relatives, maillist.Comments FROM maillist;"
'Set the cursor type we are using so we can navigate through the recordset
rsAddComments.CursorType = 2
'Set the lock type so that the record is locked by ADO when it is updated
rsAddComments.LockType = 3
'Open the recordset with the SQL query
rsAddComments.Open strSQL, adoCon
'Tell the recordset we are adding a new record to it
rsAddComments.AddNew
'Add a new record to the recordset
rsAddComments.Fields("FirstName") = Request.Form("name")
rsAddComments.Fields("Last name") = Request.Form("lname")
rsAddComments.Fields("Maiden name") = Request.Form("mname")
rsAddComments.Fields("e-mail") = Request.Form("email")
rsAddComments.Fields("New submission or update") = Request.Form("update")
rsAddComments.Fields("AddressLine1") = Request.Form("AddressLine1")
rsAddComments.Fields("AddressLine2") = Request.Form("AddressLine2")
rsAddComments.Fields("City") = Request.Form("City")
rsAddComments.Fields("Province/State") = Request.Form("State")
rsAddComments.Fields("Postal Code") = Request.Form("Zip")
rsAddComments.Fields("Country") = Request.Form("Country")
rsAddComments.Fields("phone number:") = Request.Form("areac") & Request.Form("phonea") & Request.Form("phoneb")
rsAddComments.Fields("International phone:") = Request.Form("intphone")
rsAddComments.Fields("Present Relationship to Roslyn") = Request.Form("relation")
rsAddComments.Fields("Clarification of other connection to Roslyn:") = Request.Form("specifyrelation")
rsAddComments.Fields("association") = Request.Form("association")
rsAddComments.Fields("Years of association") = Request.Form("yearsat")
rsAddComments.Fields("Relatives") = Request.Form("relatives")
rsAddComments.Fields("Comments") = Request.Form("comments")
'Write the updated recordset to the database
rsAddComments.Update
'Reset server objects
rsAddComments.Close
Set rsAddComments = Nothing
Set adoCon = Nothing
%>

brazenskies
10-16-2008, 08:42 PM
be sure to use code tags, makes things easier to read...


<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsAddComments 'Holds the recordset for the new record to be added
Dim strSQL 'Holds the SQL query to query the database
'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("rosem2008rsf.mdb")
'Create an ADO recordset object
Set rsAddComments = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT maillist.FirstName, maillist.""Last name"", maillist.""Maiden name"", maillist.""New submission or update"", maillist.e-mail, maillist.AddressLine1, maillist.AddressLine2, maillist.City, maillist.""Province/State"", maillist.""Postal Code"", maillist.Country, maillist.""phone number:"", maillist.""International phone:"", maillist.""Present Relationship to Roslyn"", maillist.""Clarification of other connection to Roslyn:"", maillist.association, maillist.""Years of association"", maillist.Relatives, maillist.Comments FROM maillist;"
'Set the cursor type we are using so we can navigate through the recordset
rsAddComments.CursorType = 2
'Set the lock type so that the record is locked by ADO when it is updated
rsAddComments.LockType = 3
'Open the recordset with the SQL query
rsAddComments.Open strSQL, adoCon
'Tell the recordset we are adding a new record to it
rsAddComments.AddNew
'Add a new record to the recordset
rsAddComments.Fields("FirstName") = Request.Form("name")
rsAddComments.Fields("Last name") = Request.Form("lname")
rsAddComments.Fields("Maiden name") = Request.Form("mname")
rsAddComments.Fields("e-mail") = Request.Form("email")
rsAddComments.Fields("New submission or update") = Request.Form("update")
rsAddComments.Fields("AddressLine1") = Request.Form("AddressLine1")
rsAddComments.Fields("AddressLine2") = Request.Form("AddressLine2")
rsAddComments.Fields("City") = Request.Form("City")
rsAddComments.Fields("Province/State") = Request.Form("State")
rsAddComments.Fields("Postal Code") = Request.Form("Zip")
rsAddComments.Fields("Country") = Request.Form("Country")
rsAddComments.Fields("phone number:") = Request.Form("areac") & Request.Form("phonea") & Request.Form("phoneb")
rsAddComments.Fields("International phone:") = Request.Form("intphone")
rsAddComments.Fields("Present Relationship to Roslyn") = Request.Form("relation")
rsAddComments.Fields("Clarification of other connection to Roslyn:") = Request.Form("specifyrelation")
rsAddComments.Fields("association") = Request.Form("association")
rsAddComments.Fields("Years of association") = Request.Form("yearsat")
rsAddComments.Fields("Relatives") = Request.Form("relatives")
rsAddComments.Fields("Comments") = Request.Form("comments")
'Write the updated recordset to the database
rsAddComments.Update
'Reset server objects
rsAddComments.Close
Set rsAddComments = Nothing
Set adoCon = Nothing
%>

BCRandCo
10-16-2008, 09:52 PM
Sorry. Change made.
Michael

Roelf
10-17-2008, 07:49 AM
column names should be surrounded with [] if they contain special characters like spaces or reserved words.

So your sql statement should look like:
strSQL = "SELECT maillist.FirstName, maillist.[Last name], maillist.[Maiden name], maillist.[New submission or update], maillist.[e-mail], maillist.AddressLine1, maillist.AddressLine2, maillist.City, maillist.[Province/State], maillist.[Postal Code], maillist.Country, maillist.[phone number:], maillist.[International phone:], maillist.[Present Relationship to Roslyn], maillist.[Clarification of other connection to Roslyn:], maillist.association, maillist.[Years of association], maillist.Relatives, maillist.Comments FROM maillist;"