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 > Data type mismatch in criteria expression

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-26-04, 04:21
Q80-DB Q80-DB is offline
Registered User
 
Join Date: Jun 2004
Posts: 13
Angry Data type mismatch in criteria expression

Hi all,
Here is my code :-

Code:
<%

Dim oADO, oRS, sSQL
Dim sUserID, sPassword

sStd_ID = Request.Form("txtStd_ID")
sStd_pwd = Request.Form("txtStd_pwd")


sSQL = "SELECT Quizes,Midterm1,Midterm2,Final,Bonus,Grade FROM [sheet1$] 
WHERE [Std_ID]='" & q(sStd_ID) & "' AND [Std_pwd]='" & q(sStd_pwd) & "'"
Set oADO = CreateObject("ADODB.Connection")
oADO.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data 
Source=D:\Path\To\This\File.xls;Extended Properties=""Excel 
8.0;HDR=Yes;IMEX=1"""

Set oRS = oADO.Execute(sSQL)
If oRS.EOF Then
Response.Write "Login failed."
Else
%>
<table>
<tr>
  <th>quizzes</th>
  <th>Midterm 1</th>
  <th>Midterm 2</th>
  <th>final</th>
  <th>bonus</th>
  <th>grade</th>
</tr>

<tr>
  <td><%=oRS.Fields.Item(0).Value%></td>
  <td><%=oRS.Fields.Item(1).Value%></td>
  <td><%=oRS.Fields.Item(2).Value%></td>
  <td><%=oRS.Fields.Item(3).Value%></td>
  <td><%=oRS.Fields.Item(4).Value%></td>
  <td><%=oRS.Fields.Item(5).Value%></td>
</tr>
</table>
<%
End If
oRS.Close : Set oRS = Nothing
oADO.Close : Set oADO = Nothing


Function q(s)
q = Replace(s, "'", "''")
End Function
%>
As you can see its linked to Excel sheet and when I try to execute the code it gives me this error :-

Technical Information (for support personnel)

Error Type:
Microsoft JET Database Engine (0x80040E07)
Data type mismatch in criteria expression.
/results.asp, line 16

Line 16 is :-
Set oRS = oADO.Execute(sSQL)


what do you think the problem is ?

Last edited by Q80-DB; 07-26-04 at 12:59.
Reply With Quote
  #2 (permalink)  
Old 07-26-04, 13:01
Q80-DB Q80-DB is offline
Registered User
 
Join Date: Jun 2004
Posts: 13
Hello there ...
thanks anyway I found the problem its about the single quotes '' I should've taken them out because am using numric characters for Std_ID and Std_pwd
Reply With Quote
  #3 (permalink)  
Old 08-04-04, 02:02
Bullschmidt Bullschmidt is offline
Guru
 
Join Date: Jun 2003
Location: USA
Posts: 1,032
Well thanks for letting us all know what the answer was anyways...
__________________
J. Paul Schmidt, Freelance Web and Database Developer
www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips
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