Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ADO and cursoradaptor problem! Anybody??
Message
From
24/05/2004 13:08:44
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
General information
Forum:
Visual FoxPro
Category:
Internet applications
Miscellaneous
Thread ID:
00906520
Message ID:
00906597
Views:
23
Stuart,
This sample should get you started :
#Define SQLCONNECTION 	"Provider=SQLOLEDB.1;Integrated Security=SSPI;"+;
    "Persist Security Info=False;"+;
    "Initial Catalog=Northwind; Data Source=ServerNAME"

*!* 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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform