coding asp classic

  • Wurn
  • Graduate
  • Graduate
  • User avatar
  • Posts: 122
  • Loc: Cape Town

Post 3+ Months Ago

Hey all, am i wasting my time asking a classic ASP question on here?

IF not can someone please advise me how i can write code to look at my Forms input Text box, take what the user put in and then search my MS Access db and display the results. The user will only search for FirstName or LastName

I am using Dreamweaver CS4, ASP and MS Access
I know it must be possible to do this. Thx in advance

ps. please resist from advising me to use any other programms or code. Only reason im not using ASP . NET is becuase for some reason DW CS4 will not allow me to create a Dataset using Recordset. If i use classic ASP it then gives me the Recordset option.

Here's my code:
Code: [ Select ]
<%
Dim Recordset__ID
Recordset__ID = "1"
If (Request.Form("")   <> "") Then
 Recordset__ID = Request.Form("")  
End If
%>
<%
Dim Recordset
Dim Recordset_cmd
Dim Recordset_numRows

Set Recordset_cmd = Server.CreateObject ("ADODB.Command")
Recordset_cmd.ActiveConnection = MM_Smit_STRING
Recordset_cmd.CommandText = "SELECT ?, FirstName, LastName, ext, cell FROM tel WHERE FirstName LIKE 'w%'"
Recordset_cmd.Prepared = true
Recordset_cmd.Parameters.Append Recordset_cmd.CreateParameter("param1", 200, 1, 255, Recordset__ID) ' adVarChar

Set Recordset = Recordset_cmd.Execute
Recordset_numRows = 0
%>
<%
set conn = Server.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&_
Server.MapPath ("/database/smit.mdb") & ";"
set rs = conn.execute("SELECT = NULL")
if (RS.BOF and RS.EOF) then
    response.write "No records found"
    response.end
End if
%>

my Recordset fields:



       <td height="30" align="left"><span class="p"><%=(Recordset.Fields.Item("FirstName").Value)%></span></td>
       <td height="30" align="left"><span class="p"><%=(Recordset.Fields.Item("LastName").Value)%></span></td>
       </tr>
      <tr>
       <td height="30" align="left"><span class="p"><%=(Recordset.Fields.Item("cell").Value)%></span></td>
       <td height="30" align="left"><span class="p"><%=(Recordset.Fields.Item("ext").Value)%></span></td>
  1. <%
  2. Dim Recordset__ID
  3. Recordset__ID = "1"
  4. If (Request.Form("")   <> "") Then
  5.  Recordset__ID = Request.Form("")  
  6. End If
  7. %>
  8. <%
  9. Dim Recordset
  10. Dim Recordset_cmd
  11. Dim Recordset_numRows
  12. Set Recordset_cmd = Server.CreateObject ("ADODB.Command")
  13. Recordset_cmd.ActiveConnection = MM_Smit_STRING
  14. Recordset_cmd.CommandText = "SELECT ?, FirstName, LastName, ext, cell FROM tel WHERE FirstName LIKE 'w%'"
  15. Recordset_cmd.Prepared = true
  16. Recordset_cmd.Parameters.Append Recordset_cmd.CreateParameter("param1", 200, 1, 255, Recordset__ID) ' adVarChar
  17. Set Recordset = Recordset_cmd.Execute
  18. Recordset_numRows = 0
  19. %>
  20. <%
  21. set conn = Server.CreateObject("ADODB.Connection")
  22. conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&_
  23. Server.MapPath ("/database/smit.mdb") & ";"
  24. set rs = conn.execute("SELECT = NULL")
  25. if (RS.BOF and RS.EOF) then
  26.     response.write "No records found"
  27.     response.end
  28. End if
  29. %>
  30. my Recordset fields:
  31.        <td height="30" align="left"><span class="p"><%=(Recordset.Fields.Item("FirstName").Value)%></span></td>
  32.        <td height="30" align="left"><span class="p"><%=(Recordset.Fields.Item("LastName").Value)%></span></td>
  33.        </tr>
  34.       <tr>
  35.        <td height="30" align="left"><span class="p"><%=(Recordset.Fields.Item("cell").Value)%></span></td>
  36.        <td height="30" align="left"><span class="p"><%=(Recordset.Fields.Item("ext").Value)%></span></td>
  • ultimate11
  • Student
  • Student
  • ultimate11
  • Posts: 86

Post 3+ Months Ago

i cant get your question but it seems you want to search from input txtbox that user entered and display the result and if you want to search either in firstname and lastname you can add a or "||" condition ... :hmm:
Code: [ Select ]
<%

set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open (Server.MapPath("mydb.mdb"))
set rs=Server.CreateObject("ADODB.recordset")
rs.Open "Select * from mytable where lastname='"&request.form("src")&"'", conn

do until rs.EOF

%>
        <td>    <%    response.write(""&rs("lastname")&"&nbsp;&nbsp;")%>    </td>
        <td>    <%    response.write(""&rs("first_name")&"&nbsp;&nbsp;")%>    </td>
        </tr>
    
<%


    rs.movenext
loop

rs.close
conn.close
%>
  1. <%
  2. set conn=Server.CreateObject("ADODB.Connection")
  3. conn.Provider="Microsoft.Jet.OLEDB.4.0"
  4. conn.Open (Server.MapPath("mydb.mdb"))
  5. set rs=Server.CreateObject("ADODB.recordset")
  6. rs.Open "Select * from mytable where lastname='"&request.form("src")&"'", conn
  7. do until rs.EOF
  8. %>
  9.         <td>    <%    response.write(""&rs("lastname")&"&nbsp;&nbsp;")%>    </td>
  10.         <td>    <%    response.write(""&rs("first_name")&"&nbsp;&nbsp;")%>    </td>
  11.         </tr>
  12.     
  13. <%
  14.     rs.movenext
  15. loop
  16. rs.close
  17. conn.close
  18. %>

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 66 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.