We recently updated our
Terms and Conditions for TechRepublic Premium.
By clicking continue, you agree to these updated terms.
Invalid email/username and password combination supplied.
An email has been sent to you with instructions on how to reset your password.
Welcome to TechRepublic!
All fields are required. Username must be unique. Password must be a minimum of 6 characters and have any 3 of the 4 items: a number (0 through 9), a special character (such as !, $, #, %), an uppercase character (A through Z) or a lowercase (a through z) character (no spaces).
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.
Set DataConn = Server.CreateObject (“ADODB.Connection”)
connString = “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:/inetpub/wwwroot/non_credit/courses.mdb”
Where the connString will depend on your system and where the files are stored, etc.
Next, create the recordset.
Set GroupRS = Server.CreateObject (“ADODB.RecordSet”)
GroupRS.ActiveConnection = DataConn
GroupRS.Source = “SELECT * FROM tblgroups”
The Source property of the recordset is the SQL to retieve the data from your database.
Next, the code to populate the list box.
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.
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!