ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old July 13th, 2003, 03:50 PM
gxblueknight gxblueknight is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 20 gxblueknight User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old July 13th, 2003, 06:34 PM
mohecan mohecan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Melbourne, Australia
Posts: 212 mohecan User rank is Private First Class (20 - 50 Reputation Level)mohecan User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
For future reference, this topic has been discussed and answered a number of times, try searching the forums next time before posting

Quote:
sSQL = "SELECT * FROM AssemblyName Where Text='%%" + Request.QueryString("assembly") + "%%'"


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?

Reply With Quote
  #3  
Old July 13th, 2003, 06:47 PM
gxblueknight gxblueknight is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 20 gxblueknight User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks, sorry for posting w/o searching, I will search next time.

Reply With Quote
  #4  
Old July 13th, 2003, 06:55 PM
gxblueknight gxblueknight is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 20 gxblueknight User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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)

Reply With Quote
  #5  
Old July 13th, 2003, 07:05 PM
mohecan mohecan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Melbourne, Australia
Posts: 212 mohecan User rank is Private First Class (20 - 50 Reputation Level)mohecan User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
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.

Reply With Quote
  #6  
Old July 13th, 2003, 07:08 PM
gxblueknight gxblueknight is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 20 gxblueknight User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The parameter is coming from the QueryString. And the Name of the field is 'assembly'

Reply With Quote
  #7  
Old July 13th, 2003, 07:11 PM
mohecan mohecan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Melbourne, Australia
Posts: 212 mohecan User rank is Private First Class (20 - 50 Reputation Level)mohecan User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
ok then, your query should read as:

Code:
sSQL = "SELECT * FROM AssemblyName Where assembly='%" & Request.QueryString("assembly") & "%'"

Reply With Quote
  #8  
Old July 13th, 2003, 07:14 PM
gxblueknight gxblueknight is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 20 gxblueknight User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #9  
Old July 13th, 2003, 07:19 PM
mohecan mohecan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Melbourne, Australia
Posts: 212 mohecan User rank is Private First Class (20 - 50 Reputation Level)mohecan User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Sorry, Monday morning, brain hasn't kicked in properly yet, try this:
Code:
sSQL = "SELECT * FROM AssemblyName Where assembly LIKE '%" & Request.QueryString("assembly") & "%'"

Reply With Quote
  #10  
Old July 13th, 2003, 07:24 PM
gxblueknight gxblueknight is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 20 gxblueknight User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #11  
Old July 13th, 2003, 07:45 PM
mohecan mohecan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Melbourne, Australia
Posts: 212 mohecan User rank is Private First Class (20 - 50 Reputation Level)mohecan User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
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") & "'"

Reply With Quote
  #12  
Old July 13th, 2003, 07:55 PM
gxblueknight gxblueknight is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 20 gxblueknight User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks man that worked....

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Search In Asp


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway