I
isaac2004
hi i have a page that inclued a SQL statement that takes a user input
from a form and displays the request from the database. every time i
try to open the page i get an error message that says Data type
mismatch in criteria expression where i open the record set. usually
this means that you have something as a number when it shouldnt be but
i dont know what is wrong. \
here is my code
<% Option Explicit %>
<html>
<!--#include file="DatabaseConnect.asp"-->
<!--#include virtual="/06Winter/levini/database/adovbs.inc"-->
<head>
<title>Query the Clothier Database</title>
</head>
<body>
<center>
<h3>Query the Clothier Database</h3><hr>
<p> <b>List all items supplied by a vendor.</b></p>
<% dim strSQL, objRS, strVendorID
strVendorID = request.querystring("strVendorID")
strSQL = "SELECT Vendors.VendorID, Vendors.VendorName,
Items.ItemName, Items.ItemPriceBuy " & _
"FROM Items INNER JOIN Vendors ON Items.VendorID =
Vendors.VendorID " & _
"WHERE (((Vendors.VendorID) = '" & strVendorID & "')) " &
_
"ORDER BY Items.ItemName "
response.write strSQL
Set objRS = Server.CreateObject ("ADODB.Recordset")
objRS.Open strSQL, objConn
%>
Use either form:
<div align="center">
<center>
<table border="0" cellpadding="3" cellspacing="0" width="400">
<tr>
<td align="center" bgcolor="#FFFFCC">
<form method="GET" >
<p>Vendor ID (1-4)</p>
<p><input type="text" name="strVendorID" size="1"
maxlength="1"></p>
<p><input type="submit" value="Submit Query"></p>
</form>
</td>
<td width="100"> </td>
<td align="center" bgcolor="#FFFFCC">
<form method="GET">
<p>Vendor ID</p>
<p>
<select size="1" name="strVendorID">
<option selected value="1">Vendor 1</option>
<option value="2">Vendor 2</option>
<option value="3">Vendor 3</option>
<option value="4">Vendor 4</option>
</select></p>
<p><input type="submit" value="Submit Query"></p>
</form>
</td>
</tr>
</table>
<p align="center">What advantage does the right-hand form have?</p>
<!-- Response
************************************************************ -->
<%
if strVendorID > 0 then
response.write"<hr>All items by Vendor " & strVendorID & "<br>
Ordered by Item Name.<hr>"
response.write"<table border='1' cellpadding='3' cellspacing='0'
bordercolor='#BBDBE6'>"
response.write"<TR>"
response.write"<td><b>VendorID</b></td>"
response.write"<TD><b>Vendor Name</b></td>"
response.write"<td><b>Item Name</b></td>"
response.write"<td><b>Price</b></td>"
response.write"</tr>"
Do While Not objRS.EOF
response.write"<tr>"
response.write"<td>" & objRS("VendorID") & " </td>"
response.write"<td>" & objRS("VendorName") & " </td>"
response.write"<td>" & objRS("ItemName") & " </td>"
response.write"<td>" & objRS("ItemPriceBuy") & " </td>"
response.write"</tr>"
objRS.MoveNext
Loop
else if strVendor > 4 then
response.write"<hr>"
response.write" All items by Vendor " & strVendorID & "<br> Ordered by
Item Name."
response.write"<hr>"
response.write"No Records match your search. Please try again.<br><br>"
else if strVendor < 1 then
response.write"<hr>"
response.write" All items by Vendor " & strVendorID & "<br> Ordered by
Item Name."
response.write"<hr>"
response.write"No Records match your search. Please try again.<br><br>"
end if
end if
end if
%>
</body>
</html>
the problem is with the actual SQL statement but the syntax looks fine
to me.
any help would be greatly appreciated
from a form and displays the request from the database. every time i
try to open the page i get an error message that says Data type
mismatch in criteria expression where i open the record set. usually
this means that you have something as a number when it shouldnt be but
i dont know what is wrong. \
here is my code
<% Option Explicit %>
<html>
<!--#include file="DatabaseConnect.asp"-->
<!--#include virtual="/06Winter/levini/database/adovbs.inc"-->
<head>
<title>Query the Clothier Database</title>
</head>
<body>
<center>
<h3>Query the Clothier Database</h3><hr>
<p> <b>List all items supplied by a vendor.</b></p>
<% dim strSQL, objRS, strVendorID
strVendorID = request.querystring("strVendorID")
strSQL = "SELECT Vendors.VendorID, Vendors.VendorName,
Items.ItemName, Items.ItemPriceBuy " & _
"FROM Items INNER JOIN Vendors ON Items.VendorID =
Vendors.VendorID " & _
"WHERE (((Vendors.VendorID) = '" & strVendorID & "')) " &
_
"ORDER BY Items.ItemName "
response.write strSQL
Set objRS = Server.CreateObject ("ADODB.Recordset")
objRS.Open strSQL, objConn
%>
Use either form:
<div align="center">
<center>
<table border="0" cellpadding="3" cellspacing="0" width="400">
<tr>
<td align="center" bgcolor="#FFFFCC">
<form method="GET" >
<p>Vendor ID (1-4)</p>
<p><input type="text" name="strVendorID" size="1"
maxlength="1"></p>
<p><input type="submit" value="Submit Query"></p>
</form>
</td>
<td width="100"> </td>
<td align="center" bgcolor="#FFFFCC">
<form method="GET">
<p>Vendor ID</p>
<p>
<select size="1" name="strVendorID">
<option selected value="1">Vendor 1</option>
<option value="2">Vendor 2</option>
<option value="3">Vendor 3</option>
<option value="4">Vendor 4</option>
</select></p>
<p><input type="submit" value="Submit Query"></p>
</form>
</td>
</tr>
</table>
<p align="center">What advantage does the right-hand form have?</p>
<!-- Response
************************************************************ -->
<%
if strVendorID > 0 then
response.write"<hr>All items by Vendor " & strVendorID & "<br>
Ordered by Item Name.<hr>"
response.write"<table border='1' cellpadding='3' cellspacing='0'
bordercolor='#BBDBE6'>"
response.write"<TR>"
response.write"<td><b>VendorID</b></td>"
response.write"<TD><b>Vendor Name</b></td>"
response.write"<td><b>Item Name</b></td>"
response.write"<td><b>Price</b></td>"
response.write"</tr>"
Do While Not objRS.EOF
response.write"<tr>"
response.write"<td>" & objRS("VendorID") & " </td>"
response.write"<td>" & objRS("VendorName") & " </td>"
response.write"<td>" & objRS("ItemName") & " </td>"
response.write"<td>" & objRS("ItemPriceBuy") & " </td>"
response.write"</tr>"
objRS.MoveNext
Loop
else if strVendor > 4 then
response.write"<hr>"
response.write" All items by Vendor " & strVendorID & "<br> Ordered by
Item Name."
response.write"<hr>"
response.write"No Records match your search. Please try again.<br><br>"
else if strVendor < 1 then
response.write"<hr>"
response.write" All items by Vendor " & strVendorID & "<br> Ordered by
Item Name."
response.write"<hr>"
response.write"No Records match your search. Please try again.<br><br>"
end if
end if
end if
%>
</body>
</html>
the problem is with the actual SQL statement but the syntax looks fine
to me.
any help would be greatly appreciated