Instructions:
1. declare it like this
dim myDB as new DBor this
dim myDB as new DB(DbType.SQL)
2. specify db type
myDB.type = DBType.SQLother types are DBType.ACCESS
if you dont specify a type, it uses a default which is SQL
3. specify details
dim myDB as new DB
myDB.Type = DBType.ACCESS07
myDB.Path = "db.accdb"
for 2003 access
dim myDB as new DB
myDB.Type = DBType.ACCESS
myDB.Path = "db.mdb"
for ms access (note that it chooses 2k7 or 2k3 based on extension)
dim myDB as new DB myDB.Type = DBType.ACCESS myDB.Path = "db.mdb" 'or myDB.Path = "db.accdb"
for ms sql
dim myDB as new DB myDB.Type = DBType.SQL myDB.name = "db"
4. reading data
With myDB
If (.Connect And .Open) Then
Dim alRows As New ArrayList, alColumns As New ArrayList
alRows = .Read("atable")
dim iRowIndex as integer, iColIndex as integer
for iRowIndex= 0 to alRows.count - 1
'access your rows
for iColIndex = 0 to alRows(iRowIndex).count -1
'access your columns
next
next
note, you might want to use your own select statement:
myDB.Command="select *" myDB.Read
5. Write data
you have to use your own sql statements
myDB.command = "insert into ......" dim rowsaffected=myDB.Write
or
dim rowsaffected=myDB.Write("insert into ...")
6. close
myDB.close
if anyone can add xls & xlsx support
also, i have not tested the username password usage
This post has been edited by olibenu: 09 October 2009 - 09:52 AM





MultiQuote





|