Groups | Blog | Home
all groups > sql server connect > march 2007 >

sql server connect : How to decrease database connectivity failure time


Kumar
3/20/2007 12:00:00 AM
Hi All,

I am an VC++ programmer. I had written an VC++ application, which
will fetch data from SQL Server. I am doing DB Connectivity by creating a
DSN.

My application works perfectly. But it lacked with need some
performance issues when the DB Connectvity fails.

If Database connectivity Succeeded, i am getting records
immediately.

If Database connectivity fails due to Network failure or Database
Down etc..., it is taking more more time to display SQL Database
Connectivity error.

So how can i reduce this time when Database connectivity fails.

--

Regards & Thanks,

B B S Kumar Katikireddy
Software Engineer
9820474363

William (Bill) Vaughn
3/20/2007 10:33:07 AM
If you're creating a DSN, it means you aren't using the right provider.
SqlClient does not use/need a DSN. What do you mean by "DB Connectivity
fails"?

--
____________________________________
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.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

[quoted text, click to view]

Kumar
3/21/2007 12:00:00 AM
Hi William,

Thanks for your response.

I am opening the SQL Server connection in one of the following
ways.

1. Without DSN
_bstr_t strCon(L"Provider=SQLOLEDB.1;" L"Persist Security Info=False;"
L"User ID=sa;" L"Password=shah;" L"Initial Catalog=Ravi;" L"Data Source=
10.1.3.52;");

hRes = m_pConnection->Open(strCon,"","",0);

2. Using DSN

_bstr_t strCon(L"User ID=sa;" L"Password=shah;" L"Data Source= Spanco;");

hRes = m_pConnection->Open(strCon,"","",0);

In both cases, assume SQL Server is not running during program execution,
then the Database Connectivity with SQL Server will fail. In this case, i am
getting SQL error message after a long time as shown below. Means around
after 1 minute.

[Microsoft][ODBC SQL Server Driver][Shared Memory]SQL Server does not exist
or access denied.

I want to minimize this time. So how can i do this.



[quoted text, click to view]

William (Bill) Vaughn
3/21/2007 10:40:13 AM
Right. You're not using .NET at all (or so it seems). What you're seeing is
"by design". The default timeout for a connection is 1 minute. Generally,
you can set this to 10-20 seconds using the provider-specific timeout key
and get better response when the server is not there. You can also (in .NET)
easily code a Factory class that returns the visible servers and their state
so you would not have to wait at all--just connect to an active server.

--
____________________________________
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.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

[quoted text, click to view]

Kumar
3/22/2007 12:00:00 AM
Hi William,

Thanks for your help. You are absloutly right. I am not using
..net. I am using VC++ 6.0.
Your answer works perfectly. I used timout option with connection
pointer.

Once again really thanks for your help.

Regards,

B B S Kumar.

[quoted text, click to view]

AddThis Social Bookmark Button