Reading a Microsoft Access File

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vikramaditya234
    New Member
    • Nov 2007
    • 4

    Reading a Microsoft Access File

    Hi,
    I have a Access mdb file. I want to read it and gather the data from it. How can I do that? I dont have any IDE and I am using notepad to write the code. I want to use VB Script, if it possible with it, else suggest me.
  • SharpDeveloper
    New Member
    • Feb 2008
    • 12

    #2
    Hello
    You can use VBScript with ASP or only VBScript
    Use following steps

    'Declare Variables
    Dim rs, conn, DatabaseLocatio n

    'Get the location of your Access Database
    DatabaseLocatio n = Server.MapPath( "Employee.m db")

    'Create a ADO Connection Object
    SET conn=Server.Cre ateObject("ADOD B.Connection")

    'Assign the Provider
    conn.Provider=" Microsoft.Jet.O LEDB.4.0"

    'Open the connection
    conn.Open DatabaseLocatio n

    'Open the RecordSet using ADO Recordset Object
    SET rs = Server.CreateOb ject("ADODB.Rec ordset")

    'Query the table in the database
    sql = "Select * from Resources"

    'Open the result set
    rs.Open sql, conn

    c=0
    do while not rs.eof
    c=c+1
    document.write rs("EmployeeNam e")
    rs.movenext
    loop

    Set rs = nothing
    conn.close

    Hope this helps!

    Originally posted by vikramaditya234
    Hi,
    I have a Access mdb file. I want to read it and gather the data from it. How can I do that? I dont have any IDE and I am using notepad to write the code. I want to use VB Script, if it possible with it, else suggest me.

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      This really seems like it falls more under the the regular VB rather then VB.NET since you wish to use VBScript.

      I will move it there.

      MODERATOR

      Comment

      Working...