homepage Welcome to WebmasterWorld Guest from 54.166.113.249
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Displaying search results
...can't figure out what I am missing
Blelisa

10+ Year Member



 
Msg#: 3006 posted 2:48 pm on Sep 20, 2005 (gmt 0)

I have a form that gives my visitors various options to use to search my database for specific records. I have written my code to perform the search and then display the records in an html table. When I run the search I get an error saying:
No value given for one or more required parameters.
/search.asp, line 61

I can not figure out what I have done wrong for the life of me. Here is my code:
<%@LANGUAGE="VBSCRIPT" %>
<% Option Explicit
Dim connection
Dim objRS
Dim strSQL
Dim strConection
Dim i
Dim Tnum
Dim Proj
Dim Sim
Dim thedate
Dim prior
Dim Stat
Dim eby
Dim WhereClause
Dim SQL

Set objRS = Server.CreateObject("ADODB.Recordset")

set connection=Server.CreateObject("ADODB.Connection")
connection.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &_
server.MapPath("data/developers.mdb")
connection.Open

Tnum = Request.Form("tnum")
Proj = Request.Form("proj")
Sim = Request.Form("sim")
thedate = Request.Form("thedate")
Prior = Request.Form("prior")
Stat = Request.Form("stat")
eby = Request.Form("eby")

WhereClause = "" ' alway initialize!

If Tnum <> "" Then
WhereClause = " OR Tnum = " & Tnum
End If
If Proj <> "" Then
WhereClause = WhereClause & " OR Proj = '" & Proj & "'"
End If
If Sim <> "" Then
WhereClause = WhereClause & " OR Sim = '" & Sim & "'"
End If
If thedate <> "" Then
WhereClause = WhereClause & " OR thedate = #" & thedate & "#"
End If
If Prior <> "" Then
WhereClause = WhereClause & " OR Prior = '" & Prior & "'"
End If
If Stat <> "" Then
WhereClause = WhereClause & " OR Stat = '" & Stat & "'"
End If
If eby <> "" Then
WhereClause = WhereClause & " OR eby = '" & eby & "'"
End If
If WhereClause = "" Then
'They didnt select anything...give an error message or something?
Else
SQL = "SELECT * FROM Bug WHERE 1=2 " & WhereClause
End If

set objRS = connection.Execute (SQL)

if (objRS.BOF and objRS.EOF) then
response.write "No records found"
response.end
End if
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.bullet {
list-style-position: inside;
list-style-type: disc;
}
-->
</style>
<link href="link.css" rel="stylesheet" type="text/css">
</head>

<body leftmargin="0" topmargin="0">
<table width="903" height="600" border="0" align="center">
<tr>
<td height="110" colspan="3" valign="bottom"> <div align="left">
<map name="Map">
<area shape="rect" coords="405,72,448,90" href="index.htm">
<area shape="rect" coords="452,71,517,90" href="products.htm">
<area shape="rect" coords="525,72,581,90" href="svcs.htm">
<area shape="rect" coords="589,70,663,90" href="login.asp">
<area shape="rect" coords="669,71,726,91" href="support.htm">
<area shape="rect" coords="732,70,805,92" href="contact.htm">
<area shape="rect" coords="816,71,886,90" href="rlogin.asp">
<area shape="rect" coords="62,4,276,87" href="index.htm">
</map>
<img src="header.gif" width="900" height="104" border="0" usemap="#Map">
</div></td>
</tr>
<tr valign="top">
<td>&nbsp;</td>
<td width="700" rowspan="7"> <div align="center"></div>
<font size="4" face="Arial, Helvetica, sans-serif"><strong>ALL ENTERED SOFTWARE
BUGS<br>
</strong></font><font color="#000000" size="4" face="Arial, Helvetica, sans-serif"><img src="line.png" width="700" height="11"></font>
<blockquote>
<div align="left">
<table width="100%" border="1">
<%
' -- Output the Field Names as the first row in the table
Response.Write "<TR BGCOLOR=""#CCCCCC"">"
For i = 0 to objRS.Fields.Count - 1
Response.Write "<TH><FONT FACE=""ARIAL"" SIZE=""2"">" & objRS.Fields(i).Name & "</FONT></TH>"
Next
Response.write "</TR>"
' -- Now output the contents of the Recordset
objRS.MoveFirst
Do While Not objRS.EOF
' -- output the contents
Response.Write "<TR>"
For i = 0 to objRS.Fields.Count - 1
Response.Write "<TD><FONT FACE=""ARIAL"" SIZE=""1"">" & objRS.Fields(i) & "</FONT></TD>"
Next
Response.write "</TR>"
' -- move to the next record
objRS.MoveNext
Loop

objRS.Close
set objRS = Nothing
connection.Close
set connection = Nothing

%>
</table>
<p>&nbsp;</p>
</div>
</blockquote></td>
<td width="1" height="21">&nbsp;</td>
</tr>
<tr>
<td width="3" height="34">&nbsp;</td>
</tr>
<tr>
<td height="21">&nbsp;</td>
</tr>
<tr>
<td height="37">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="56">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="85">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="21">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="57">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr valign="top">
<td height="29" colspan="3" align="center"><a href="rlogin.asp" class="link"><img src="lines.png" width="900" height="11" border="0">
Developers I </a> <a href="map.htm"class="link" >Site Index I </a> <a href="contact.htm" class="link">Contact
Us I </a> <a href="svcs.htm"class="link" >Services I </a> <a href="news.htm" class="link">Events
I </a> <a href="news,htm" class="link">Articles I </a> <a href="corporate.htm" class="link">
Corporate Info I </a></td>
</tr>
</table>
</body>
</html>

Can Anyone help? Thanks!

 

Mr_Brutal

10+ Year Member



 
Msg#: 3006 posted 2:52 pm on Sep 20, 2005 (gmt 0)

Hi Blelisa,

Your SQL building is a little complicated for me to follow,
could you try adding this line

Response.Write(SQL)

before

set objRS = connection.Execute (SQL)

This should display your SQL statement which is often where the problem lies. Post that back and maybe we can find out more.

Cheers

Iguana

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3006 posted 2:59 pm on Sep 20, 2005 (gmt 0)

That error message is a JET engine message for you've named a parameter but not provided any data. A parameter is any name that is not a database column.

In other words, you've almost certainly misspelt the name of one of your database fields

Blelisa

10+ Year Member



 
Msg#: 3006 posted 3:05 pm on Sep 20, 2005 (gmt 0)

The sql I get back is:
SELECT * FROM Bug WHERE 1=2 OR Tnum = TRLVQM

Looks like the problem lies with "WHERE 1=2"?

So instead of putting:
If WhereClause = "" Then
'They didnt select anything...give an error message or something?
Else
SQL = "SELECT * FROM Bug WHERE 1=2 " & WhereClause
End If

I should just put:
SQL = "SELECT * FROM Bug WHERE = WhereClause?
Is that correct?

Iguana

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3006 posted 3:12 pm on Sep 20, 2005 (gmt 0)

Tnum = TRLVQM

Is Tnum a number or a string? Don't forget the quotes

Mr_Brutal

10+ Year Member



 
Msg#: 3006 posted 3:18 pm on Sep 20, 2005 (gmt 0)

Hi Blelisa,

I think your 1=2 part is to allow you to place OR in the front of each Where clause. 1=2 will always be false but the SQL will pull back the data using the rest of the where clause.

The problem looks like TNum is expected to be a number but your getting characters instead. Trying puttin single quotes around the TNum value.

WhereClause = " OR Tnum = '" & Tnum & "' "

Cheers

Blelisa

10+ Year Member



 
Msg#: 3006 posted 3:35 pm on Sep 20, 2005 (gmt 0)

tried the changes with the quotes, also changed the whereclause to 1=1 Still no luck

Output of query is now:
SELECT * FROM Bug WHERE 1=1 OR Tnum = 'TRLVQM'

Blelisa

10+ Year Member



 
Msg#: 3006 posted 5:23 pm on Sep 20, 2005 (gmt 0)

Nevermind I figured it out, turned out to be a misspell, as usual

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved