|
-
December 11th, 2007, 08:08 AM
#1
CRecordSet Timeout
I connect to a remote database with CRecordSet derived class and ODBC. (MyODBC)
The timeout of the remote DB is 5 minutes and I can not change it.
Supposing the timeout time has passed.
- Question 1:
How can I detect the server has disconnected me? I tried CRecordSet::IsOpen() and CDabase::IsOpen() but are still given me TRUE.
- Question 2:
The problem is closing the CRecordSet and opening it again gives me a timeout error message. I have to close the application and run it again. What should I do in order to reconnect again with the DB without closing the Application?
Thank you.
-
December 11th, 2007, 08:14 AM
#2
Re: CRecordSet Timeout
I don't know if they'd help here, but have you tried the SetLoginTimeout and SetQueryTimeout methods of CDatabase?
-
December 11th, 2007, 09:29 AM
#3
Re: CRecordSet Timeout
Question 1:
you could try ::SQLGetInfo () with the SQL_ACTIVE_CONNECTIONS flag.
Another way is try to open a Recordset and surround it with a try/catch. If an error occurs you know the connection is gone 
Question 2:
That's weird behaviour. You should be able to open and close a recordset as much as you like. I think you should try to find why you get a timeout.
Last edited by Skizmo; December 11th, 2007 at 09:31 AM.
-
December 12th, 2007, 03:32 AM
#4
Re: CRecordSet Timeout
 Originally Posted by GCDEF
I don't know if they'd help here, but have you tried the SetLoginTimeout and SetQueryTimeout methods of CDatabase?
Thanky you.
I think is a connection timeout matter since I already was connected and there is no query involved.
-
December 12th, 2007, 03:41 AM
#5
Re: CRecordSet Timeout
 Originally Posted by Skizmo
Question 1:
you could try ::SQLGetInfo () with the SQL_ACTIVE_CONNECTIONS flag.
Another way is try to open a Recordset and surround it with a try/catch. If an error occurs you know the connection is gone 
I will try that way.
 Originally Posted by Skizmo
Question 2:
That's weird behaviour. You should be able to open and close a recordset as much as you like. I think you should try to find why you get a timeout.
I am sure the timeout happens because I have the recordset open without doing anything more time than the connection timeout of the server.
I wonder why after closing the recordset when trying to open it again fails.
I don't know how to restore the conection when this happens.
The error message I receive is "MySQL server has gone away". I've read the help in mysql site about this issue but I don't find nothing helpful in order to restore the connection.
-
December 13th, 2007, 05:35 AM
#6
Re: CRecordSet Timeout
The only way I have found to solve the problem is to dynamically create and destroy the CRecordSet object. Then If I found it is timeout I destroy and create it again before calling Open().
This solves the problem but is only a way to surround the problem.
I still don't know where is and/or what is that hidden link between the recordset object and the server that allows the server to remember the recordset was timeout even though the recorset is closed.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|