codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  How do i search a table in my database using ASP  Monkey at 19:22 on Wednesday, May 05, 2004
 

Hi everyone, i want to enter a value into a text field, then click my submit button, i want this then to generate the asp code which should then search the database. for example i enter a part e.g. seal, then i press submit it then searches the database for seal then it displays this in another html page. Does anyone know how to do this, any help would be much appreciated. I know in my asp page i will need

<%

dim rsPru, adoPruCon, adoPruCmd, sPruDB, sSQL

sPruDB="Provider=Microsoft.Jet.OLEDB.4.0; " & "Data Source=" & server.MapPath("PRU.mdb")
set adoPruCon= Server.CreateObject("ADODB.Connection")
adoPruCon.Open sPruDB
set rsPru=server.createObject("ADODB.Recordset")
sSQL = "SELECT * FROM T_Parts"
rsPru.open sSQL, adoPruCon, adOpenDynamic, adLockOptimistic, adCmdText


%>

<%

if rsPru.EOF then

Response.Write "No records returned, please search again"

else

Response.Write "<TABLE>"


while not rsPru.EOF

Response.Write "<hr>"
Response.Write "<b>PART: </b>" & rsPru("CH_Part Name") & "<b> / TYPE: </b>" & rsPru("CH_Part Description") & "<br>"
Response.Write "<b>REF: </b>" & rsPru("CH_Refernce") & "<b> / PRICE: £</b>" & rsPru("CH_Price") & "<br>"


Response.Write "<br>"

rsPru.MoveNext
wend
end if

%>

what would i need to put in the html?.
But how do i write it to a html page and display, but also how can i keep it there for when i want to add another. display all the parts the user as requested etc.

  Re: How do i search a table in my database using ASP  marx at 21:52 on Thursday, May 20, 2004
 

I am not sure of what exactly u r asking. Could u clarify please?


  Re: How do i search a table in my database using ASP  arasaki1 at 14:39 on Friday, May 21, 2004
 

I agree with Marx I am not sure exactly what you are looking for. From the code you listed you are going to list all of the records in the table...do you want to just find a specific record?

  Re: How do i search a table in my database using ASP  Troy Wolf at 20:26 on Wednesday, May 26, 2004
 

To answer part of your question--that is how to only show results matching the text entered by the user in the HTML form: Simply have a textbox in a form. Submit that form to your ASP page (similar to the ASP you listed). Have that page test the value of the textbox -- if the length is greater than 0, then add
"where CH_PARTNAME like '%" & Request.Form("part_search") & "%'"
to your query. Then your SQL query will only return the matching parts.
Troy Wolf: site expert
Shiny Solutions









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: Print and print preview file on the website without using the File - Print on the IE
•  Re: ASP.NET web controls
•  Re: JavaSript Problem In Mac Safari Browser
•  Re: DHTML div positionning Problem
•  Convert script to NS6 compatible - Please Help!
•  Print .doc file from the website using System.Diagnostics.Process
•  Re: Fullscreen code
•  Re: iframe targeting
•  Excel n ASP


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005