473,407 Members | 2,326 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,407 software developers and data experts.

Multiple Recordsets with VB Net

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
8 6678
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
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

"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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: (Pete Cresswell) | last post by:
I posted this in the MS Access group, but no luck. ------------------------------------------ I've got another stored procedure in the same app that returns multiple recordsets and the code works....
3
by: sans_spam | last post by:
I want to pull 2 different recordsets using 2 different stored procedures using the same Data Connection. Below is the code that I currently have, but I'm getting an 'Object Required' error...
2
by: Keith Chadwick | last post by:
I prefer to use stored procedures over having sql statements sitting in my ..NET code. My problem is I can not figure out how get .NET to understand there are multiple recordsets coming back. ...
12
by: Scott | last post by:
Front-end Access 2000 I have a stored procedure that has 2 parameters BusinessUnitID and Year. It returns multiple record sets (5 to be exact). I thought I could use a Pass through query but...
16
by: Randy Harris | last post by:
I was inspired by the recent discussion of returning multiple recordsets to ADO from a stored procedure. (Amazed is probably more accurate). I asked about how to accomplish same with Oracle and...
6
by: blue875 | last post by:
Hello helper people who are smarter than me: I have a form that needs to submit multiple queries to different tables during one Sub's execution. Some sections are as simple as: 1| With rst 2|...
0
by: nachiket2k2 | last post by:
Hi, I am using VB 6.0, ADO 2.0 with MS Access 2000 Database. in a vb form, i need to fatch data from 3 different tables (ABC.MDB). it will be a tedious job if i create 3 connections with 3...
3
by: Dooza | last post by:
Hi there, I have a Stored Procedure in SQL 2000 that takes 10 input paremeters, and outputs 11 recordsets, not rows, but 11 different SELECT statements. The purpose of this is to for a menu...
0
it0ny
by: it0ny | last post by:
Hi guys, thanks I am fairly new to this forum so I hope I chose the right place to post this question. I try to make my program printout a deposit's report. I created a class to store the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.