Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: SEARCH using recordsets


Message #1 by "sharad bhalla" <sbhalla@s...> on Sun, 11 Jun 2000 02:36:23 +1000
hi,

i am really struggling with my search code with the use of recordsets.

could you please let me know how to progress by giving me some code of 

some kind.

i actually need to search for 2 fields in a table when the user supplies 

then into a text box of some kind.

could u please help me as soon as possible.



As the user enters into the text boxes and presses submit it searches 

down on those basis and then displays using asp and recordsets.

if possible could you please tell me how could i even write a procedure 

for it and then call it in my script.



thanks

sharad
Message #2 by "Ken Schaefer" <ken.s@a...> on Mon, 12 Jun 2000 15:40:47 +1000
This is your third question on this topic - why can't you just go and buy

the book?



Beginning Active Server Pages v3 - Wrox Press.



Amend this to suite - please stop asking the same question!



--- page1.asp ---



<form method="post" action="page2.asp">

    <input type="text" name="t1"> 

    <input type="submit" value="Submit">

</form>



--- page2.asp ---



<%

If Len(Request.Form("t1")) then

    strVar = Request.Form("t1")

    strVar = Replace(strVar, "'", "''")

    strVar = Replace(strVar, Chr(34), Chr(34) & Chr(34))



    strSQL = "SELECT field1, field2, ...etc... fieldn "

    strSQL = "FROM table1 "

    strSQL = "WHERE field1 = '" & strVar & "'"



    set objConn = Server.CreateObject("ADODB.Connection")

    objConn.Open Application("strDBConnectionString")

    set objRS = objConn.execute(strSQL)



    If objRS.EOF and objRS.BOF then

        Response.Write("No records returned")

    Else

        Response.Write("<table><tr>")

        For each objField in objRS.Fields

            Response.Write("<td>" & objField.Name & "</td>")

        Next

        Response.Write("</tr>")



        Do While Not objRS.EOF

            Response.Write("<tr>")

            For each objField in objRS.Fields

                Response.Write("<td>" & objField.Value & "</td>")

            Next

            Response.Write("</tr>")

            objRS.movenext

        Loop

    End If



    objConn.close

    set objConn = nothing



End If

%>



Cheers

Ken





----- Original Message -----

From: "sharad bhalla" <sbhalla@s...>

To: "ASP Databases" <asp_databases@p...>

Sent: Sunday, June 11, 2000 2:36 AM

Subject: [asp_databases] SEARCH using recordsets








  Return to Index