PC Review


Reply
Thread Tools Rate Thread

How to dertiminate how many connecitons

 
 
ad
Guest
Posts: n/a
 
      20th Nov 2005
I am use VS2005 Profession and SqlExpress 2005 to develop WebApplication.
I use many SqlDataReader in my application.
I think there are some connecitons not be closed after reading data.

How can I moniter the status of conneciton of a Database?


 
Reply With Quote
 
 
 
 
William \(Bill\) Vaughn
Guest
Posts: n/a
 
      21st Nov 2005
1) Use the SQL Profiler to monitor connections
2) With the 1.1 framework (try to) use the .NET data performance counters.
These can show how many connections are pooled but they don't work very
well.
3) With the 2.0 framework there are new performance counters (that work)
4) With any version of SS you can monitor the number of user connections
using its own performance counters.

I'll be discussing these (and showing the code) in my session at VSLive in
Sydney.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
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.
__________________________________

"ad" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I am use VS2005 Profession and SqlExpress 2005 to develop WebApplication.
> I use many SqlDataReader in my application.
> I think there are some connecitons not be closed after reading data.
>
> How can I moniter the status of conneciton of a Database?
>



 
Reply With Quote
 
Robbe Morris [C# MVP]
Guest
Posts: n/a
 
      21st Nov 2005
http://www.eggheadcafe.com/forums/Fo...=46053&INTID=9

--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.masterado.net





"William (Bill) Vaughn" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 1) Use the SQL Profiler to monitor connections
> 2) With the 1.1 framework (try to) use the .NET data performance counters.
> These can show how many connections are pooled but they don't work very
> well.
> 3) With the 2.0 framework there are new performance counters (that work)
> 4) With any version of SS you can monitor the number of user connections
> using its own performance counters.
>
> I'll be discussing these (and showing the code) in my session at VSLive in
> Sydney.
>
> --
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant
> Microsoft MVP
> INETA Speaker
> www.betav.com/blog/billva
> 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.
> __________________________________
>
> "ad" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I am use VS2005 Profession and SqlExpress 2005 to develop WebApplication.
>> I use many SqlDataReader in my application.
>> I think there are some connecitons not be closed after reading data.
>>
>> How can I moniter the status of conneciton of a Database?
>>

>
>



 
Reply With Quote
 
Robbe Morris [C# MVP]
Guest
Posts: n/a
 
      21st Nov 2005
I'm not recommending that you do this to
close connections in production. That
sample could be useful in helping you
figure out if you really do have a
problem with connections not
be closed or not.

--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.masterado.net





"William (Bill) Vaughn" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 1) Use the SQL Profiler to monitor connections
> 2) With the 1.1 framework (try to) use the .NET data performance counters.
> These can show how many connections are pooled but they don't work very
> well.
> 3) With the 2.0 framework there are new performance counters (that work)
> 4) With any version of SS you can monitor the number of user connections
> using its own performance counters.
>
> I'll be discussing these (and showing the code) in my session at VSLive in
> Sydney.
>
> --
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant
> Microsoft MVP
> INETA Speaker
> www.betav.com/blog/billva
> 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.
> __________________________________
>
> "ad" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I am use VS2005 Profession and SqlExpress 2005 to develop WebApplication.
>> I use many SqlDataReader in my application.
>> I think there are some connecitons not be closed after reading data.
>>
>> How can I moniter the status of conneciton of a Database?
>>

>
>



 
Reply With Quote
 
ad
Guest
Posts: n/a
 
      21st Nov 2005
I have tried the codes (below) in the link:

But what doesGetDataTableFromSql function come from?

What about ths SQL:
select spid from master..sysprocesses

The code can't compile.

I am using VS2005 and Sql2005 Express.

//--------------------------------------------------------------------------------------------------------------------
public static void KillProcesses(string DBConStr, string DBName)
{
try
{
using (SqlConnection conn = new SqlConnection(DBConStr))
{
conn.Open();
string sSql = "select spid from master..sysprocesses
where dbid=db_id('" + DBName + "')";
DataTable oTable = GetDataTableFromSql(sSql, DBConStr,
60);
foreach(DataRow oRow in oTable.Rows)
{
int Id = int.Parse(oRow[0].ToString());
SqlCommand cmd = new SqlCommand("kill " + Id, conn);
cmd.ExecuteNonQuery();
}
conn.Close();

}
}
catch{}
}






"Robbe Morris [C# MVP]" <(E-Mail Removed)> 撰寫於郵件新聞:(E-Mail Removed)...
> http://www.eggheadcafe.com/forums/Fo...=46053&INTID=9
>
> --
> Robbe Morris - 2004/2005 Microsoft MVP C#
> http://www.masterado.net
>
>
>
>
>
> "William (Bill) Vaughn" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 1) Use the SQL Profiler to monitor connections
>> 2) With the 1.1 framework (try to) use the .NET data performance
>> counters. These can show how many connections are pooled but they don't
>> work very well.
>> 3) With the 2.0 framework there are new performance counters (that work)
>> 4) With any version of SS you can monitor the number of user connections
>> using its own performance counters.
>>
>> I'll be discussing these (and showing the code) in my session at VSLive
>> in Sydney.
>>
>> --
>> ____________________________________
>> William (Bill) Vaughn
>> Author, Mentor, Consultant
>> Microsoft MVP
>> INETA Speaker
>> www.betav.com/blog/billva
>> 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.
>> __________________________________
>>
>> "ad" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>>I am use VS2005 Profession and SqlExpress 2005 to develop WebApplication.
>>> I use many SqlDataReader in my application.
>>> I think there are some connecitons not be closed after reading data.
>>>
>>> How can I moniter the status of conneciton of a Database?
>>>

>>
>>

>
>



 
Reply With Quote
 
Robbe Morris [C# MVP]
Guest
Posts: n/a
 
      21st Nov 2005
That is an old function of ours that just uses a sqldataadapter
to fill a DataTable. The key for you is to look at the
two different sql statements in strings and adapt it
to what you need to do.

--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.masterado.net





"ad" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have tried the codes (below) in the link:
>
> But what doesGetDataTableFromSql function come from?
>
> What about ths SQL:
> select spid from master..sysprocesses
>
> The code can't compile.
>
> I am using VS2005 and Sql2005 Express.
>
> //--------------------------------------------------------------------------------------------------------------------
> public static void KillProcesses(string DBConStr, string DBName)
> {
> try
> {
> using (SqlConnection conn = new SqlConnection(DBConStr))
> {
> conn.Open();
> string sSql = "select spid from master..sysprocesses
> where dbid=db_id('" + DBName + "')";
> DataTable oTable = GetDataTableFromSql(sSql, DBConStr,
> 60);
> foreach(DataRow oRow in oTable.Rows)
> {
> int Id = int.Parse(oRow[0].ToString());
> SqlCommand cmd = new SqlCommand("kill " + Id,
> conn);
> cmd.ExecuteNonQuery();
> }
> conn.Close();
>
> }
> }
> catch{}
> }
>
>
>
>
>
>
> "Robbe Morris [C# MVP]" <(E-Mail Removed)>
> 撰寫於郵件新聞:(E-Mail Removed)...
>> http://www.eggheadcafe.com/forums/Fo...=46053&INTID=9
>>
>> --
>> Robbe Morris - 2004/2005 Microsoft MVP C#
>> http://www.masterado.net
>>
>>
>>
>>
>>
>> "William (Bill) Vaughn" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> 1) Use the SQL Profiler to monitor connections
>>> 2) With the 1.1 framework (try to) use the .NET data performance
>>> counters. These can show how many connections are pooled but they don't
>>> work very well.
>>> 3) With the 2.0 framework there are new performance counters (that work)
>>> 4) With any version of SS you can monitor the number of user connections
>>> using its own performance counters.
>>>
>>> I'll be discussing these (and showing the code) in my session at VSLive
>>> in Sydney.
>>>
>>> --
>>> ____________________________________
>>> William (Bill) Vaughn
>>> Author, Mentor, Consultant
>>> Microsoft MVP
>>> INETA Speaker
>>> www.betav.com/blog/billva
>>> 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.
>>> __________________________________
>>>
>>> "ad" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>>I am use VS2005 Profession and SqlExpress 2005 to develop
>>>>WebApplication.
>>>> I use many SqlDataReader in my application.
>>>> I think there are some connecitons not be closed after reading data.
>>>>
>>>> How can I moniter the status of conneciton of a Database?
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to dertiminate ad Microsoft ADO .NET 1 20th Nov 2005 09:41 AM
How to dertiminate if a sting in the keys of a hashtable ad Microsoft C# .NET 5 16th Nov 2005 11:58 AM
Connection Manager (for wireless connecitons) needed Bjorn Simonsen Freeware 0 8th Sep 2005 11:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:35 PM.