By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,582 Members | 1,720 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,582 IT Pros & Developers. It's quick & easy.

Multiple Recordsets with VB Net

P: n/a
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.
Nov 21 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
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.

"Tull Clancey" <tu**********@btopenworld.com> wrote in message
news:d6**********@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...
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.

Nov 21 '05 #2

P: n/a
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.

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #3

P: n/a

"Tull Clancey" <tu**********@btopenworld.com> wrote in message
news:d6**********@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...
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?

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Nov 21 '05 #4

P: n/a
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.

"Tull Clancey" <tu**@idcodeware.co.uk> wrote in message
news:u%****************@TK2MSFTNGP10.phx.gbl...
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.

*** Sent via Developersdex http://www.developersdex.com ***

Nov 21 '05 #5

P: n/a
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
"Tull Clancey" wrote:
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.

*** Sent via Developersdex http://www.developersdex.com ***

Nov 21 '05 #6

P: n/a
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
Nov 21 '05 #7

P: n/a
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

"Tull Clancey" <tu**@idcodeware.co.uk> wrote in message
news:u%****************@TK2MSFTNGP10.phx.gbl...
| 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.
|
| *** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #8

P: n/a
Many thanks, I think you have set me off in the right direction.

Thanks again.
Cheers,
Tull.

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.