Computing.Net > Forums > Programming > VBS - retrieving data from Access

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

VBS - retrieving data from Access

Reply to Message Icon

Original Message
Name: sthchris
Date: December 13, 2004 at 21:45:52 Pacific
Subject: VBS - retrieving data from Access
OS: Win2000
CPU/Ram: P42K/256MB
Comment:

Hi all,

Can anybody please tell me how can I retrieve the data/records (using VBS coding) from Access database and get the retrieved-data stored into a defined variable within the VBScript?

Kindly please send me the coding.

Thanks in advance!


Report Offensive Message For Removal


Response Number 1
Name: Chi Happens
Date: December 15, 2004 at 15:10:54 Pacific
Reply: (edit)

you use it just like in vb.

create an adodb.connection and an adodb.recordset, then connect to the db and load what you want:


Dim CN
Dim RS

Set CN = CreateObject("ADODB.Connection")
Set RS = CreateObject("ADODB.RecordSet")

CN.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=[FILENAME]" ' Replace [FILENAME] with your file name (path and all)

RS.CursorLocation = 3
RS.Open "SELECT * FROM [TABLENAME]",CN ' replace [TABLENAME] with the table name

do while RS.EOF = false
[MYVARIABLE] = RS("[FIELDNAME]") ' replace [MYVARIABLE] with your variable and [FIELDNAME] with your field name
RS.MoveNext
Loop
RS.Close

CN.Close

Set CN = nothing
Set RS = nothing


enjoy
Chi

"They mostly come at night...mostly"


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History




Data Recovery Software