>>>>>>>>Hi,
>>>>>>>>
>>>>>>>>I received an error message from the customer using VFP 9 app with SQL Server 2005. The error message says "[ODBC SQL Server Driver] Communication link failure."
>>>>>>>>
>>>>>>>>Does anybody know what could cause such error? What to do to prevent it? TIA.
>>>>>>>
>>>>>>>The connection to the SQL Server is lost.
>>>>>>>You can't prevent this, but you may try to reconnect.
>>>>>>>This could be caused by bad LAN card, torn cable, bad switch etc. No power for some LAN devices.
>>>>>>
>>>>>>Thank you. I will have to think of how to make the "reconnect" work anywhere in my application. I never thought about this during the design phase.
>>>>>
>>>>>If you use SPT then make a class that could handle SQL* functions.
>>>>>Before every SQLEXEC just run one that you are sure it never fails like:
>>>>>
>>>>>IF SQLEXEC(sqlHandler,"SELECT GETDATE()","cTestConn") < 0
>>>>> SQLDISCONNECT(sqlHandler)
>>>>> sqlHandler = SQSTRINGCONNECT(....)
>>>>> IF sqlHandler < 0
>>>>> AERROR(laError)
>>>>> MessageBox("We have problems with connection to the SQL Server."+CHR(13)+;
>>>>> laError[1,2])
>>>>> ENDIF
>>>>>ENDIF
>>>>>USE IN SELECT("cTestConn")
>>>>>
>>>>>*** rest of execution code
>>>>>
>>>>
>>>>Thank you for the sample code. I use Cursor Adapter, not SPT, so I will see how to apply your code to my case. I appreciate your help.
>>>
>>>Check connection before you run some form.
>>
>>Thank you. I understand that this will slow down every connection (since the program has to check of "good" connection first). Is this a good practice, in your opinion?
>
>If you use several connections. then maybe not.
No, I use one connection for the application. At the top of the application the connection is created and used everywhere afterwards.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham