I am trying to create a script to view/edit a profile. I can login and pass session variables between pages but I am getting this error
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
/viewprofile.asp, line 54
If I comment things out I can see the SQL string and that is correct. I can also see the userID variable too just fine.
PS line 54 is "rsViewProfile.Open strSQL, adoCon"
Here is the code
<%
'Dimension Variables
Dim strUserName 'Holds the name of the user
Dim userID
Dim adoCon 'Holds the Database Connection Object
Dim rsViewProfile 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query to query the database
'Get the users name passed from the previous page
strUserName = Session("userName")
userID = Session("userID")
'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 "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("toddwoolums_site.mdb")
'Create an ADO recordset object
Set rsViewProfile = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT firstname FROM tblUsers WHERE ID ='" & userID & "'"
'Open the recordset with the SQL query
rsViewProfile.Open strSQL, adoCon
If NOT rsViewProfile.EOF Then
Response.Write ("<br>")
Response.Write (rsViewProfile("firstname"))
Response.Write ("<br>")
Response.Write ("<br>")
End If
'Reset server objects
rsViewProfile.Close
Set rsViewProfile = Nothing
Set adoCon = Nothing
%>
sql string <% = strSQL %>
Your user id is <% =userID %>