basic MS Access Question.. get a data into a dataset


A

Aussie Rules

Hi,

Just learning how to use VB.net and Access databases. I am use to working
against a SQL server.

I have a Oledb connection to an access database. I have created a query in
the access database that I want to create a dataset in my vb app using the
query data.

I am able to get the query results into a reader, but I need it in a
dataset, as a thirdpart grid i am using requires a dataset (as it has a
iBindinglist)

my code for the datareader is :

dim dbConnection As New OleDbConnection
dbConnection.ConnectionString = ("Provider=Microsoft.ACE.OLEDB.12.0;Data
Sou... ETC..)
dbConnection.Open()
dim command As New OleDbCommand("select * from projectcosts", dbConnection)

dim reader As OleDbDataReader = command.ExecuteReader()


what do i have to do to get my result into a dataset ?

Thanks
 
Ad

Advertisements

J

Jack Jackson

Hi,

Just learning how to use VB.net and Access databases. I am use to working
against a SQL server.

I have a Oledb connection to an access database. I have created a query in
the access database that I want to create a dataset in my vb app using the
query data.

I am able to get the query results into a reader, but I need it in a
dataset, as a thirdpart grid i am using requires a dataset (as it has a
iBindinglist)

my code for the datareader is :

dim dbConnection As New OleDbConnection
dbConnection.ConnectionString = ("Provider=Microsoft.ACE.OLEDB.12.0;Data
Sou... ETC..)
dbConnection.Open()
dim command As New OleDbCommand("select * from projectcosts", dbConnection)

dim reader As OleDbDataReader = command.ExecuteReader()


what do i have to do to get my result into a dataset ?

Look at DataSet.Load()
 
S

Steve Gerrard

Aussie said:
Hi,

Just learning how to use VB.net and Access databases. I am use to
working against a SQL server.

I have a Oledb connection to an access database. I have created a
query in the access database that I want to create a dataset in my vb
app using the query data.

dim dbConnection As New OleDbConnection
dbConnection.ConnectionString =
("Provider=Microsoft.ACE.OLEDB.12.0;Data Sou... ETC..)
dbConnection.Open()
dim command As New OleDbCommand("select * from projectcosts",
dbConnection)

I would ditch the reader, and use an adapter, something like this:

Dim ds As New DataSet
Dim da As New OleDbDataAdapter(command)
da.Fill(ds)
 
Ad

Advertisements

G

Guest

Hi,

Just learning how to use VB.net and Access databases. I am use to
working against a SQL server.

You can use SQL Server Compact Edition or SQL Server Express, both are
free SQL Server products from Microsoft :)

what do i have to do to get my result into a dataset ?

To create a dataset you need to:

1. Open a Connection
2. Create a Command Object
3. Create a empty Dataset
4. Create a table adapter
5. Assign the command object to the table adapater
6. Fill the dataset with the table adapter

It's a lot of steps, but do it a couple times and it's not so bad.

Here is an example:

http://msdn2.microsoft.com/en-us/library/bh8kx08z(VS.71).aspx
 

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

Top