Forums
This topic is locked
I need help (Too few parameters. Expected 1. )
Posted 28 Sep 2001 11:30:27
1
has voted
28 Sep 2001 11:30:27 Paul Gannon posted:
HiI'm pretty new to ASP, and am struggling with a piece of code and can't figure it out. Fron a HTML form search box, the database is supposed to be searched. But isn't not working.
I am getting this error
Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
/totalreddwarf/fansite_directory/searchdb.asp, line 27
This is my code
Dim searchStr, MyConn, RS, i
searchStr = Replace(Request.Form("strSearch", "'", "''"
Set MyConn=Server.CreateObject("ADODB.Connection"
MyConn.Open "totalreddwarf1"
SQL = "SELECT * FROM tblFansites WHERE tblFansites.SiteDescription"
SQL = SQL & "LIKE '%"& strSearch & "%' "
Set RS = MyConn.Execute(SQL)
If searchStr <> "" Then
If RS.BOF AND RS.EOF Then
Response.Write "<center> No Records Found.</center>"
Else
Response.Write "<center><table border=""1""><tr>"
For i= 0 to RS.Fields.Count - 1
Response.Write "<th>" & RS(i).SiteTitle & "</th>"
Next
Response.Write "</tr>"
While Not RS.EOF
Response.Write "<tr>"
For i= 0 to RS.Fields.Count - 1
Response.Write "<td>" & RS(i) & "</td>"
Next
Response.Write "</tr>"
RS.MoveNext
WEND
Response.Write "</table>"
End If
Else
Response.Write "<center>No Search String Entered.</center>"
End IF
RS.Close
MyConn.Close
Set RS = Nothing
Set MyConn = Nothing
Can anyone see what I'm doing wrong?
Many Thanx
Paul
Replies
Replied 28 Sep 2001 17:47:25
28 Sep 2001 17:47:25 Viktor Farcic replied:
What part of this code is line 27?
Edited by - vfarcic on 09/28/2001 17:51:02
Edited by - vfarcic on 09/28/2001 17:51:02
Replied 28 Sep 2001 17:58:00
28 Sep 2001 17:58:00 Paul Gannon replied:
Hiya
Set RS = MyConn.Execute(SQL)
is line 27 but I have a feeli9ng that is't something to do with the line before it
Paul
Set RS = MyConn.Execute(SQL)
is line 27 but I have a feeli9ng that is't something to do with the line before it
Paul
Replied 28 Sep 2001 19:27:06
28 Sep 2001 19:27:06 Owen Eastwick replied:
Yuo've used two different variable names:
Dim <b>searchStr</b>, MyConn, RS, i
<b>searchStr</b> = Replace(Request.Form("strSearch", "'", "''"
Then later on:
SQL = SQL & "LIKE '%"& <b>strSearch</b> & "%' "
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Dim <b>searchStr</b>, MyConn, RS, i
<b>searchStr</b> = Replace(Request.Form("strSearch", "'", "''"
Then later on:
SQL = SQL & "LIKE '%"& <b>strSearch</b> & "%' "
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 01 Oct 2001 13:01:10
01 Oct 2001 13:01:10 Paul Gannon replied:
Oh yeah ! Doh! <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
I'll give it a try, thanx very much <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Paul
I'll give it a try, thanx very much <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Paul