Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Two CursorAdapters don't have two cursors opened
Message
From
13/03/2007 11:26:10
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01203001
Message ID:
01203015
Views:
15
I hope this code can be understood. If not please let me know
Thanks a lot
Hernan
*!*	LOAD event of the form

WITH this
     LOCAL cSelectCmd AS String

     cSelectCmd = "SELECT Expr_cli.Expr_cliid, Expr_cli.Expreso, Expr_cli.Clienteid " +;
                    "FROM Datos!Expr_cli " +;
                   "WHERE Expr_cli.Clienteid = '0'"

     .Ca("caExpr_cli", "Expr_cli", "curExpr_cli", .T., cSelectCmd, "Expr_cli")

     SELECT curExpr_cli
ENDWITH


*!*	Ca method of the form
Lparameters toObjeto, tcTabla, tcAlias, tcSelectCmd, tcListaTablas

** genera un cursor adapter de una sola tabla, actualizable o no, vacio o no

Local cSchema as String, cUFL as String, cUNL as String, lOK as Boolean, cSelectCmd as String, cThis as String

lOK = .T.

*******************************************
*!*	In here it generates the UpdatableFieldList, the UpdateNameList and the CursorSchema using the table for that
Try

    If Vartype(tcSelectCmd) = "C"
       cSelectCmd = tcSelectCmd
	   This.armaschema(tcTabla, cSelectCmd, tcAlias)  
       cSelectCmd = tcSelectCmd + [ into cursor ] + tcAlias
    else
	   This.OpenTable(tcTabla, tcAlias)  && abre la tabla
	   This.armaschema(tcTabla, '', tcAlias)  
    endif

Catch To oException

	lOK = .F.
	This.mensaje("No se pudo generar el schema en el cursor " + tcAlias + Chr(13) + oException.Message)

Endtry

If lOK = .F.
	Return
Endif
****************************************************

cUFL    = This.cUFL                        && updatable field list
cUNL    = This.cUNL      				   && update name list	
cSchema = This.cSch						   && table schema	

This.CloseTable(tcAlias)                   && cierra la tabla antes de armar el CA

lOK = .T.

Try
	If Vartype( "This." + toObjeto  ) = "O"
		Removeproperty(This, "toObjeto ")
	Endif

	This.AddProperty((toObjeto ))

    cCa  = "This." + toObjeto  + " = Createobject('cursoradapter')"
    &cCa 


Catch To oErrores

	Messagebox("No se pudo generar el objeto CursorAdapter"+;
		Chr(13)+oErrores.Message,16,"Atención",2000)

	lOK = .F.

Finally
Endtry

If lOK = .F.
	Return
Endif


If lOK = .T.
	Try

        cSelectCmd = tcSelectCmd

		cThis = 'This.' + toObjeto

		cDataSourceType = cThis + '.DataSourceType = "NATIVE"'
		cAlias          = cThis + '.Alias = "' + tcAlias + '"'

		If Vartype(tcListaTablas) = "C" and Len(Alltrim(tcListaTablas)) > 0
		   cTables      = cThis + '.Tables = "' + tcListaTablas + '"'
		else
		   cTables      = cThis + '.Tables = "' + tcTabla+ '"'
		endif   

		cDataSourceType     = cThis + '.DataSourceType = "NATIVE"'
		cAlias              = cThis + '.Alias = "' + tcAlias + '"'
		cTables             = cThis + '.Tables = "' + tcTabla + '"'
		cBufferModeOverride = cThis + '.BufferModeOverride = 5'
		cKeyFieldList       = cThis + '.KeyFieldList = "' + this.cCampoClave + '"'
		cSendUpdates        = cThis + '.SendUpdates = .T.'
		cSelectCmd          = cThis	+ '.SelectCmd = "' + cSelectCmd + '"'
		cUpdatableFieldList = cThis + '.UpdatableFieldList = "' + cUFL + '"'
		cUpdateNameList 	= cThis + '.UpdateNameList = "' + cUNL + '"'
		cCursorSchema       = cThis + '.CursorSchema = "' + cSchema + '"'
		cCursorFill	        = cThis + '.CursorFill()'

		&cDataSourceType
		&cAlias
	    &cTables
		&cBufferModeOverride
		&cKeyFieldList
		&cSendUpdates
		&cSelectCmd
		&cUpdatableFieldList
		&cUpdateNameList
		&cCursorSchema
		&cCursorFill

        Select ( tcAlias )
       
	Catch To oErrores

		Messagebox("No se pudo generar el Cursor "+tcAlias+Chr(13)+oErrores.Message;
			,16,"Atención",3000)

		lOK = .F.

	Endtry
Endif

Return lOK
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform