General discussion

  • Creator
    Topic
  • #2130797

    populating web page from Access database

    Locked

    by plantogo2000 ·

    Need the procedure in HTML so that a drop-down list box is populated from an Access database.

All Comments

  • Author
    Replies
    • #3546590

      populating web page from Access database

      by allenhunter ·

      In reply to populating web page from Access database

      I am going to assume that you have no experience with connecting a database to the web. Please forgive me if I state things that you arlready know.

      The following code uses VBScript in an Active Server Page to populate a list box with data from anAccess database.

      First, open the connection to the database.

      Dim connString
      Dim DataConn
      Set DataConn = Server.CreateObject (“ADODB.Connection”)
      connString = “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:/inetpub/wwwroot/non_credit/courses.mdb”
      DataConn.Open connString

      Where the connString will depend on your system and where the files are stored, etc.

      Next, create the recordset.

      Dim GroupRS
      Set GroupRS = Server.CreateObject (“ADODB.RecordSet”)
      GroupRS.ActiveConnection = DataConn
      GroupRS.Source = “SELECT * FROM tblgroups”
      GroupRS.Open

      The Source property of the recordset is the SQL to retieve the data from your database.

      Next, the code to populate the list box.

      Response.write “

      This loops through the recordset and puts the data in the value attribute and the text of each option tag. Don’t forget that when using nested quotes, to alternate between double and single quotes or you might close string to soon. This can cause many errors.

      Finaly close therecordset and data connections.

      GroupRS.Close
      DataConn.Close
      Set DataConn = nothing

      Put the following line at the top of the page…

      <%@ Language=VBScript %>

      enclose all of the VBSript code within the script tags – <% and %>
      thensave the page with an .asp extension and you should be ready to go!

      e-mail me if you have any problems and I’ll see what I can do.
      Allen
      allenhunter@mindspring.com

      • #3548666

        populating web page from Access database

        by allenhunter ·

        In reply to populating web page from Access database

        There are two lines of code listed above that are broken up and need to be on one line for the code to work.

        The first is in the first block of code. The line that starts with “Source=E:…” needs to be on the previous line;
        “…Data Source=E:…”

        The other one is in the third block of code. The line that starts with “(“groupname”)…” needs to be added to the line above it
        “…GroupRS (“groupname”)…”

        Allen

      • #3548567

        populating web page from Access database

        by shanghai sam ·

        In reply to populating web page from Access database

        Poster rated this answer

    • #3548566

      populating web page from Access database

      by plantogo2000 ·

      In reply to populating web page from Access database

      This question was closed by the author

Viewing 1 reply thread