Hi Karl,
This is a piece of cake
--------------------------------------------
Imports System.Data.Ole Db
Imports System.Data
Imports System.IO
Public Class Form1
Dim conn As OleDbConnection , da As OleDbDataAdapte r
Dim ds As DataSet, curMgr As CurrencyManager
Private Sub Form1_Load(...) Handles MyBase.Load
conn = New OleDbConnection
conn.Connection String = "provider=micro soft.jet.oledb. 4.0; Data Source =
C:\someDir\db1t est.mdb"
da = New OleDbDataAdapte r
ds = New DataSet
da.SelectComman d = New OleDbCommand
da.SelectComman d.Connection = conn
da.SelectComman d.CommandType = CommandType.Tex t
da.SelectComman d.CommandText = "Select * from yourTbl"
da.Fill(ds, "tbl1")
curMgr = CType(Me.Bindin gContext(ds.Tab les("tbl1")), CurrencyManager )
curMgr.Position = 0
'--tssL3.Text = curMgr.Count.To String
'--tssL2.Text = (curMgr.Positio n + 1).ToString
dgrv1.DataSourc e = ds.Tables(0)
End Sub
End Class
--------------------------------------------
This is a basic sample for just reading data into a VB2005 app from an
Access mdb. As far as controls go, for this sample, start a new project
which will bring up Form1 by default. In Form1 add a statusStrip control
(from the toolbox) -- this is the replacement for the Statusbar control
-- lots more horsepower. Actually, if you want to simplify the example,
you can forgo the statusstrip and just comment out the lines of code for
tssL3... and tssL2...
But you will need to add a datagridview to the form. I named my
datagridview -- dgrv1. THen just copy and paste the code above. Just
replace the connection string path with a path to your mdb and replace
yourTbl with the name of a table in your Access mdb and then run the
sample. The datagridview will populate immediately with the data from
your Access table.
The CurrencyManager object "curMgr" is how you keep track of where you
are in your dataset. You display the record position in the labels in
the statusstrip. I named my labels tssL2 and tssL3. But just to run
the sample, you don't need the statusstrip.
Writing/editing data from your Access table is also pretty easy, but
I'll let you chew on this for a while first. Note: if the connection
string copies on 2 lines -- drag the 2nd line to the first line to make
it one line because in this sample I did not break the connection string
into 2 lines. And you do not need to add any additional objects like a
Dataset from the toolbox. The only control you need from the toolbox
for this sample is a Datagridview control. Drag one of those onto your
form and strech it out a little bit.
Rich
*** Sent via Developersdex
http://www.developersdex.com ***