Jump to content

How to find record from MS Access using ASP


tamakuwalapranav

Recommended Posts

Hello, I am trying to find data from my database. In my database, I have made up auto generate ID which will increment whenever data will insert from XHTML form. But now what I want to do is that if any use write ID in search field , that data should come up on the screen and user can modify it and save again to database.I have written a query as well but nothing working properly. If any one know any website or having these kind of code , please upload it asap..

Link to comment
Share on other sites

Hello, I am trying to find data from my database. In my database, I have made up auto generate ID which will increment whenever data will insert from XHTML form. But now what I want to do is that if any use write ID in search field , that data should come up on the screen and user can modify it and save again to database.I have written a query as well but nothing working properly. If any one know any website or having these kind of code , please upload it asap..

I'm not exactly sure what you're asking, but it sounds like this:You have a form for users to search your database. If a user types "bunny", it will search all records containing the word bunny; if a user types "id=5", it will bring up the appropriate article so the user can modify it.Most likely, you're going to use something like this: search.asp
<% Option Explicit %><html><body><form action="search.asp" method="post">    <input type="text" name="search"><br>    <input type="submit" value="Search"></form><%Dim Search, Conn, RS, SQLDim Regex, Match, MatchesSearch = cstr(Request("search"))if Search <> "" then   'Just going to perform a quick regex to see if the user typed "ID=" in the   'search field.   Set Regex = New Regexp   Regex.Pattern = "^ID=(\d+)$"   Regex.IgnoreCase = True   Regex.Global = True   Regex.Multiline = True    If Regex.Test(Search) then        Set Matches = Regex.Execute(Search)        For Each Match in Matches            SQL = "Select * From your_table WHERE ID = " & Match.SubMatches(0)        Next    else        SQL = "Select * From your_table WHERE SearchField Like '%" & Search & "%'"    End if    Set Conn = Server.CreateObject("ADODB.Connection")    Set RS = Server.CreateObject("ADODB.RecordSet")    Conn.Open your_connection_string    RS.Open SQL, Conn, 1, 1        'display form data, and be sure to include a hidden field with the RS("ID")        'so you can edit the form record.    RS.Close    Conn.Close    Set Conn = nothing    Set RS = nothingEnd if%></body></html>

Link to comment
Share on other sites

Hi,I am really sorry abt my comments. Actually, I am looking for same thing which is provided by you and i am trying to implement it in my project hopefully i can intrgrate it with my code. I am really thankful for your help. I am having other problem with login page. Actual secnario is describe below:I am creating student website. I am done with everything such as student enrolment form and registration but now my client requirement is that if any student visting my website and if he/she wants to apply for any course , they need to register for that so that next time they come to our site , they need to enter their username and password to fatch their all details.I tried to generate my login page but what happening is that it is showing first record , whether I enter last record or first .. I think this problem occur due to imappropriate loop. If you have any idea or any coding related to this , pls send me according to your time but try to send me asap..Again thanks for your help and support.

I'm not exactly sure what you're asking, but it sounds like this:You have a form for users to search your database. If a user types "bunny", it will search all records containing the word bunny; if a user types "id=5", it will bring up the appropriate article so the user can modify it.Most likely, you're going to use something like this: search.asp
<% Option Explicit %><html><body><form action="search.asp" method="post">    <input type="text" name="search"><br>    <input type="submit" value="Search"></form><%Dim Search, Conn, RS, SQLDim Regex, Match, MatchesSearch = cstr(Request("search"))if Search <> "" then   'Just going to perform a quick regex to see if the user typed "ID=" in the   'search field.   Set Regex = New Regexp   Regex.Pattern = "^ID=(\d+)$"   Regex.IgnoreCase = True   Regex.Global = True   Regex.Multiline = True    If Regex.Test(Search) then        Set Matches = Regex.Execute(Search)        For Each Match in Matches            SQL = "Select * From your_table WHERE ID = " & Match.SubMatches(0)        Next    else        SQL = "Select * From your_table WHERE SearchField Like '%" & Search & "%'"    End if    Set Conn = Server.CreateObject("ADODB.Connection")    Set RS = Server.CreateObject("ADODB.RecordSet")    Conn.Open your_connection_string    RS.Open SQL, Conn, 1, 1        'display form data, and be sure to include a hidden field with the RS("ID")        'so you can edit the form record.    RS.Close    Conn.Close    Set Conn = nothing    Set RS = nothingEnd if%></body></html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...