Handling SQL Server connection failure in VC++

Handling SQL Server connection failure in VC++

Post by Ray Melende » Thu, 08 Nov 2001 01:05:38



I have a VC service program accessing a
continously accessing SQL 2K database.
It selects the records from a table that have
a flag set to 1, processes an external funcion,
sets the flag to 0, and process the remaining
records set with 1.  Once all the selected records
are processed, the selection is done again.
There is a pseudo code below...

Every once in a while, my service receives an
error saying:

Connection failed:
SQLState: '01000'
SQL Server Error: 6
[Microsoft][ODBC SQL Server Driver][Shared Memory]
ConnectionOpen (Connect())'
Connection failed:
SQLState: '08001'
SQL Server Error:6
[Microsoft][ODBC SQL Server Driver][Shared Memory]
Specified SQL Server not found

This is followed by an ODBC Dialog
I'm not sure what is causing this error. I am
accessing the database more than once every
second. Once I select and hit OK, the
service continues to work like a charm.
What can I do to handle this error?
I did read about SetLoginTimout, but since
I'm only using CDatabase:Open once, I'm only
required to login once. Below is a pseudo code
of my source code in Visual C++

Begining of thread...
CDatabase myDB
myDb.OpenEx ("DSN=xxxx", CDatabase:noOdbcDialog)

CRecordset myRs (&myDB);

while (bServiceIsRunning)
{
    myRS.Open (dynaset, "Select All records with Flag =1")
    while (!myRS.IsEof && myRS.IsOpen && bServiceIsRunning)
    {
      run external functions
      Set Flag to 0 using myDB->ExecuteSQL
   }
   if (myRS.IsOpen) myRS.Close

Quote:}

if (myDB.IsOpen) myDB.Close
...end of thread
 
 
 

1. Handling SQL Server connection failure

I have a VC service program accessing a
continously accessing SQL 2K database.
It selects the records from a table that have
a flag set to 1, processes an external funcion,
sets the flag to 0, and process the remaining
records set with 1.  Once all the selected records
are processed, the selection is done again.
There is a pseudo code below...

Every once in a while, my service receives an
error saying:

Connection failed:
SQLState: '01000'
SQL Server Error: 6
[Microsoft][ODBC SQL Server Driver][Shared Memory]
ConnectionOpen (Connect())'
Connection failed:
SQLState: '08001'
SQL Server Error:6
[Microsoft][ODBC SQL Server Driver][Shared Memory]
Specified SQL Server not found

This is followed by an ODBC Dialog
I'm not sure what is causing this error. I am
accessing the database more than once every
second. Once I select and hit OK, the
service continues to work like a charm.
What can I do to handle this error?
I did read about SetLoginTimout, but since
I'm only using CDatabase:Open once, I'm only
required to login once. Below is a pseudo code
of my source code in Visual C++

Begining of thread...
CDatabase myDB
myDb.OpenEx ("DSN=xxxx", CDatabase:noOdbcDialog)

CRecordset myRs (&myDB);

while (bServiceIsRunning)
{
    myRS.Open (dynaset, "Select All records with Flag =1")
    while (!myRS.IsEof && myRS.IsOpen && bServiceIsRunning)
    {
      run external functions
      Set Flag to 0 using myDB->ExecuteSQL
   }
   if (myRS.IsOpen) myRS.Close
if (myDB.IsOpen) myDB.Close
...end of thread

2. I have a question..!

3. Handling SQL Server connection failures

4. stupid i-net&i-star question

5. Connection is busy with results - VC++ 1.52, SQL Server 6.5, ODBC

6. MDAC problems

7. Deleting records in SQL server from VC++ DAO connection

8. Recordset as result for JSP

9. Connection is busy with results - VC++ 1.52, SQL Server 6.5, ODBC

10. Sql Server Connection Failure

11. Connection failure to SQL Server 7.0 database from OLAP

12. SQL Server registration failed because of the connection failure displayed below

13. Login Failure/Not Trusted SQL Server Connection