Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reconnect a remote view to SQL server.
Message
From
07/07/2006 03:31:31
Walter Meester
HoogkarspelNetherlands
 
 
To
06/07/2006 17:59:47
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01133536
Message ID:
01134367
Views:
34
Hi Aleksey,

Using you example below, I was able to fix the problem. Many, many thanks.
BTW, you would not know a way in VFP8SP1 do more or less the same ?

I relialise we have to go to VFP9SP1, but we are facing quite a few problems with C00005 errors that seem to have to do with corrupted buffers (it gives C5s on OLDVAL(), SYS(1104), SQL commandss) both in VFP8 and 9, so we really have to throuroughly test this before upgrading.

Thanks again,

Walter,






>>Hi aleksey,
>>
>>I'm not sure I understand this.
>>
>>My application uses a shared connection made by SQLSTRINGCONNECT(). All remote views and SPT are using this connection.
>>
>>After I detect the connection has been broken I do a SQLIDLEDISCONNECT(Applic.SQLhandle) to close the connection. This sometimes works, but in other cases it does not.
>>
>>If I get the connectionhandle via CURSORGETPROP("Connectionhandle", Myview) and use that handle in SQLIDLEDISCONNECT(), the function is returning -1. Even using 0 as a parameter returns -1.
>>
>>The ODBChdbc and ODBChstmt do still contain numbers (are not set to 0).
>>
>>The problem as I see it is that I have to detect the disconnect before I try to requery() it. Once I don't do that, SQLIDLEDISCONNECT() does not reconnect the disconnected view.
>>
>>Can you confirm this problem ?
>>
>>Walter,
>>
>>
>
>Hi Walter,
>
>The following code works fine for two views and shared connection. REQUERY fails, "broken" connection is successfully disconnected using SQLIDLEDISCONNECT and restored after that.
>
>
>CLOSE DATABASES all
>CLEAR
>
>DELETE DATABASE TestReconnect
>
>CREATE DATABASE TestReconnect
>
>con = SQLCONNECT("LocalServer")
>
>IF con<1
>	? "Failed to connect!"
>	RETURN
>ENDIF
>
>CREATE CONNECTION test CONNSTRING (SQLGETPROP(con,"ConnectString"))
>SQLDISCONNECT(con)
>
>CREATE SQL VIEW view1 REMOTE CONNECTION test SHARE As ;
>select top 1 * from northwind..categories
>
>CREATE SQL VIEW view2 REMOTE CONNECTION test SHARE As ;
>select top 2 * from northwind..categories
>
>SELECT 0
>USE view1
>DELETE ALL
>? "Connection handle:",CURSORGETPROP("ConnectHandle","view1")
>LIST
>
>SELECT 0
>USE view2
>DELETE ALL
>? "Connection handle:",CURSORGETPROP("ConnectHandle","view2")
>LIST
>
>WAIT "Kill the connection ..."
>
>IF REQUERY("view1")!=1
>	? "REQUERY failed, disconnect and retry."
>	AERROR(aerrs)
>	DISPLAY MEMORY LIKE aerrs
>	
>	LOCAL hdbc as Integer
>	
>	hdbc=SQLGETPROP(CURSORGETPROP("ConnectHandle","view1"),"ODBChdbc")
>	ASQLHANDLES(sqlhndls)
>	
>	FOR I=1 TO ALEN(sqlhndls)
>		IF SQLGETPROP(sqlhndls(I),"ODBChdbc")=hdbc
>			? "Disconnecting handle:", sqlhndls(I)
>			?? sqlidledisconnect(sqlhndls(I))
>			?? SQLGETPROP(sqlhndls(I),"ODBChdbc")
>		ENDIF
>	NEXT
>	
>	IF REQUERY("view1")!=1 OR REQUERY("view2")!=1
>		? "REQUERY failed!!!"
>		AERROR(aerrs)
>		DISPLAY MEMORY LIKE aerrs
>	ELSE
>		? "REQUERY succeeded"
>		SELECT view1
>		LIST
>
>		SELECT view2
>		LIST
>	ENDIF
>ENDIF
>
>
>Output:
>
>Connection handle:          2
>Record#   CATEGORYID CATEGORYNAME    DESCRIPTION PICTURE
>      1 *          1 Beverages       Memo        Gen
>
>Connection handle:          3
>Record#   CATEGORYID CATEGORYNAME    DESCRIPTION PICTURE
>      1 *          1 Beverages       Memo        Gen
>      2 *          2 Condiments      Memo        Gen
>
>Kill the connection ...
>REQUERY failed, disconnect and retry.
>AERRS       Pub    A
>   (   1,   1)     N  1526        (      1526.00000000)
>   (   1,   2)     C  "Connectivity error: [Microsoft][ODBC SQL Serv
>                      er Driver][Shared Memory]ConnectionWrite (Wrap
>                      perWrite())."
>   (   1,   3)     C  "[Microsoft][ODBC SQL Server Driver][Shared Me
>                      mory]ConnectionWrite (WrapperWrite())."
>   (   1,   4)     C  "01000"
>   (   1,   5)     N  4           (         4.00000000)
>   (   1,   6)     N  2           (         2.00000000)
>   (   1,   7)     C  .NULL.
>   (   2,   1)     N  1526        (      1526.00000000)
>   (   2,   2)     C  "Connectivity error: [Microsoft][ODBC SQL Serv
>                      er Driver][Shared Memory]ConnectionWrite (Wrap
>                      perWrite())."
>   (   2,   3)     C  "[Microsoft][ODBC SQL Server Driver][Shared Me
>                      mory]General network error. Check your network
>                       documentation."
>   (   2,   4)     C  "08S01"
>   (   2,   5)     N  11          (        11.00000000)
>   (   2,   6)     N  2           (         2.00000000)
>   (   2,   7)     C  .NULL.
>Disconnecting handle:          2         1  33493832
>Disconnecting handle:          3         1         0
>REQUERY succeeded
>Record#   CATEGORYID CATEGORYNAME    DESCRIPTION PICTURE
>      1            1 Beverages       Memo        Gen
>
>Record#   CATEGORYID CATEGORYNAME    DESCRIPTION PICTURE
>      1            1 Beverages       Memo        Gen
>      2            2 Condiments      Memo        Gen
>
>
>Thanks,
>Aleksey.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform