Here is a quicky sample of the OleDB class used with an Access mdb
Imports System.Data.OleDb
Imports System.Data
Public Class Form7
Dim conn As OleDbConnection, da As OleDbDataAdapter
Dim ds As DataSet, curMgr As CurrencyManager
Private Sub Form7_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
conn = New OleDbConnection
conn.ConnectionString = "provider=microsoft.jet.oledb.4.0; Data Source =
C:\Code\testAcc\db2test.mdb"
da = New OleDbDataAdapter
ds = New DataSet
da.SelectCommand = New OleDbCommand
da.SelectCommand.Connection = conn
da.SelectCommand.CommandType = CommandType.Text
da.SelectCommand.CommandText = "Select * from Table1"
da.Fill(ds, "tbl1")
curMgr = CType(Me.BindingContext(ds.Tables("tbl1")), CurrencyManager)
curMgr.Position = 0
tssL3.Text = curMgr.Count.ToString
tssL2.Text = (curMgr.Position + 1).ToString
dgrv1.DataSource = ds.Tables(0)
End Sub
Private Sub dgrv1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles dgrv1.Click
'--this will display the number of the record you are on
'--in the Datagridview - same as a table or query in Acc
tssL2.Text = (curMgr.Position + 1).ToString
End Sub
End Class
Note: tssL2 and tssL3 are labels on a statusStrip (my naming
convention). The statusStrip is the control that replaces the StatusBar
- much more horsepower. dgrv1 is a DatagridView control (the equivalent
of a subform, but way more horsepower and flexibility).
You could use the OleDBDataReader or DataAdapter. The OleDBDataReader
doesn't have the Fill method, but if you don't need to fill a table to
view in a DatagridView control, then the Reader is probably more
efficient.
This sample may not look like much, but if you apply it to a large
project, you will end up writing way less code using the OleDB class
than the ODBC class. THe ODBC class is mostly for legacy stuff, like
for DBF tables. Access is an OleDB application, so you should take
advantage of the improvements OleDB offers over ODBC.
Rich
*** Sent via Developersdex
http://www.developersdex.com ***