If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Select statment Getting mismatch data error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-08-03, 10:53
turkle112 turkle112 is offline
Registered User
 
Join Date: Sep 2003
Posts: 2
Exclamation Select statment Getting mismatch data error

Good morning everyone. I am working on selecting from a database and displaying the results, what should be an easy code to code is turned into a nightmare. My select statement is as follows

Code:
sql2="SELECT * FROM line_data WHERE customerNumber = " & customerNumber
Where CustomerNumber is passed in through a querystring like www.domain.com/page.asp?custNum=1234567

The error I am getting is
Code:
Microsoft OLE DB Provider for ODBC Drivers error '80040e07' 

[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
The field customerNumber in the database is text, does that make a difference? Is there a function to change this from a number to text, if the above is the case? Any help would be appreciated

Turk
Reply With Quote
  #2 (permalink)  
Old 09-08-03, 11:58
fused fused is offline
Registered User
 
Join Date: May 2003
Posts: 23
Code:
"SELECT * FROM line_data WHERE customerNumber = '" & Request.QueryString("custnum") & "'"
Reply With Quote
  #3 (permalink)  
Old 09-08-03, 12:09
turkle112 turkle112 is offline
Registered User
 
Join Date: Sep 2003
Posts: 2
Sorry about that I request the string in an if statement above.
Code:
dim customerNumber
'if the customer number is empty assign message if not assign number to variable
if request.QueryString("custNum") <> "" then
	customerNumber = request.QueryString("custNum")
	set conn=Server.CreateObject("ADODB.Connection") 
	conn.Open "h_data"
	'setting up recordset and opening data table
	set rs1=Server.CreateObject("ADODB.recordset")
	'select all rows from table where customer number matches number passed in
	sql2="SELECT * FROM l_data WHERE customerNumber = " & customerNumber
	rs1.Open sql2, conn
	rs1 = conn.execute (sql2)
else 
	customerNumber = "Customer number not found"
end if
Theres the code for everything
Reply With Quote
  #4 (permalink)  
Old 09-12-03, 21:16
bill_dev bill_dev is offline
Registered User
 
Join Date: Sep 2003
Posts: 60
...in Access what datatype is the "customerNumber" field? If it is Text then that is why fused suggested you add quotes which you may have overlooked.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On