Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
As to Connect ADO and CursorAdapter with code
Message
 
To
29/10/2005 17:21:58
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01063303
Message ID:
01063306
Views:
10
>Please I need its aid in conexcion ADO with CursorAdapter for SQL Server 200O, but all with codigo:
>
>As I can connect a database of SQL Server 2000 and to recover the data of a board in the GRID of a Form, utilizing CursorAdapter and ADO, but all with Code, not desire to use the Generator of CursorAdapter. in order then to Insert, Save and Eliminate records?
>
>Please if they have an example they can send it to my email: rreynac@speedy.com.pe
>
>
>Thanks by its valuable aid
>
>ROBERT

Somethign like this?
This code is designed by builder and then I used Class Browser to get the code
DEFINE CLASS TestCA AS cursoradapter

	CursorSchema = "UpdateField1 C(9), UpdateField2 C(30)"
	Alias = "MyCA"
	DataSourceType = "ADO"
	Flags = 0
	FetchSize = -1
	Tables = "MySQLTable"
	BreakOnError = .T.
	Name = "TestCA"


	PROCEDURE Init
		local llReturn
		do case
			case not pemstatus(This, '__VFPSetup', 5)
				This.AddProperty('__VFPSetup', 0)
			case This.__VFPSetup = 2
				This.__VFPSetup = 0
				return
		endcase
		llReturn = dodefault()
		*** Select connection code: DO NOT REMOVE
		local loConnDataSource
		set multilocks on
		loConnDataSource = createobject('ADODB.Connection')
		***<DataSource>

                **** Here you must put your own connection string
		loConnDataSource.ConnectionString = [Provider=SQLNCLI.1;Integrated Security=SSPI;]+
                                                    [Persist Security Info=False;] + ;
                                                    [Initial Catalog=BORIS;Data Source=localhost;]

		***</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
		*** Setup code: DO NOT REMOVE
		***<SelectCmd>
		text to This.SelectCmd noshow
                     select * from MySQLTable
		endtext
		***</SelectCmd>
		***<KeyFieldList>
		text to This.KeyFieldList noshow
                     KeyField1,KeyField2 && etc.
		endtext
		***</KeyFieldList>
		***<UpdateNameList>
		text to This.UpdateNameList noshow
                     UpdateField1 MySQLTable.UpdateField1, UpdateField2 MySQLTable.UpdateField2 && etc.
		endtext
		***</UpdateNameList>
		***<UpdatableFieldList>
		text to This.UpdatableFieldList noshow
                     UpdateField1, UpdateField1 && etc.
		endtext
		***</UpdatableFieldList>
		*** End of Setup code: DO NOT REMOVE
		if This.__VFPSetup = 1
			This.__VFPSetup = 2
		endif
		return llReturn
	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
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform