473,387 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

oledb idiocy

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
Nov 25 '05 #1
1 883
Andrew Bullock wrote:
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

--
Larry Lard
Replies to group please

Nov 25 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Chris Thunell | last post by:
I have a program where i connect to an access database and get some information out of it. I'm using the oledb.3.51 version, my computer doesn't seem to have the 4.0 version, but the computer that...
12
by: Parking Meters | last post by:
Today I managed to get the OleDB provider to let me put datasets from an as400 using sql. Great, the provider string I used is: Provider=IBMDA400.DataSource.1;User ID=XXXXX;Password=XXXX;Data...
4
by: NS | last post by:
Hi, I am trying to execute a prepare statement using oledb provider for DB2. The command.Prepare() statement is giving me an exception " No error information available:...
2
by: Joe | last post by:
Hi All, I am new to using the Access DB and I need some help if someone is able to give it to me. What I want to do is get the names of the columns of certain tables. Not the data in the table...
9
by: Pam Ammond | last post by:
I need the code to update the database when Save is clicked and a text field has changed. This should be very easy since I used Microsoft's wizards for the OleDBAdapter and OleDBConnection, and...
1
by: T8 | last post by:
I have a asp.net (framework 1.1) site interfacing against SQL 2000. It runs like a charm 99% of the time but once in a while I get the following "unspecified error". Sometimes it would resolve by...
3
by: Brian Foree | last post by:
I am developing an ASP.NET application that uses Access 2000 as its backend, and have just started getting the following error on 2 ASP.NET pages that had been working until late last week (and I...
2
by: Martin | last post by:
Hi, I currently have an application that connects to an MS ACCESS database. This application uses an OLEDB connection string for MS ACCESS. Now, I'd like to upsize the application so I converted...
0
by: NicK chlam via DotNetMonster.com | last post by:
this is the error i get System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.Common.DbDataAdapter.Update(DataRow dataRows, DataTableMapping tableMapping) at...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.