Database connection Difficulties

Discussion in 'MS Access' started by MastaKay, Jun 6, 2007.

  1. MastaKay

    MastaKay New Member

    Joined:
    Jun 6, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Hi.

    I have a MS Access database called TelephoneList, that has a table called Characters.Now, I have a webpage with a dropdownlistbox preloaded with characters(A-Z).When I select a character, I want the page to extract values from the page using that character to filter the values.(i.e. Select select name, surname from Character where FilterByChar = Dropdownlist.SelectedItem).

    First.How do I establish a connection, command, and datareader to allow me to do this.

    A sample code would be very nice thank you.

    My current one is****
    Code:
    <%
    set conn=Server.CreateObject("ADODB.Connection")
    conn.Provider="Microsoft.Jet.OLEDB.4.0"
    conn.Open(Server.Mappath("/db/TelephoneList.mdb"))
    set rs = Server.CreateObject("ADODB.recordset")
    sql="SELECT Name, Surname, Department, Xtension, [Other Extension] FROM Characters where Xtension = "****Dont knw how to do the where statement
    rs.Open sql, conn
    %>
    
    <table border="1" width="100%">
    <tr>
    <%for each x in rs.Fields
        response.write("<th>" & x.name & "</th>")
    next%>
    </tr>
    <%do until rs.EOF%>
        <tr>
        <%for each x in rs.Fields%>
           <td><%Response.Write(x.value)%></td>
        <%next
        rs.MoveNext%>
        </tr>
    <%loop
    rs.close
    conn.close
    %>
     
    Last edited by a moderator: Jun 6, 2007

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice