Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dynamically adding tables to data environment, VFP 7
Message
From
03/02/2002 05:39:55
Max Chen
Yx Software
Shunde, China
 
 
To
30/01/2002 12:06:19
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00612858
Message ID:
00614520
Views:
26
The follow is my solution

design form normally, drag table/views to data environment
then set property you want.

Set the AutoOpenTable and AutoCloseTable of the dte to .f. .

in the load event of the form, write your own code to
enumerate cursors and its definition then construct codes
to open them in your ways.

the following is my code in load events
*-----------------------------------------------------------
PRIVATE o,oData,i,cOErr,lErr
lErr=.f.
cOErr=ON('error')
oData=thisform.dataEnvironment
FOR i=1 TO oData.objects.count
o=EVALUATE('oData.Cursor'+ALLTRIM(STR(i,3)))

ON ERROR lErr=.t.
IF ! DBUSED(o.database)
OPEN DATABASE (o.database) SHARED
ENDIF
SET DATABASE TO (o.database)
ON ERROR &cOErr
IF lErr
RETURN .f.
ENDIF


DO CASE
CASE o.bufferModeOverride=0
nBuffer=1
CASE o.bufferModeOverride=1
nBuffer=thisform.BufferMode+1
OTHERWISE
nBuffer=o.bufferModeOverride
ENDCASE

TEXT TO cTmp noshow
USE <> <>
in 0 ALIAS <> <>
<> <>
connstring (gcConnectString)
ENDTEXT
ctmp=chrTRAN(ctmp,CHR(13)+CHR(10)+CHR(9),' ')

ON ERROR lErr=.t.
&cTmp
ON ERROR &cOErr
IF lErr
RETURN .f.
ENDIF

ON ERROR lErr=.t.
CURSORSETPROP("Buffering",nBuffer,o.Alias)
ON ERROR &cOErr
IF lErr
RETURN .f.
ENDIF

ON ERROR lErr=.t.
IF NOT EMPTY(o.filter)
SET FILTER TO (o.filter) IN (o.alias)
ENDIF
ON ERROR &cOErr
IF lErr
RETURN .f.
ENDIF
NEXT
*---------

select (thisform.cMasterAlias)
this.nConnectHandle=CursorGetProp('ConnectHandle')
glSql(this.nConnectHandle,'set Lock_TimeOut 3000')
glSql(this.nConnectHandle,'SET DATEFORMAT ymd')
glSql(this.nConnectHandle,'SET ANSI_NULLS OFF')
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform