> > Title says it all. I thought CA.Nodata = .t. and/or CursorFill(,.T.) would do it but couldn't succeed. Anyone with CA experience know how to to a NoDataOnload? The only workaround I found is to add "where 1=0" in beforecursorfill.
> > TIA
> >
> > Cetin Basoz
>
> That works for me:
>
> oCA= CREATEOBJECT([CursorAdapter])
> oCA.DataSourceType = [ODBC]
> oCA.DataSource = SQLSTRINGCONNECT([Driver=SQL Server;Server=Boris;DataBase=Test;TRUSTED_CONNECTION=Yes;])
> oCa.NoData = .t.
> oCa.SelectCmd = [Select * from test]
> ? oCa.CursorFill()
> BROWSE NORMAL && Empty cursor
> ? oCa.CursorRefresh()
> BROWSE NORMAL && All records come to me :-)
>
>
> -----------------
> Borislav Borissov
>
>
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller>
The only thing normal about database guys is their tables.OK, I gave up trying to do it directly with CA class' NoData and indirectly do something like:
oApp = Createobject('myApp')
Local lcSQL, _loCa
lcSQL = 'select * from myTable where somefield like ?m.lcString'
_loCa = CreateGenCA(m.lcSQL, "MyResult")
With _loCa
lcString = 'be%'
.CursorFill(.F.,.F.,0,.oCommand)
Endwith
Browse
Function CreateGenCA(m.tcSQL, m.tcALias)
Clear
Local loConn As ADODB.Connection, ;
loException As Exception, ;
loCursor As CursorAdapter, ;
laErrors[1]
loConn = Createobject('ADODB.Connection')
With loConn
.ConnectionString = oApp.DataConnectionString
Try
.Open()
Catch To loException
Messagebox(loException.Message)
Cancel
Endtry
Endwith
loCursor = Createobject('CursorAdapter')
loCursor.AddProperty( 'oCommand', Createobject('ADODB.Command') )
With loCursor
.Alias = m.tcALias
.DataSourceType = 'ADO'
.SelectCmd = m.tcSQL
.Datasource = Createobject('ADODB.Recordset')
.Datasource.ActiveConnection = loConn
.oCommand.ActiveConnection = loConn
Endwith
Return loCursor
Endfunc
Define Class myApp As Custom
DataConnectionString = ;
"Provider=SQLNCLI.1;Integrated Security=SSPI;Persist Security Info=False;"+;
"Initial Catalog=MyDatabase;Data Source=.\sqlexpress;"
Enddefine
Cetin Basoz