There are a ton of tutorials online for exactly this.. but the basic idea is this:
<ServerAddress> = IP or DNS address to SQL server
<Database> = DB name on the SQL server to connect to
<DBUser> = Username that has access to the DB
<DBPassword> = Password for username
"myTable" = The table you want to quey
"Column1" = The name of the column you want to return
Code:
<!-- #include virtual="inc-adovbs.asp" -->
<%
Dim strDBConn, sSQL
Dim objDataCmd, objconn, objrs
sDBConn="Provider=SQLOLEDB; Data Source=<ServerAddress>; Initial Catalog=<Database>; User Id=<DBUser>; Password=<DBPassword>; Network Library=DBMSSOCN"
set objDataCmd = server.CreateObject("ADODB.Command")
set objconn = server.CreateObject ("ADODB.connection")
set objrs = server.createObject("ADODB.recordset")
objconn.Open sDBConn
objDataCmd.ActiveConnection = objconn
sSQL = "SELECT * FROM myTable"
objDataCmd.CommandText = sSQL
set objrs = objDataCmd.Execute ( , ,adCmdText)
If NOT objrs.BOF AND NO objrs.EOF Then
While NOT objrs.EOF
Response.Write objrs("Column1") & "<BR>"
objrs.MoveNext
WEnd
End If
objconn.Close
set objrs = Nothing
set objconn = Nothing
set objDataCmd = Nothing
%>
You'll need the attached include file.