ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old July 15th, 2003, 08:37 AM
snorkmaiden snorkmaiden is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 11 snorkmaiden User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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)

Reply With Quote
  #2  
Old July 15th, 2003, 08:54 AM
kkong's Avatar
kkong kkong is offline
Monkey Magic
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: UK
Posts: 103 kkong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to kkong
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.

Reply With Quote
  #3  
Old July 15th, 2003, 08:58 AM
snorkmaiden snorkmaiden is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 11 snorkmaiden User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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
%>

Reply With Quote
  #4  
Old July 15th, 2003, 09:01 AM
kkong's Avatar
kkong kkong is offline
Monkey Magic
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: UK
Posts: 103 kkong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to kkong
ah not quite like that, actually from the SQL statments point of view:

WHERE userID='" & ID & "' "


Kong.

Reply With Quote
  #5  
Old July 15th, 2003, 09:35 AM
snorkmaiden snorkmaiden is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 11 snorkmaiden User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #6  
Old July 17th, 2003, 04:12 AM
Agarash Agarash is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: South Africa
Posts: 53 Agarash User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 35 sec
Reputation Power: 6
one question: is ID a field in your database or is it a variable in your asp page??

Reply With Quote
  #7  
Old July 17th, 2003, 04:30 AM
snorkmaiden snorkmaiden is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 11 snorkmaiden User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #8  
Old July 17th, 2003, 04:38 AM
rgdubey rgdubey is offline
I am here to share knowledge
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: India
Posts: 83 rgdubey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Try this

dim ID, sqlstmt
ID= Session("SessionID")

Reply With Quote
  #9  
Old July 17th, 2003, 04:41 AM
Agarash Agarash is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: South Africa
Posts: 53 Agarash User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 35 sec
Reputation Power: 6
i had the same problem, this is the solution:

WHERE userID=' "&(user)&" '

Reply With Quote
  #10  
Old July 17th, 2003, 01:59 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,711 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 1 Day 23 h 21 m 59 sec
Reputation Power: 688
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.

Reply With Quote
  #11  
Old July 18th, 2003, 04:50 AM
yaan yaan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 10 yaan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Data type mismatch?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway