473,949 Members | 22,282 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6710
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**********@b topenworld.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**********@b topenworld.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**@idcodewar e.co.uk> wrote in message
news:u%******** ********@TK2MSF TNGP10.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**@idcodewar e.co.uk> wrote in message
news:u%******** ********@TK2MSF TNGP10.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
16568
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. But now I've written another SP and the code traps out with the 3251 message. The SP is writing two recordsets. When I run the SP in Query Analyzer, both recordsets appear.
3
2717
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 message. Am I doing this correctly, or at least headed in the right direction? Can someone tell me the most efficient way (provide a code example) to pull 2 different recordsets from the same Data Connection? Set dConn =...
2
2270
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. Each of the recordsets is returning xml data and if called individually would be called as : Dim myCmd as SqlCommand=New SqlCommand("ae_RegGetShow",myCnct) myDataSet.ReadXml(myCmd.ExecuteXmlReader(), XmlReadMode.Fragment)
12
17693
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 that only returns the first record set. I thought I could use ADO but that does not seem to work. I get an Error
16
5747
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 got a nudge in the right direction from Mr. Kreft. I promised to provide details once working, so here it is. The code is shown below. My next step is to build this technique into my application. I'm hoping for substantial performance gain. ...
6
6843
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| .Open query1 3| .Close 4| .Open query2 5| End With
0
2374
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 recordsets. is it possible to do programming in such a way that we can use multiple recordsets with SAME connection? firing SQL statments one after the other and building recordsets. each recordset will contain different no. of records. if yes,...
3
10052
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 system in a store. If all the inputs are NULL, then just the top level categories are output in the first recordset. The ID of each category will then be passed back into the stored procedure where it then filters the second recordset to create the...
0
2864
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 printing printing data and the actual database data in a recordset. the class looks like this: Public Class BRPDD 'Balance Report PrintingDocument Data Public totalReceiptsNum As Integer Public totalLicFee As Double
0
11592
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11188
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10699
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9903
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7435
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6349
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4954
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4545
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3553
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.