|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
Search In Asp
I am trying to search my access database using asp here is my code. I am also wanting to know how to display the results after I have openend the recordset.
Code:
<%
Option Explicit
Response.Expires = -1000
Dim oConn
Dim oRS
Dim sSQL
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open("Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("\gxblueknight\db\Parts.mdb"))
sSQL = "SELECT * FROM AssemblyName Where Text='%%" + Request.QueryString("assembly") + "%%'"
Set oRS = oConn.Execute(sSQL)
oConn.Close
Set oRS = Nothing
Set oConn = Nothing
%>
Here is the error that I am getting: Microsoft OLE DB Provider for ODBC Drivers error '80040e10' [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. /gxblueknight/RequestQuery.asp, line 13 Thanks, Last edited by gxblueknight : July 13th, 2003 at 04:03 PM. |
|
#2
|
|||
|
|||
|
For future reference, this topic has been discussed and answered a number of times, try searching the forums next time before posting
![]() Quote:
Use ampersand's (&'s) rather than +'s to concatenate your string. Also, you should only need to use one % mark at the beginning and one at the end of search criteria, such that Code:
sSQL = "SELECT * FROM AssemblyName Where Text='%" & Request.QueryString("assembly") & "%'"
As for displaying your results: Code:
If oRS.EOF OR oRS.BOF Then
Response.Write "No Records Found"
Else
oRS.MoveFirst
Do While NOT oRS.EOF
Response.Write oRS("AssemblyName") & "<br>"
oRS.MoveNext
Loop
End if
[/code] DevGuru is a great resource for ASP/ADO help. HTH ![]()
__________________
How can I soar like an eagle when I'm flying with turkey's? |
|
#3
|
|||
|
|||
|
Thanks, sorry for posting w/o searching, I will search next time.
|
|
#4
|
|||
|
|||
|
sorry can't get it to work
here is the error now: Microsoft OLE DB Provider for ODBC Drivers error '80040e10' [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. /gxblueknight/RequestQuery.asp, line 15 Code:
Set oRS = oConn.Execute(sSQL) |
|
#5
|
|||
|
|||
|
Is the field you are searching on called "Text"?
If so, change the name of the field, Text is a reserved word, if it isn't then change Text to the name of the field. Otherwise, is the parameter coming from the QueryString, or is it a "posted" value. |
|
#6
|
|||
|
|||
|
The parameter is coming from the QueryString. And the Name of the field is 'assembly'
|
|
#7
|
|||
|
|||
|
ok then, your query should read as:
Code:
sSQL = "SELECT * FROM AssemblyName Where assembly='%" & Request.QueryString("assembly") & "%'"
|
|
#8
|
|||
|
|||
|
Ok i changed that and every time i search for something that i know is in the database it says no records found. %
Last edited by gxblueknight : July 15th, 2003 at 10:42 PM. |
|
#9
|
|||
|
|||
|
Sorry, Monday morning, brain hasn't kicked in properly yet, try this:
Code:
sSQL = "SELECT * FROM AssemblyName Where assembly LIKE '%" & Request.QueryString("assembly") & "%'"
|
|
#10
|
|||
|
|||
|
Thanks Man That worked but one more question, it displays all the records in the assembly field instead of just displaying the specific on that was searched for.....Man I think you so much for helping me out.
|
|
#11
|
|||
|
|||
|
There's two ways of searching, one is to do what we've done, which is to return all results like the entered criteria.
The other is to return exact matches. If you want return exact matches only use: Code:
sSQL = "SELECT * FROM AssemblyName Where assembly = '" & Request.QueryString("assembly") & "'"
|
|
#12
|
|||
|
|||
|
Thanks man that worked....
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Search In Asp |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|