Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to use the CursorAdapter
Message
 
To
07/11/2002 04:27:19
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00719501
Message ID:
00719793
Views:
35
Thanks for this example. It clearly shows strenght of cursoradapter class

>
>One sample :)
>
>#Define SQLCONNECTION 	"Provider=SQLOLEDB.1;Integrated Security=SSPI;"+;
>  "Persist Security Info=False;"+;
>  "Initial Catalog=Northwind; Data Source=servernamehere"
>
>*!* ADO CursorAdapter
>oXC1 = Createobject('xcADOUpdatable', "vcustomers", SQLCONNECTION, ;
>   "select * from customers",;
>   "Customers",;
>   "CustomerID",;
>   "CustomerID, CompanyName, ContactName, ContactTitle",;
>   "CustomerID customers.CustomerID, "+;
>   "CompanyName customers.CompanyName,"+;
>   "ContactName customers.ContactName,"+;
>   "ContactTitle customers.ContactTitle")
>
>CursorSetProp("Buffering",5,'vcustomers')
>Browse Title 'Before modification'
>If ( !Tableupdate(2,.T.,'vcustomers') )
>  oXC1.DispError()
>Else
>  oXC1.CursorFill()
>  Browse Title 'After Tableupdate'
>Endif
>
>Define Class xcADOUpdatable As CursorAdapter
>  AllowUpdate = .T.
>  AllowInsert = .T.
>  AllowDelete = .T.
>  Procedure Init
>    Lparameters tcAlias,tcConn, tcSQL,tcTables,;
>    tcKeyFieldList,tcUpdatableFieldList,tcUpdateNameList
>    This.AddProperty('oConn', Newobject("ADODB.Connection"))
>    This.AddProperty('oRS',   Newobject("ADODB.Recordset"))
>    With This.oConn
>      .ConnectionString = tcConn
>      .Mode = 16  && adModeShareDenyNone
>      .Open()
>    Endwith
>    With This.oRS
>      .ActiveConnection = This.oConn
>      .LockType=3  && adLockOptimistic
>      .CursorLocation = 3  && adUseClient
>      .CursorType = 2  && adOpenDynamic
>    Endwith
>    With This
>      .Alias = tcAlias
>      .Tables = tcTables
>      .KeyFieldList = tcKeyFieldList
>      .UpdatableFieldList = tcUpdatableFieldList
>      .UpdateNameList = tcUpdateNamelist
>      .WhereType = 1
>      .UpdateType= 1
>      .SendUpdates = .T.
>      .DataSourceType = "ADO"
>      .Datasource = This.oRS
>      .SelectCmd = tcSQL
>      .CursorFill()
>    Endwith
>  Endproc
>
>  Procedure DispError
>    Local Array errors(1)
>    Local lcError
>    Aerror(errors)
>    lcError = 'Error--------------'
>    For ix=1 To 7
>      lcError = lcError + Chr(13)+Transform(errors[ix])
>    Endfor
>    lcError = lcError + Chr(13) + 'Error--------------'
>    Messagebox(lcError)
>  Endproc
>Enddefine
>
Cetin
Previous
Reply
Map
View

Click here to load this message in the networking platform