Welcome to WebmasterWorld Guest from

Forum Moderators: ocean10000

Displaying search results

...can't figure out what I am missing

2:48 pm on Sep 20, 2005 (gmt 0)

10+ Year Member

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:

<% 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

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

set connection=Server.CreateObject("ADODB.Connection")
connection.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &_

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?
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"
End if

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<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;
<link href="link.css" rel="stylesheet" type="text/css">

<body leftmargin="0" topmargin="0">
<table width="903" height="600" border="0" align="center">
<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">
<img src="header.gif" width="900" height="104" border="0" usemap="#Map">
<tr valign="top">
<td width="700" rowspan="7"> <div align="center"></div>
<font size="4" face="Arial, Helvetica, sans-serif"><strong>ALL ENTERED SOFTWARE
</strong></font><font color="#000000" size="4" face="Arial, Helvetica, sans-serif"><img src="line.png" width="700" height="11"></font>
<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>"
Response.write "</TR>"
' -- Now output the contents of the Recordset
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>"
Response.write "</TR>"
' -- move to the next record

set objRS = Nothing
set connection = Nothing

<td width="1" height="21">&nbsp;</td>
<td width="3" height="34">&nbsp;</td>
<td height="21">&nbsp;</td>
<td height="37">&nbsp;</td>
<td height="56">&nbsp;</td>
<td height="85">&nbsp;</td>
<td height="21">&nbsp;</td>
<td height="57">&nbsp;</td>
<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>

Can Anyone help? Thanks!
2:52 pm on Sep 20, 2005 (gmt 0)

10+ Year Member

Hi Blelisa,

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



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.


2:59 pm on Sep 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

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

3:05 pm on Sep 20, 2005 (gmt 0)

10+ Year Member

The sql I get back is:

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?
SQL = "SELECT * FROM Bug WHERE 1=2 " & WhereClause
End If

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

3:12 pm on Sep 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member


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

3:18 pm on Sep 20, 2005 (gmt 0)

10+ Year Member

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 & "' "


3:35 pm on Sep 20, 2005 (gmt 0)

10+ Year Member

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

Output of query is now:

5:23 pm on Sep 20, 2005 (gmt 0)

10+ Year Member

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

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month