Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. articles. downloads. faq. members. files. rss.
 From: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 To: Borislav Borissov
  Where is Borislav Borissov?
 Sofia
 Bulgaria
 Borislav Borissov
Subject: RE: How to prevent CA bringing in data?
Thread ID: 162536 Message ID: 162550 # Views: 4 # Ratings: 0
Version: Visual FoxPro 9 Category: General VFP Topics
Date: Monday, March 3, 2008 7:30:41 PM         
   



> > 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

ENTIRE THREAD

How to prevent CA bringing in data? Posted by Cetin Basoz @ 3/3/2008 6:27:38 PM
RE: How to prevent CA bringing in data? Posted by Borislav Borissov @ 3/3/2008 6:39:16 PM
RE: How to prevent CA bringing in data? Posted by Cetin Basoz @ 3/3/2008 6:49:23 PM
RE: How to prevent CA bringing in data? Posted by Borislav Borissov @ 3/3/2008 7:07:07 PM
RE: How to prevent CA bringing in data? Posted by Cetin Basoz @ 3/3/2008 7:12:16 PM
RE: How to prevent CA bringing in data? Posted by Borislav Borissov @ 3/3/2008 7:42:06 PM
RE: How to prevent CA bringing in data? Posted by Cetin Basoz @ 3/3/2008 7:30:41 PM