>*Sample form >#Define SQLCONNECTION "Provider=SQLOLEDB;Integrated Security=SSPI;"+; > "Persist Security Info=False;"+; > "Initial Catalog=Northwind; Data Source=servername" > >oForm = Createobject('myForm',SQLCONNECTION) >oForm.Show >Read Events > >Define Class myForm As Form > DataSession = 2 > Height = 300 > Width = 800 > Add Object Grd1 As myGrid With Height = 300, Width = 400 > Add Object Grd2 As Grid With Height = 300, Width = 400, Left = 400 > > Procedure Init > Lparameters tcConn To cool! This is just what I was lookin for. Is there a way to open the cursoradapter in a program then use it in a form with the parameters? This is so I can use the same cursoradapter in mutiple forms. > This.AddProperty('oConn', Newobject("ADODB.Connection")) > With This.oConn > .ConnectionString = tcConn > .Mode = 16 > .Open() > Endwith > This.AddProperty('Dataenvironment',Createobject('myDataEnvironment', This.oConn)) > This.Grd1.RecordSource = 'ca_customers' > This.Grd2.RecordSource = 'ca_orders' > Endproc > > Procedure QueryUnload > Clear Events > Endproc > Procedure Destroy > Endproc > > Procedure DispError > Local Array errors(1) > Aerror(errors) > ? 'Error--------------' > For ix=1 To 7 > ? errors[ix] > Endfor > ? 'Error--------------' > Endproc > >Enddefine > >Define Class myDataEnvironment As DataEnvironment > Procedure Init > Lparameters toConn > With This > .AddObject('caCustomers','myADOAdapter',toConn,'ca_customers') > With .caCustomers > .Tables = "Customers" > .KeyFieldList = "CustomerID" > .UpdatableFieldList = "CustomerID, CompanyName, ContactName, ContactTitle" > .UpdateNameList = ; > "CustomerID customers.CustomerID, "+; > "CompanyName customers.CompanyName,"+; > "ContactName customers.ContactName,"+; > "ContactTitle customers.ContactTitle" > .SelectCmd = "select * from customers" > .CursorFill() > Endwith > .AddObject('caOrders','myADOAdapter',toConn,'ca_orders') > With .caOrders > .Tables = "Orders" > .KeyFieldList = "ORDERID" > .UpdateNameList = "CUSTOMERID Orders.CUSTOMERID, "+; > "EMPLOYEEID Orders.EMPLOYEEID,"+; > "FREIGHT Orders.FREIGHT,"+; > "ORDERDATE Orders.ORDERDATE,"+; > "ORDERID Orders.ORDERID" > .UpdatableFieldList = "CUSTOMERID, EMPLOYEEID, FREIGHT, ORDERDATE, ORDERID" > .CursorSchema = "CUSTOMERID C(5), EMPLOYEEID I, FREIGHT Y, ORDERDATE D, ORDERID I" > > .AddProperty('oCommand', Newobject('ADODB.Command') ) > With .oCommand > .CommandText = "select Orders.CustomerID, Orders.EmployeeID, "+; > "Orders.Freight, Orders.OrderDate, Orders.OrderID"+; > " from Orders"+; > " where customerID = ?"+; > " order by employeeID, orderdate desc" > .Parameters.Append( .CreateParameter("CustomerID", 129,1,10,ca_customers.customerID) ) > Endwith > .oCommand.ActiveConnection = .Datasource.ActiveConnection > .AddProperty( 'oRS', .oCommand.Execute() ) > .CursorFill(.T., .F., 0, .oRS) > Endwith > Endwith > Endproc >Enddefine > >Define Class myGrid As Grid > Procedure AfterRowColChange > Lparameters nColIndex > With Thisform.DataEnvironment.caOrders > .oRS.ActiveCommand.Parameters("CustomerID") = ca_customers.customerID > .CursorRefresh() > Endwith > Thisform.Refresh() > Endproc >Enddefine > >Define Class myADOAdapter As CursorAdapter > AllowUpdate = .T. > AllowInsert = .T. > AllowDelete = .T. > WhereType = 1 > UpdateType= 1 > SendUpdates = .T. > DataSourceType = "ADO" > > Procedure Init > Lparameters toConn, tcAlias > With This > .Alias = tcAlias > .Datasource = Newobject("ADODB.Recordset") > With .Datasource > .ActiveConnection = toConn > .LockType=4 > .CursorLocation = 3 > .CursorType = 2 > Endwith > Endwith > Endproc > > Procedure UpdateTable > This.Datasource.Updatebatch() > Endproc >Enddefine >Cetin