Database Code
  Home arrow Database Code arrow Using ADO to Communicate with the Database...
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DATABASE CODE

Using ADO to Communicate with the Database, Part 1
By: Pradeep Chaudhary
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 34
    2004-11-02

    Table of Contents:
  • Using ADO to Communicate with the Database, Part 1
  • What is a Recordset?
  • What Are the Lock Types?
  • Bringing All Together
  • Implementing the Code

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Using ADO to Communicate with the Database, Part 1
    (Page 1 of 5 )

    ADO provides developers with a powerful, logical object model for programmatically accessing, editing, and updating data from a wide variety of data sources. Its primary benefits are ease of use, high speed, low memory overhead, and a small disk footprint.

    How to start the Communication with the Database?

    To use the objects you must make a reference to them in your project. Go to Project/References and check the highest version of Microsoft ActiveX Data Objects. This could be 2.0 or 2.6.To start the communication with the database, there must be some procedure, which we need to follow. To start with, we need to declare a Connection Object.

    What is a Connection?

    A Connection object represents a physical connection to a database. When you open the Connection object, you attempt to connect to the database. The State property of the Connection object tells you whether you succeeded or failed. You can send SQL statements or run stored procedures by using the Execute method of the Connection object. If the command you send to the data store returns records, a Recordset object will be created automatically.

    Referencing the Connection

    Before you proceed, you need to refer the ADO (Microsoft Activex Data Object ver X.XX) in your project. To add the reference you need to go to the Project Menu and then select the Microsoft Activex Data Object X.XX.

    Declaring a Connection

    Before establishing a session with the database, you need to declare the Connection. Connection can be declared like any of the method below:

    Dim objConn As ADODB.Connection
    Set objConn = New ADODB.Connection

    Or

    Dim objConn As New ADODB.Connection
    Opening a Connection

    To open a Connection, we must make a connection string (Specifying Provider, Path of the database, User ID and Password etc) with the Database. At a minimum, you'll require to specify a Provider/connection string which indicates the type of the database, and a Data Source String, which is simply the path and file name of your database. To separate an Individual setting=value combinations of the connection string are separated with semi-colons.

    Dim sConnect As String ‘ Declarign the Connection
    sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=c:databasemyaccessfile.mdb"
    objConn.Open sConnect ‘ Opening the Connection

    Provider for MS-Access 2000 Database file is 'Microsoft.Jet.OLEDB.4.0 Provider for MS-Access 97 Database its 'Microsoft.Jet.OLEDB.3.51.

    Once our connection is established, we can read the records (Rows) of the table by using the ADODB Recordset object.

    More Database Code Articles
    More By Pradeep Chaudhary


       · Seems like you would at least cover ADO.NET rather than covering 3+ year outdated...
       · contrary to what Microsoft says, there are thousands of ASP coders out there that...
       · but there are already a massive number of ADO tutorials on the web - why continue to...
       · Nice concise information with examples to help a DAO developer move to ADO. Thank...
       · anything i can learn is great, thanks for taking the time to post up the knowlegde!...
     

    DATABASE CODE ARTICLES

    - Deployment of the MobiLink Synchronization M...
    - MobiLink Synchronization Wizard in SQL Anywh...
    - Finding Matching Records in Data Access Pages
    - Using the AccessDataSource Control in VS 2005
    - A Closer Look at ADO.NET: The Command Object
    - A Closer Look at ADO.NET: The Connection Obj...
    - Using ADO to Communicate with the Database, ...
    - Code Snippets: Counting Records
    - Constraints In Microsoft SQL Server 2000
    - Multilingual entries into a DB and to be dis...
    - Getting A List of Tables From SQL Server
    - SQL Server Database Creator - .NET Version
    - ADO Recordset Paging
    - Two combos, one textbox example
    - Discussion & Listserv Module by Mike Eck...




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway