* 只是一个指向 DataEnvironment 对象的指针.
myde=Createobject("Data1")
Thisform.DataEnvironment=myde
myde.ADDOBJECT("demoname", "demo")
&&myde.demoname.selectcmd="select top 10 * from ................"
myde.demoname.selectcmd=comSql
* 在 LOAD 开始时打开表.
Thisform.DataEnvironment.OpenTables
Thisform.DataEnvironment.CloseTables && 在 destroy 过程的结束处关闭表
Define Class Data1 As DataEnvironment && 数据环境类
Name = "Dataenvironment"
Top = 220
Left = 1
Width = 520
Height = 200
Datasource = .Null.
DataSourceType = "ADO"
Procedure BeforeOpenTables
*** Select connection code: DO NOT REMOVE
Local loConnDataSource
loConnDataSource = Createobject('ADODB.Connection')
***<DataSource>
&&loConnDataSource.ConnectionString = [Provider=SQLOLEDB.1;Password=cxy;Persist Security Info=True;User ID=sa;Ini] + ;
&& [tial Catalog=bussetup;Data Source=.;]
loConnDataSource.ConnectionString = conString
***</DataSource>
loConnDataSource.Open()
This.Datasource = Createobject('ADODB.RecordSet')
This.Datasource.CursorLocation = 3 && adUseClient
This.Datasource.LockType = 3 && adLockOptimistic
This.Datasource.ActiveConnection = loConnDataSource
*** End of Select connection code: DO NOT REMOVE
ENDPROC
Enddefine && 添加 Cursor 类对象
DEFINE CLASS demo as CursorAdapter
UseDeDataSource= .T.
SelectCmd="select * from ........."
CursorSchema ="ID I, 日期 T"
Alias = "demotable"
Flags = 0
KeyFieldList = "ID"
Tables = ".......D"
UpdatableFieldList = "................"
UpdateNameList = "......................."
UseCursorSchema = .T.
Name = "demo"
Procedure Init
*** Setup code: DO NOT REMOVE
Local llReturn
Do Case
Case Not Pemstatus(This, '__VFPSetup', 5)
This.AddProperty('__VFPSetup', 0)
Case This.__VFPSetup = 1
This.__VFPSetup = 2
Case This.__VFPSetup = 2
This.__VFPSetup = 0
Return
Endcase
Set Multilocks On
llReturn = DoDefault()
*** End of Setup code: DO NOT REMOVE
*** Setup code: DO NOT REMOVE
If This.__VFPSetup = 1
This.__VFPSetup = 2
Endif
Return llReturn
*** End of Setup code: DO NOT REMOVE
Endproc
Procedure AutoOpen
*** Setup code: DO NOT REMOVE
If Not Pemstatus(This, '__VFPSetup', 5)
This.AddProperty('__VFPSetup', 1)
This.Init()
Endif
*** End of Setup code: DO NOT REMOVE
Endproc
ENDDEFINE
[此贴子已经被作者于2023-12-20 12:51编辑过]