Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP e Firebird/Interbase
Message
From
01/12/2003 07:28:55
 
 
To
01/12/2003 05:44:31
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00854148
Message ID:
00854630
Views:
16
Alo, José Maria.

>já programo há bastante tempo com VFP 5 e 6, estou iniciando agora em VFP 8, juntamente com SQL, seria possível me enviar um exemplo de CursorAdapter....

Envio-le um par de exemplos para você:
Function ConsultaNativa

* Abro la DBC
Open Database ( Home(2) + 'Northwind\Northwind.dbc' )

* Creo el CursorAdapter
Local oCA As CursorAdapter
oCA=Createobject("CursorAdapter")

* Seteo las propiedades necesarias para obtener los datos
With oCA
	.DataSourceType="NATIVE"
	.Alias="Clientes"
	.SelectCmd="select * from customers"
	If .CursorFill()
		Select Clientes
		Browse
	Else
		Messagebox( "Falló el CursorFill!!!", 16 )
	Endif
Endwith

oCA = Null
Release oCA

* Cierro la DBC
Close Database

Return

********************
Function ConsultaADO

* Me conecto al BackEnd con un objeto ADO Connection
oConn = Createobject("ADODB.Connection")
oConn.ConnectionString = 'Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind;Data Source=SaliasMovil'
oConn.Open()

* Creo un objeto ADO Command
oCmd = Createobject("ADODB.Command")
oCmd.ActiveConnection = oConn

* Creo un objeto ADO Recordset
oRS = Createobject("ADODB.Recordset")
With oRS
	.CursorLocation 	= 3 &&adUseClient
	.LockType 			= 3 &&adLockOptimistic
	.ActiveConnection 	= oConn
Endwith

* Creo un CursorAdapter
Local oCA As CursorAdapter
oCA=Createobject("CursorAdapter")

* Seteo las propiedades necesarias para obtener los datos
With oCA
	.DataSourceType="ADO"
	.Datasource = oRS
	.Alias="Clientes"
	.SelectCmd="select * from customers"
	
	.KeyFieldList="CustomerID"
	.UpdatableFieldList = "companyname,contactname"
	.UpdateNameList     = [companyname Customers.CompanyName, contactname Customers.ContactName]
	
	If .CursorFill()
		Select Clientes
		CursorSetProp("Buffering",5)
		
		Browse
		
		If TableUpdate(.t.)
			MessageBox("Actualizó")
		EndIf 
	Else
		Messagebox( "Falló el CursorFill!!!", 16 )
	EndIf

	
Endwith

oCA = Null
Release oCA

oRS = Null
Release oRS

oCmd = Null
Release oCmd

oConn.Close()
oConn = Null
Release oConn

Return
Até mais,
Previous
Reply
Map
View

Click here to load this message in the networking platform