OK, you know how to connect to a database, you need to retrieve data now! so let's start with simple code.
'First we need to make a connection to the database here
Set ConString = Server.CreateObject("ADODB.Connection")
ConString.open 'your connection string goes here
'Then we make the RecordSet
Set ConRS = Server.CreateObject("ADODB.Recordset")
'Ok now it's time to select some records form a table
strSQL = "SELECT * FROM tblProducts"
'Now let's execute this statement
ConRS.open strSQL, ConString
Now let's display the data retrieve, it's simple you just print the Recordset out
While Not ConRS.EOF
Response.write ConRS("ProductName")
ConRS.MoveNext
WendThis code works good, it loops through all records selected and print the ProductName, the loop stops when ConRS.EOF is True, this means the loop stops when the recordset ends
It works just fine that way, but what if there was nothing on that table you selected, with the first way, there will be no record printed out, hence user may think there is something goes wrong with it
to tell user that there was no record founded and ask him to check back, you need to add If...Else...End if statement, it's simple see how you can do it.
If ConRS.EOF then
Response.write "There is no record, please check back."
Else
While Not ConRS.EOF<br>
Response.write ConRS("ProductName")<br>
ConRS.MoveNext<br>
Wend
End If
Can you see it, it is so simple, try yours and play around.