Home Tutorials IT Jobs Source Codes Certifications Discussion Forum
  Python Tutorials
Introduction
ASP - Setup
ASP - Running
ASP - First Script
Syntax
ASP - VBScript
ASP - Javascript
ASP - Operators
If Statement
Select
Variable
Array
Session
Cookies
String
Forms
Forms Get
Forms Post
Email Form
ASP Object
ASP Components
ASP Comments
Special Characters
DLL
ADO
ASP File
ASP Date
   IT Jobs
Software Jobs
Networking Jobs
   Model Question Papers
BE Computer Science
MCA
BCA
Others
 
   

ASP ADO

This lesson will provide a brief overview of what ADO is and why it is necessary to have in your ASP programming repertoire. ADO stands for ActiveX Data Objects. ActiveX Data Objects are a collection of components that can be used in your ASP programs.

Accessing the Database

ADO is specifically used as means to communicate and manipulate a database. The types of databases ADO will allow your ASP program to interact include Access, MySQL, and MSSQL to name a few. In this lesson we will be connecting to an Access database, so you will need to have access to Access(hehe) to complete this lesson.

Create Your Access Database

Before you can connect to the Access database you have to first create the Access database file. Fire up your copy of MS Access and create the following database:

  1. Create a New blank database called "codeteller.mdb" (without the quotes) and save it to "C:\Inetpub\wwwroot\codetellerASP\" (without the quotes)
  2. Use the wizard to create the database.
  3. Add two fields to your table: FirstName and LastName
  4. Click Next
  5. Name the table "codetellerTable" (without the quotes)
  6. Select "Yes, set a primary key for me"
  7. Click Next
  8. Click Finish

Now that we have our database all that remains to connect to it.

Using ADO to Connect to an Access Database

Create an ASP file called "codetellerADO.asp" and save it in the same directory as your Access database file.

In the following ASP code we first create an ADO database connection and then we set up the ConnectionString and finally we call the Open method with our Access database filename to finish the opening process.

ASP Code:

<%
Dim myConn
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open = ("DRIVER={Microsoft Access" &_
" Driver (*.mdb)};DBQ=" &_
"C:\Inetpub\wwwroot\codetellerASP\codeteller.mdb;")
myConn.Close()
Set myConn = nothing
%>

<< Previous | Next >>

Home  |  About us  | Privacy  |  Disclaimer  |  Contact us |  Advertise with us | Our Link Partners
All Rights Reserved 2009, CodeTeller.com