-
Apr 18th, 2014, 01:08 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Server Connection
hi
I have written the below code in MDI form . If network is dowm then sytem hangs for 15 seconds when the below code is trying to check connection to server . Is it possible that system should not be in hang like situation
Private Sub Timer3_Timer()
If cnn2.State Then cnn2.Close
cnn2.Open "Driver=SQL Server;Server=" & Svr & ";Database=" & "Test" & ";uid=" & uid & ";pwd=" & pwd & ";"
Thanks
-
Apr 18th, 2014, 09:53 AM
#2
Re: Server Connection
Why would you write code like that? The timer ticks, connection is open, code closes the connection and opens it again, that is not a very good idea at all.
Also why do you keep creating new threads on basically the same question. Seems like this makes at least 3 or 4 threads I have saw from you related to opening this connection.
-
Apr 18th, 2014, 09:59 AM
#3
Thread Starter
Fanatic Member
Re: Server Connection
Hi Datamiser
can you help me with code what it should be
Thanks
-
Apr 18th, 2014, 12:39 PM
#4
Re: Server Connection
Well I don't know what you are trying to do really, even after 5 threads the only thing I have gathered is that you are trying to determine if the connection succeeds or not which you had some code for already in one of the other threads.
You should not be closing the connection and then opening it like that. Normally you would open a connection, use it, close it. If you need to hold the connection open then you would check to see if it is already open and if it use then use it if not then open it.
-
Apr 20th, 2014, 02:49 AM
#5
Frenzied Member
Re: Server Connection
Why don't use timeout Property of Cnn2.
Code:
Private Sub Timer3_Timer()
If cnn2.State Then cnn2.Close
cnn2.ConnectionTimeout = 0
cnn2.Open "Driver=SQL Server;Server=" & Svr & ";Database=" & "Test" & ";uid=" & uid & ";pwd=" & pwd & ";"
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
|