Multiple Recordsets with VB Net

T

Tull Clancey

Hi, hope someone can help.

I'm writing a decent size app as a first project in Net, have been writing
in VB for years.

I've stumbled on a small problem, I can't open two connections to a database
at the same time, even if the connections are in different classes. Am I
doing something compeltely idiotic or is this not as easy at it used to be?

Cheers,
Tull.
 
M

Marina

Why can't you open 2 connections at the same time?

We can't say what you might be doing wrong, if you don't show us your code.

Also, do you really need 2 open connection? You can open the connection, get
the data into a datatable, and close it. And then open it again when you
need more data.
 
T

Tull Clancey

Sorry I haven't posted code, I'm using the basic OLEDB connection and
the DataReader, DataAdapter etc. objects.

When I try to open a second DataReader or Adapter I'm told that a
connection is already made and I can't make another.

Going back to DAO and ADO you could open one database connection and as
many recordsets as required.

The reason is I have to open a couple of tables and write values to
another at the same time, SQL joining just wont do the trick.

Cheers,
Tull.
 
P

Peter van der Goes

Tull Clancey said:
Hi, hope someone can help.

I'm writing a decent size app as a first project in Net, have been writing
in VB for years.

I've stumbled on a small problem, I can't open two connections to a
database at the same time, even if the connections are in different
classes. Am I doing something compeltely idiotic or is this not as easy
at it used to be?

Cheers,
Tull.
Based on your reference to the term "Recordsets" in the subject line, are
you attempting to use ADO with this project, or are you trying to use
ADO.NET? Once we get that settled, can you provide some specifics?
Are you attempting to create the connections at design time, using Server
Explorer or in code? Can you quote the error message received when you
attempt to open the second connection?
 
M

Marina

Is this for access? Then that is probably a limitation of the database
engine.

Like I said, I am assuming by 'record set', you mean an OleDbDataReader, in
which case, you might need to switch to using datatables. That way you can
execute one query, get a result set, and then execute another query, and get
another result set, and look at them both at the same time.
 
G

Guest

Tull,

From this message it sounds like the error is that you can't have more than
1 datareader open on any given open connection. (Not that your app can't have
more than one open connection).

It is the case that only one datareader can be open on a connection at a
time. That's probably also the case with the data adapter.

Kerry Moorman
 
C

Cor Ligthert

Kerry,
It is the case that only one datareader can be open on a connection at a
time. That's probably also the case with the data adapter.

The Dataadapter uses internally the datareader to gets its rows.

Just to inform you that you are rigth,

Cor
 
J

Jay B. Harlow [MVP - Outlook]

Tull,
It sounds like you are using a single OleDbConnection object, and attempting
to use multiple OleDbDataReader objects.

You can only have a single DataReader object in use for each Connection
object.

If you in deed want multiple connections open at the same then, then you
need to create multiple OleDbConnection objects.

Hope this helps
Jay

| Sorry I haven't posted code, I'm using the basic OLEDB connection and
| the DataReader, DataAdapter etc. objects.
|
| When I try to open a second DataReader or Adapter I'm told that a
| connection is already made and I can't make another.
|
| Going back to DAO and ADO you could open one database connection and as
| many recordsets as required.
|
| The reason is I have to open a couple of tables and write values to
| another at the same time, SQL joining just wont do the trick.
|
| Cheers,
| Tull.
|
|
 
T

Tull Clancey

Many thanks, I think you have set me off in the right direction.

Thanks again.
Cheers,
Tull.
 

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


Top