Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Tips Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS Access
SQL Scripts & Samples
» Database Forum
» Slideshows
» Sitemap
Free Newsletters:

By submitting your information, you agree that databasejournal.com may send you databasejournal offers via email, phone and text message, as well as email offers about other products and services that databasejournal believes may be of interest to you. databasejournal will process your information in accordance with the Quinstreet Privacy Policy.

News Via RSS Feed

Database Journal |DBA Support |SQLCourse |SQLCourse2

Featured Database Articles


Posted Dec 11, 2000

Another VB-ADO Tool to View Data from a SQL Database - Page 2

By Danny Lesandrini

Another VB-ADO SQL Tool to View Data from a SQL Database

Back to Article

Sample ASP Code Using ADO to Get Pubs Data


Dim sSQL
Dim dbPubs
Dim rsPubs

' Create an ADO database connection
Set dbPubs = server.createobject("adodb.connection")

' Create a record set
Set rsPubs = server.CreateObject("adodb.recordset")

' ////////////////////////////////////////////////////////////////
' This is the connection string section
' It must be edited to reflect your login params:
' Data Source=Server
' Initial Catalog=Database
' User ID=UID
' Password=PWD

' Open the connection using our ODBC file DSN

sConn = "Provider=SQLOLEDB.1;Initial Catalog=Pubs;"
sConn = sConn & "Data Source=dan;User ID=sa;Password=;"
' ////////////////////////////////////////////////////////////////

sSQL = sSQL & "SELECT au_fName + ' ' + au_lName AS FullName , "
sSQL = sSQL & " Titles.Title AS Publication "
sSQL = sSQL & "FROM Authors "
sSQL = sSQL & "INNER JOIN TitleAuthor "
sSQL = sSQL & "ON Authors.au_id = TitleAuthor.au_id "
sSQL = sSQL & "INNER JOIN Titles "
sSQL = sSQL & "ON Titles.title_id = TitleAuthor.title_id "
sSQL = sSQL & "WHERE Authors.State='CA' "

' Execute the sSQL statement
Set rsPubs = dbPubs.Execute(sSQL)

' Now, create the ASP Table

<BODY bgColor=lightyellow>

<TABLE width="100%" border=1 align=center>
<TH width="25%">Full Name</TH>
<TH width="75%">Title</TH>

' Loop through recordset, inserting rows intp ASP table
Do Until rsPubs.EOF
Response.Write("<TD>" & rsPubs("FullName") & "</TD>")
Response.Write("<TD>" & rsPubs("Publication") & "</TD>")


Set rsPubs = Nothing

Set dbPubs = Nothing

Back to Article

See All Articles by Columnist Danny Lesandrini

MS SQL Archives

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
SQL 2005: SSIS: Error using SQL Server credentials poverty 3 August 17th, 07:43 AM
Need help changing table contents nkawtg 1 August 17th, 03:02 AM
SQL Server Memory confifuration bhosalenarayan 2 August 14th, 05:33 AM
SQL Server Primary Key and a Unique Key katty.jonh 2 July 25th, 10:36 AM