I have few forms that I am trying just to display the data.

In each form I need to fire different sqlstatements to get the data. Before
executing each sql statement I am opening the connection, executing
sqlreader, closing sqlreader and closing the connection. Sometimes I get
errors like SQL connection is already open or sqlcon is busy fetching etc.

What is the better approach for me to accomplish this.

Thanks

RE: SQLConnection by Rich

Rich
Sat Nov 13 12:01:02 CST 2004

You might try using the same connection for all the readers - keep the
connection open. Don't close it until all the data retrieval is done.

Make sure the readers run one right after the other...get what data you need
- and then close them right away.

Assuming that you don't have to wait for anything between queries - such as
user events - this should not only work well but make good use of resources,
as well.

HTH



"vb" wrote:

> I have few forms that I am trying just to display the data.
>
> In each form I need to fire different sqlstatements to get the data. Before
> executing each sql statement I am opening the connection, executing
> sqlreader, closing sqlreader and closing the connection. Sometimes I get
> errors like SQL connection is already open or sqlcon is busy fetching etc.
>
> What is the better approach for me to accomplish this.
>
> Thanks
>
>
>
>
>
>
>
>
>
>
>

Re: SQLConnection by Miha

Miha
Sat Nov 13 16:12:48 CST 2004

Hi,

It seems that you are somewhat leaking your connections.
Are you sure that you are closing them?
Do you use threading?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com

"vb" <vb@discussions.microsoft.com> wrote in message
news:A370DFB7-48A6-44C8-82EC-7FE41D907FB7@microsoft.com...
>I have few forms that I am trying just to display the data.
>
> In each form I need to fire different sqlstatements to get the data.
> Before
> executing each sql statement I am opening the connection, executing
> sqlreader, closing sqlreader and closing the connection. Sometimes I get
> errors like SQL connection is already open or sqlcon is busy fetching etc.
>
> What is the better approach for me to accomplish this.
>
> Thanks
>
>
>
>
>
>
>
>
>
>
>



Re: SQLConnection by Angel

Angel
Thu Nov 18 19:16:19 CST 2004

make sure that you are creating a new connection in each form, specifically
I would recomend the "using" statement to avoid leaks.
Using the same connection in multiple threads is not supported.

--
Angel Saenz-Badillos [MS] Managed Providers
This posting is provided "AS IS", with no warranties, and confers no
rights.Please do not send email directly to this alias.
This alias is for newsgroup purposes only.
I am now blogging about ADO.NET: http://weblogs.asp.net/angelsb/




"vb" <vb@discussions.microsoft.com> wrote in message
news:A370DFB7-48A6-44C8-82EC-7FE41D907FB7@microsoft.com...
> I have few forms that I am trying just to display the data.
>
> In each form I need to fire different sqlstatements to get the data.
Before
> executing each sql statement I am opening the connection, executing
> sqlreader, closing sqlreader and closing the connection. Sometimes I get
> errors like SQL connection is already open or sqlcon is busy fetching etc.
>
> What is the better approach for me to accomplish this.
>
> Thanks
>
>
>
>
>
>
>
>
>
>
>