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

SqlConnection and DB connection failures detection

Hello everybody,

i'm writing an application, which should be connected all the time to
the database. So i want to test it in few ways if reconnection works in
order. First thing i tried to do is killing my apps process from MS SQL
(2005 Express). Problem is that after i have still "Open" status for
SqlConnection.Status. That means, that "Status" property is not enough
to test :( I would like to not to test the connection everytime with
some simple "select" queries, but if there is an another solution ?
Thanks in advance for any help.

--
Tomasz

Sep 18 '06 #1
9 2013

Tomasz wrote:
Hello everybody,

i'm writing an application, which should be connected all the time to
the database. So i want to test it in few ways if reconnection works in
order. First thing i tried to do is killing my apps process from MS SQL
(2005 Express). Problem is that after i have still "Open" status for
SqlConnection.Status. That means, that "Status" property is not enough
to test :( I would like to not to test the connection everytime with
some simple "select" queries, but if there is an another solution ?
Thanks in advance for any help.

Finally i did it by a combination of exception and loop blocks, but i'd
love to have an proper event or property to test :/

--
Tomasz

Sep 18 '06 #2
Hi,

"Tomasz" <to***************@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hello everybody,

i'm writing an application, which should be connected all the time to
the database.
Why ?
This will seriusly hamper the performance/scalability of both the DB and the
app
>So i want to test it in few ways if reconnection works in
order. First thing i tried to do is killing my apps process from MS SQL
(2005 Express). Problem is that after i have still "Open" status for
SqlConnection.Status. That means, that "Status" property is not enough
to test :( I would like to not to test the connection everytime with
some simple "select" queries, but if there is an another solution ?
I think that the status is not refhresed until a request is sent and an
error is received.
Again, IMO I think this is a bad design criteria.
What are you trying to do?

--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Sep 18 '06 #3

Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi,

"Tomasz" <to***************@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hello everybody,

i'm writing an application, which should be connected all the time to
the database.

Why ?
This will seriusly hamper the performance/scalability of both the DB and the
app
So, should i connect each time i want to launch a query (only insert
queries i'm performing)? Even if there are many such queries at the
time ? I mean, all these queries will be done from one machine, so
isn't better if i don't need to connect each time i want to insert a
row ?

--
Tomasz

Sep 18 '06 #4
Hi,

"Tomasz" <to***************@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
>
Ignacio Machin ( .NET/ C# MVP ) wrote:
>Hi,

"Tomasz" <to***************@gmail.comwrote in message
news:11**********************@k70g2000cwa.googleg roups.com...
Hello everybody,

i'm writing an application, which should be connected all the time to
the database.

Why ?
This will seriusly hamper the performance/scalability of both the DB and
the
app

So, should i connect each time i want to launch a query (only insert
queries i'm performing)?
YES !!
>Even if there are many such queries at the
time ?
YES
I mean, all these queries will be done from one machine, so
isn't better if i don't need to connect each time i want to insert a
row ?
Even if you close the connection it does not mean that the connection is
"really" closed. SQL server use something named connection pooling that does
indeed manage the connections for you. MS recommendation is that you open
the connection the latter possible and you close it the sooner you can.
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Sep 18 '06 #5
Ignacio Machin ( .NET/ C# MVP ) wrote:
Even if you close the connection it does not mean that the connection is
"really" closed. SQL server use something named connection pooling that does
indeed manage the connections for you. MS recommendation is that you open
the connection the latter possible and you close it the sooner you can.
Didn't know this! Man learns the whole life! Thanks for tips!

--
Tomasz

Sep 19 '06 #6
Ignacio Machin ( .NET/ C# MVP ) wrote:
Why ?
This will seriusly hamper the performance/scalability of both the DB and
the
app
So, should i connect each time i want to launch a query (only insert
queries i'm performing)?

YES !!
Ok, i changed this - my code is now much more simplified!
Now question - after performing insert query I'm closing connection,
but my process still exists in SQL Server Activity Monitor (even if i
close my app) with "Sleeping" status. I believe that this is what you
said about functionality of MS SQL (Damm i will order an MS SQL
bible-like book immediatelly!). How long server will keep this process
? Is it good idea to play with such timeouts to improve performance
(App is going to work 24h/day)?

Then second question - I'm using SQL Server authentication instead of
AD one, i think this is better solution for more missions-critical
apps, is it true ? Theoretically even if the whole my network is down
this application will still work (SQL server is on the same PC). What
would you say ?

Thanks in advance for your help!

--
Best regards
Tomasz

Sep 19 '06 #7
Hi,

"Tomasz" <to***************@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
>
Ok, i changed this - my code is now much more simplified!
Now question - after performing insert query I'm closing connection,
but my process still exists in SQL Server Activity Monitor (even if i
close my app) with "Sleeping" status. I believe that this is what you
said about functionality of MS SQL (Damm i will order an MS SQL
bible-like book immediatelly!). How long server will keep this process
? Is it good idea to play with such timeouts to improve performance
I would advise you not to. IF and only IF you are experimenting connection
problems you should modify the pooling. which is configurable btw. see
"connection pooling" in msdn
(App is going to work 24h/day)?
Then second question - I'm using SQL Server authentication instead of
AD one, i think this is better solution for more missions-critical
apps, is it true ?
Not sure about this. I do also prefer using SQL auth, in my current office
( florida department of transportation) it may takes 1 week to create a new
account in the domain.
Not sure what is best in mission-critical apps though.

>Theoretically even if the whole my network is down
this application will still work (SQL server is on the same PC). What
would you say ?
Not sure about this. maybe you will get a better answer in a SQL NG
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Sep 19 '06 #8

"Tomasz" <to***************@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
| Ignacio Machin ( .NET/ C# MVP ) wrote:
| Why ?
| This will seriusly hamper the performance/scalability of both the DB
and
| the
| app
|
| So, should i connect each time i want to launch a query (only insert
| queries i'm performing)?
| >
| YES !!
|
| Ok, i changed this - my code is now much more simplified!
| Now question - after performing insert query I'm closing connection,
| but my process still exists in SQL Server Activity Monitor (even if i
| close my app) with "Sleeping" status. I believe that this is what you
| said about functionality of MS SQL (Damm i will order an MS SQL
| bible-like book immediatelly!). How long server will keep this process
| ?

The physical connection drops after ~6 minutes, provided no logical
connections exists.

Is it good idea to play with such timeouts to improve performance
| (App is going to work 24h/day)?
|

No.

| Then second question - I'm using SQL Server authentication instead of
| AD one, i think this is better solution for more missions-critical
| apps, is it true ?

Authentication is all about security, not about being mission-critical. When
using integrated security, there is no way to expose the credentials used to
authenticate, while using SQL authentication, you can expose your secrets.

Theoretically even if the whole my network is down
| this application will still work (SQL server is on the same PC). What
| would you say ?
|

Yep. And authentication is less of a concern, credentials aren't going over
the network anyway.

Willy.
Sep 19 '06 #9
Hello!

Ok, then the last, i hope question.

Is it a good idea to launch insert queries in separate threads ?
Problem is my application waits for input from a user (proximity cards
reader), so could be, that for some reason procedure will freeze my
app, and then it will be impossible to react on next input, or I'm
wrong?

Thanks very much from your response :-)

--
Tomasz

Sep 20 '06 #10

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

Similar topics

1
by: Donnie Darko | last post by:
I'm trying to understand SqlConnection(), SqlCommand() For example. I use SqlConnection() as a parameter when I create a new SqlCommand. Then I open SqlConnection(), then I execute the...
4
by: The Coolest Dolphin | last post by:
Hi all, I have a question/problem concerning usage of my sqlconnection throughout my program. In my main form (frmMain) I defined an sqlconnection (I've set the connection public so that I can...
17
by: LP | last post by:
Hello, Here's the scenario: Object A opens a Sql Db connection to execute number of SqlCommands. Then it needs to pass this connection to a constructor of object B which in turn executes more...
13
by: MuZZy | last post by:
Hi, Just wanted to make sure i get it right: consider this class: // =========== START CODE ============= class Test { private SqlConnection con = null; public void Connect() { con = new...
16
by: ed_p | last post by:
Hello, I have implemented the singleton pattern for a class to hold a SqlConnection object that will be used thruout the application to create commands. My application is a simple Windows Form...
11
by: Bob | last post by:
In our new .NET web applications, we try to limit the use of SqlConnection to just one instance per page, even if there are multiple accesses to various queries. The thinking behind is that this...
4
by: Steve Richter | last post by:
I really miss c++ .... I have an SqlConnection object within my Web.UI.Page object. The thinking is that the connection to the database server is opened once when the page starts to do its...
5
by: fniles | last post by:
I am using VB.NET 2003. When using SQLClient.SQLConnection with SQL 2005 database, 1. connection pooling is automatically used, right ? I mean, in the connection string I do not need to explicitly...
4
by: =?Utf-8?B?VG9kZCBKYXNwZXJz?= | last post by:
Hey guys, I've written a web application that I'm simply trying to use to access a database. When I run the application locally (or as an NT Service) it can easily access the remote SQL...
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.