oledb idiocy

  • Thread starter Thread starter Andrew Bullock
  • Start date Start date
A

Andrew Bullock

Hi,


I'm really struggling to find out how to perform a simple sql query on
my jet4 database, and get the results returned into something i can
easilly iterate over.

Every example i find tells me to use a datagrid, and i dont want to!!!!

In vb 6 it was easy peasy:

Dim sqlGeneric as Recordset
Set sqlGeneric = New Recordset
sqlGeneric.CursorType = adOpenStatic
sqlGeneric.LockType = adLockOptimistic
sqlGeneric.Open strSQL, "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
& strDBPath & ";Persist Security Info=False"

I could then easilly use .fields(x) and .movenext to loop trough my results!

How do i do this in VB .net 2 2005?




Thanks


Andrew
 
Andrew said:
Hi,


I'm really struggling to find out how to perform a simple sql query on
my jet4 database, and get the results returned into something i can
easilly iterate over.

Every example i find tells me to use a datagrid, and i dont want to!!!!

In vb 6 it was easy peasy:

Dim sqlGeneric as Recordset
Set sqlGeneric = New Recordset
sqlGeneric.CursorType = adOpenStatic
sqlGeneric.LockType = adLockOptimistic
sqlGeneric.Open strSQL, "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
& strDBPath & ";Persist Security Info=False"

I could then easilly use .fields(x) and .movenext to loop trough my results!

How do i do this in VB .net 2 2005?

Dim sDBPath As String = "C:\whatever.mdb"
Dim dc As New OleDbConnection _
("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
sDBPath & ";Persist Security Info=False")
Dim dcmd As New OleDbCommand("SELECT * FROM MyTable", dc)
Dim dr As OleDbDataReader = dcmd.ExecuteReader

Do While dr.Read
'now access dr.GetValue(0...)
'or dr.GetInt<Type>(0...)
'or whatever
Loop

dr.Close() 'do not forget this
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top