473,394 Members | 1,770 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,394 software developers and data experts.

can I read from a dr, then populate a ds w/ 1 con?

A user provides an organization name, username & password. I've got Access
as the back end so no triggers, functions etc. This is what I do:

1. open a connection
2. use the datareader to query the orgID [user provides an org name ].
3. Then do an ExecuteNonQuery, with that orgID in the where clause.
4. close the connection.

Unfort. .NET gives me an error when I try to do my executeNonQuery because
it says the datareader connection needs to be closed first. What I'm
wondering is why I can't be more efficient and do this with 1 single
connection to the database. Why do i have to split it up.

Thanks
Jason Shohet
Nov 17 '05 #1
3 1109
All you probably need to do is close the DataReader before trying to use it
again.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big things are made up of
Lots of Little Things.

" Jason Shohet" <as****@hotmail.com> wrote in message
news:Op**************@TK2MSFTNGP11.phx.gbl...
A user provides an organization name, username & password. I've got Access as the back end so no triggers, functions etc. This is what I do:

1. open a connection
2. use the datareader to query the orgID [user provides an org name ].
3. Then do an ExecuteNonQuery, with that orgID in the where clause.
4. close the connection.

Unfort. .NET gives me an error when I try to do my executeNonQuery because
it says the datareader connection needs to be closed first. What I'm
wondering is why I can't be more efficient and do this with 1 single
connection to the database. Why do i have to split it up.

Thanks
Jason Shohet

Nov 17 '05 #2
Kevin is right.
Additionally, it's more efficient than you think. ADO.NET has built in
connection pooling, so when you close a connection it usually doesn't
actually get closed. It goes back to the pool and waits for you to open
another connection. Then instead of going through all the work of opening a
connection it just grabs your previously opened connection from the pool and
uses it.

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

" Jason Shohet" <as****@hotmail.com> wrote in message
news:Op**************@TK2MSFTNGP11.phx.gbl...
A user provides an organization name, username & password. I've got Access as the back end so no triggers, functions etc. This is what I do:

1. open a connection
2. use the datareader to query the orgID [user provides an org name ].
3. Then do an ExecuteNonQuery, with that orgID in the where clause.
4. close the connection.

Unfort. .NET gives me an error when I try to do my executeNonQuery because
it says the datareader connection needs to be closed first. What I'm
wondering is why I can't be more efficient and do this with 1 single
connection to the database. Why do i have to split it up.

Thanks
Jason Shohet

Nov 17 '05 #3
you can use a stored procedure call to do both the things for you.
Just pass it the organisation name and let it do the rest with just one
connection, one trip.

" Jason Shohet" <as****@hotmail.com> wrote in message
news:Op**************@TK2MSFTNGP11.phx.gbl...
A user provides an organization name, username & password. I've got Access as the back end so no triggers, functions etc. This is what I do:

1. open a connection
2. use the datareader to query the orgID [user provides an org name ].
3. Then do an ExecuteNonQuery, with that orgID in the where clause.
4. close the connection.

Unfort. .NET gives me an error when I try to do my executeNonQuery because
it says the datareader connection needs to be closed first. What I'm
wondering is why I can't be more efficient and do this with 1 single
connection to the database. Why do i have to split it up.

Thanks
Jason Shohet

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: C. David Rossen | last post by:
Hello: I have a registration form for classes. Each class has a fee. I have a drop down box whereby the user chooses his class. There is a textbox with the associated fee. I would like to...
1
by: Vikrant | last post by:
Hey Friends I need to read records from a table and populate a list box with the same. Can Someone Plz Help me.
14
by: Laszlo Szijarto | last post by:
Can BinaryReader be forced to read a stream, say a TCP/IP stream or memory stream or even file stream in big endian order or do I have to write something custom to reverse the byte order? So, for...
6
by: BBM | last post by:
I have an object that has a fairly complex construction sequence, so I have written a dedicated "factory" class that invokes the constructor of my object class (which does nothing but instantiate...
3
by: Yul | last post by:
Hi, We are in the process of designing an ASP.NET app, where a user will enter some 'Customer ID' to be queried in the database. If the ID is valid, several stored procedures will be called to...
0
by: SteveS | last post by:
I'm not sure if this is the right forum, but here it goes :-) This has been bothering me for a long time, and I'm curious about everyone's opinion or a "Microsoft Best Practices" method of doing...
2
by: sweyer via AccessMonster.com | last post by:
Okay, so this is my situation. I have a database that stores clients and their corresponding groups. (We're an insurance brokerage, so we have each company's information and each of their clients'...
2
by: rperreta | last post by:
I exported a xml file using .writexml from a dataset and now I would like to populate a combo box from that. Can someone supply a link or sample vb.net code that show's how to do this... much...
3
by: =?Utf-8?B?dHZpbg==?= | last post by:
Hi All, I'm working with an application that read CSV File and populate data into Datatable. but unfortunatly CSV file change to .BRF file, they are completly different. So is someone...
0
by: Padma Athimoolam | last post by:
Hi, I am new to VB and XML.I want to populate XML Values in Excel Sheet.My Sample XML is <?xml version="1.0" encoding="UTF-8" ?> - <workbook> - <worksheet name="Scorecard_KTC_MW"> <cell...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.