Monday, December 17, 2007

How to use the information to generate a HTML Select control

How to use the information to generate a HTML Select control

S T E P - 1

- We can open a Connection and RecordSet:

<%

Const adOpenKeyset = 1, adLockReadOnly =1

Dim oConn

Dim oRs

Set oConn = Server.CreateObject("ADODB.Connection")

oConn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("db1.mdb")

Set oRs = Server.CreateObject("ADODB.Recordset")

%>

S T E P - 2

- We try to search a male member (Mem Id = 01):

<%

strMemID="01"

strSQL = "SELECT * FROM Member WHERE (MemberID='" & strMemID & "');"

oRs.Open strSQL, oConn, adOpenKeyset, adLockReadOnly

If oRs.RecordCount <> 0 then

strRecMemGender = oRs("Gender")

Else

Response.write("Record Not Found!")

Response.End < color="red" size="+1">'If the record not found, we stop to generate the HTML form

End If

oRs.Close

Set oRs = Nothing

oConn.Close

Set oConn = Nothing

%>

S T E P - 3

- We use the data that get from the database to generate the HTML Select control:

No comments: