|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Data type mismatch?
Anybody spot the obvious?
The Code: <% dim ID ID= Session.SessionID Set MyConn = Server.CreateObject("ADODB.Connection") Set RS=Server.CreateObject("ADODB.RecordSet") MyConn.OPEN "mentor" sqlstmt = "SELECT * From infograb" sqlstmt= sqlstmt & " WHERE userID=" & ID Set RS = MyConn.execute(sqlstmt) Do While Not RS.eof %> The Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80040E07) [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression. /test/regmem11.asp, line 21 which is the execute line.... [note all fields in the database are text) |
|
#2
|
||||
|
||||
|
Hi,
in the SQL statement I think you need to add ' ' around the ID variable as it's text. Also you haven't defined sqlstmt (that probably won't make any difference). Kong. |
|
#3
|
|||
|
|||
|
did that now getting syntax error!
<%
dim ID, sqlstmt ID= Session.SessionID Set MyConn = Server.CreateObject("ADODB.Connection") Set RS=Server.CreateObject("ADODB.RecordSet") MyConn.OPEN "mentor" sqlstmt = "SELECT * From infograb" sqlstmt= sqlstmt & " WHERE userID=" & 'ID' Set RS = MyConn.execute(sqlstmt) Do While Not RS.eof %> |
|
#4
|
||||
|
||||
|
ah not quite like that, actually from the SQL statments point of view:
WHERE userID='" & ID & "' " Kong. |
|
#5
|
|||
|
|||
|
Ii did that - still no banana
I tried it as:
sqlstmt = "SELECT * From infograb" sqlstmt= sqlstmt & " WHERE userID='" & ID & "' " Still no joy.. making the field 'text' has also thrown out the other pages which were quite happily referencing it as a number field in the dtabase so I have changed it back to being a number (basically it's the value of Session.SessionId, inserted into the db when they start the pages. So how should I phrase the query if it is now looking at a number field .... Tried various withou/without brackets & am now lost in the confusing of single & double quotes. Maixne |
|
#6
|
|||
|
|||
|
one question: is ID a field in your database or is it a variable in your asp page??
|
|
#7
|
|||
|
|||
|
ID is an asp variable
dim ID, sqlstmt
ID= Session.SessionID userID is a database field, type: number, assigned to the record when they first encounter the website. Any help? |
|
#8
|
|||
|
|||
|
Try this
dim ID, sqlstmt ID= Session("SessionID") |
|
#9
|
|||
|
|||
|
i had the same problem, this is the solution:
WHERE userID=' "&(user)&" ' |
|
#10
|
|||
|
|||
|
You can add a line response.write sqlstmt to see what is really being sent in the sql statement to the database server.
My guess is session("sessionid") doesn't have what you expect, or doesn't exist, so ID ends up being empty or null. |
|
#11
|
|||
|
|||
|
a quick check using the response.write would be to insert the following into your page: response.write "ID=" & ID
This should display exactly what the "ID" variable is. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Data type mismatch? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|