Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reconnect a remote view to SQL server.
Message
From
10/07/2006 16:20:12
 
 
To
07/07/2006 03:31:31
Walter Meester
HoogkarspelNetherlands
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:
01135135
Views:
37
This message has been marked as a message which has helped to the initial question of the thread.
>BTW, you would not know a way in VFP8SP1 do more or less the same ?
>
Hi Walter,

1) You can close and reopen the views once you've detected that their connection is "broken".
2) You can use IdleTimeout property as an alternative for SQLIDLEDISCONNECT() function, but it may take up to two minutes to bring the connection into disconnected state (ODBChdbc == 0). Here is modified code:
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 c1 as Integer
	LOCAL c2 as Integer
	
	c1=CURSORGETPROP("ConnectHandle","view1")
	c2=CURSORGETPROP("ConnectHandle","view2")
	SQLSETPROP(c1,"IdleTimeout",1)
	SQLSETPROP(c2,"IdleTimeout",1)

	WAIT "Restoring connection. Please wait ..." TIMEOUT 120 
		
	? SQLGETPROP(c1,"ODBChdbc")
	
	SQLSETPROP(c1,"IdleTimeout",0)
	SQLSETPROP(c2,"IdleTimeout",0)

	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
Thanks,
Aleksey.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform