Re: sql connection errors as usage increases
From: Doug Stoltz (NoSpam_at_MyEmail.com)
Date: 08/30/04
- Previous message: John Doe: "Re: visual basic.net standard 2003 (ado.net)"
- In reply to: William \(Bill\) Vaughn: "Re: sql connection errors as usage increases"
- Next in thread: William \(Bill\) Vaughn: "Re: sql connection errors as usage increases"
- Reply: William \(Bill\) Vaughn: "Re: sql connection errors as usage increases"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 30 Aug 2004 16:15:28 -0400
You can verify Bills theory by removing the NEW operator on the DIM
statement and breaking this into 2 statements, like this. Change you code
from this:
Dim xxxx as new xxxx
to this:
Dim xxxx as xxxx
Set xxxx = new xxxx
With your current logic, you don't get an error when you do something like
this:
dim xxxx as new xxxx
...
set xxxx = nothing ' destroys an instance
if xxx.propertyX = 5 then ' VB instantiates new object here
**
"William (Bill) Vaughn" <billvaRemoveThis@nwlink.com> wrote in message
news:u7MgUKiiEHA.2908@TK2MSFTNGP10.phx.gbl...
> I suspect that you have a hole in your logic that permits a connection to
be
> opened but not closed as you suspect.
>
> --
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant
> Microsoft MVP
> www.betav.com
> Please reply only to the newsgroup so that others can benefit.
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> __________________________________
>
> "kkres" <kkres@discussions.microsoft.com> wrote in message
> news:9F344E8F-A6E8-46D1-BEDF-B33A97590C47@microsoft.com...
> >I own an ASP .NET application that uses ADO.NET to manage SQLConnections
to
> >a
> > SQL Srvr 2000 database. Until recently the app has been working fine
> > (with a very small number of users). But in recent weeks number of users
> > has
> > dramatically increased, and now the site is reporting this frequent
error:
> >
> > System.InvalidOperationException: Not allowed to change the
> > 'ConnectionString'
> > property while the connection (state=Open). at
> > System.Data.SqlClient.SqlConnection.set_ConnectionString(Stringvalue)
> > at ... in ...basApplication.vb:line 89
> >
> > It occurs as the user login and the app is creating 2 connections
strings
> > for use during the user's session. The code in question is essentially:
> >
> > Public gobjConn As New
> > SqlClient.SqlConnection(ConfigurationSettings.AppSettings("dsn"))
> > Public gobjConn2 As New
> > SqlClient.SqlConnection(ConfigurationSettings.AppSettings("dsn"))
> > -
> > -
> > gobjConn.Close()
> > gobjConn2.Close()
> > -
> > -
> > gobjConn.ConnectionString = strDataSource & strDataBase & "UID=fred;"
&
> > "PWD=xyz;"
> > gobjConn2.ConnectionString = strDataSource & strDataBase &
"UID=fred;"
> > &
> > "PWD=xyz;" (line 89)
> >
> > gobjConn.Open()
> > gobjConn2.Open()
> >
> > The connection strings are identical (same server and db) and exactly
the
> > same (same login and pw) for all users.
> >
> > I had thought that the Close operations before the Opens would always
> > assure
> > that no connection would ever be left open.
> >
> > This site has been able to live with the problem by regularly restarting
> > IIS.
> >
> > What am I missing?
> >
> > Thanks,
> > --
> > kkres
>
>
- Previous message: John Doe: "Re: visual basic.net standard 2003 (ado.net)"
- In reply to: William \(Bill\) Vaughn: "Re: sql connection errors as usage increases"
- Next in thread: William \(Bill\) Vaughn: "Re: sql connection errors as usage increases"
- Reply: William \(Bill\) Vaughn: "Re: sql connection errors as usage increases"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|