Results 1 to 2 of 2

Thread: ASP DataBase Connectivity

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    1

    Angry ASP DataBase Connectivity

    hello!!!
    I am a new comer in ASP and want to connect my DataBase in Access with ASP.Please help me how to do it??
    I am a student of A-levels from Pakistan.

  2. #2
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243

    Thumbs up

    Hi,
    First you need to set up a connection:
    Code:
    'Open connection to Access database using 
    'DSN-less connection
    Dim CN
    Set CN = Server.CreateObject("ADODB.Connection")
    CN.ConnectionString="DRIVER={Microsoft Access Driver (*.mdb)};" & _
    "DBQ=C:\My Documents\YourDatabase.mdb"
    CB.Open
    Once you hace the connection open you can then retrieve recordsets, send SQL statements etc..

    Example recordset:
    Code:
    dim RST
    Set RST = Server.CreateObject("ADODB.Recordset")
    RST.Open "MyFriends",CN,,,adCmdTable
    
    Do While Not RST.EOF
       Response.Write "<B>" & RST("Name") & "</B>"
    Loop
    Don't forget to clear your object's when you have finished with them:
    Code:
    RST.Close
    Set RST=Nothing
    CN.Close
    Set CN = Nothing
    Hope this helps you get started

    Shaun
    Web/Application Developer
    VB6 Ent (SP5), Win 2000,SQL Server 2000

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width