Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Advantages-Disadvantages between CA vs SPT
Message
From
27/02/2007 17:19:48
Hans-Otto Lochmann
Dr. Lochmann Consulting Gmbh
Frankfurt, Germany
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01198612
Message ID:
01199361
Views:
22
>Thanks for the reply Hans,
>i'll look up these links,
>i've also Mark McCasland's CA-Builder but i doesnt work forme SQL server why i dont know :( for native its OK
>
>PS : first i've installed SQL 2005 after than SQL 2000 may be this cause to doesnt work for CABuilder

Hi Soykan,

my pleasure.

I never tried Mark McCasland's CA-Builder, I just mentioned it. But there a version available for Visual FoxPro 9 at UT Download #26265, which obviously you have downloaded already.

I always use the Visual FoxPro 9 CA builder with some twinkle in my eyes:

Just to mention, before I forget it: I never used SPTs, so I cannot tell you anything about it.

I have installed SQL 2005 PLUS the SQL Server Management Studio Express, which not only is a great help to get the SQL server doing what you want, it has - like Visual FoxPro - kind of a command window, where you can do all kind of tests. It also allows you to access BOL (Books On Line), where you will answers to all of questions, once you got used to the particular way BOL wants to be asked.

I never tried to use SQL 2000 as a data source for my apps, so I cannot tell you anything about it.

As far as CAs are concerned: With the information from Chuck's article, the tip from Borislav (Message ID #1155867) and the help of the Visual FoxPro CA builder I have set up my CA base class, which you will find at the end of this message. There is not much wisdom in it because most of the code has been generated by the Visual FoxPro CA builder. I just send it to you just as a starter.

You then can start to build you CA classes as children of this base class using the Visual FoxPro CA builder. I usually do it this way:

When I start the builder the first time for a new class, which has been created as a child of my base class, I select ODBC as Data Source Type, enter my Connection String and continue to use the builder as described for instance in the Visual FoxPro help or in the MSDN Library, see http://msdn2.microsoft.com/en-us/library/xtakh6xc(VS.80).aspx. If you are connected to the SQL server via ODBC all what has to be done is easy. You also could set the "Use the connection string setting in the builder only" and use the click the "Use existing connection handle", if you have set it up already (see Message# 1155867).

After being finished with the builder I then tweak this new class: I "empty" the methods AutoOpen and Init (right click the method and select "Reset to Default"), because the code I need is already contained in the parent class. I also "Reset to Default" all those properties, which I have had already set in the parent class and which have been reset by the builder. Sounds laborious, but after you get used to it is quickly done.

Two more hints: If you know this already, then please excuse me for being so verbose. The builder cannot be resized, so sometimes the space in its editboxes is very limited. If you open the class in the class designer and open the properties window, then by right clicking on the particular property you can select Zoom from the drop down popup and a nice little separate window opens, which provides more space, so you can continue editing in there. You also can copy the content of that window and edit it somewhere else, where you have more space.

For instance I use this "export possibility" also to test my SQL Select commands and other commands with the SQLEXEC() function. If you think about this a little bit, then you will find many more usages to import strings into the CA or export strings out of it via this "Zoom Window".

By this, then you can combine the strengths of the various tools and compensate for their weaknesses.
**************************************************
*-- Class:        cabasics (..\..\..\libraries\mycursoradapters.vcx)
*-- ParentClass:  cursoradapter
*-- BaseClass:    cursoradapter

Define Class cabasics As CursorAdapter

  Alias = "cabasics"
  AllowDelete = .T.
  AllowInsert = .T.
  AllowSimultaneousFetch = .T.
  AllowUpdate = .T.
  BufferModeOverride = 3
  CompareMemo = .F.
  ConflictCheckType = 1
  Datasource = ( _Screen.nSQLStHandle)
  DataSourceType = "ODBC"
  DeleteCmdDataSource = ( _Screen.nSQLStHandle)
  DeleteCmdDataSourceType = "ODBC"
  FetchAsNeeded = .T.
  FetchMemo = .F.
  FetchMemoDataSource = ( _Screen.nSQLStHandle)
  FetchMemoDataSourceType = "ODBC"
  FetchSize = 100
  Flags = 0
  Height = 22
  InsertCmdDataSource = ( _Screen.nSQLStHandle)
  InsertCmdDataSourceType = "ODBC"
  MaxRecords = -1
  Nodata = .T.
  Prepared = .T.
  RefreshCmdDataSource = ( _Screen.nSQLStHandle)
  RefreshCmdDataSourceType = "ODBC"
  SendUpdates = .T.
  UpdateCmdDataSource = ( _Screen.nSQLStHandle)
  UpdateCmdDataSourceType = "ODBC"
  UpdateType = 1
  UseCursorSchema = .T.
  UseDeDataSource = .T.  && Don't forget to set the DE's properties!!
  UseTransactions = .T.
  Width = 23
  *-- XML Metadata for customizable properties
  _MemberData = ''
  Name = "cabasics"


  Procedure BeforeUpdate
    ********************************************************************************
    *-- Chuck Urwiler: Introducing the CursorAdapter Class, CoDe, 2003, Vol.1, Iss.1
    ********************************************************************************

    Lparameters cFldState, lForce, nUpdateType, cUpdateInsertCmd, cDeleteCmd

    If nUpdateType = 1 Then
      cUpdateInsertCmd = cUpdateInsertCmd + ;
        " IF @@ROWCOUNT = 0 "+ ;
        "RAISERROR('Update Failed due to update " + ;
        "conflict.',16,1)"
    Endif
    Return .T.
  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


  Procedure Init
    *** Setup code: DO NOT REMOVE
    Local llReturn
    Do Case
      Case Not Pemstatus(This, '__VFPSetup', 5)
        This.AddProperty('__VFPSetup', 0)
      Case This.__VFPSetup = 1
        This.__VFPSetup = 2
      Case This.__VFPSetup = 2
        This.__VFPSetup = 0
        Return
    Endcase
    Set Multilocks On
    llReturn = DoDefault()
    *** End of Setup code: DO NOT REMOVE

    *** Select connection code: DO NOT REMOVE
    ***<DataSource>
    This.Datasource = _Screen.nSQLStHandle
    ***</DataSource>
    *** End of Select connection code: DO NOT REMOVE

    *** Setup code: DO NOT REMOVE
    If This.__VFPSetup = 1
      This.__VFPSetup = 2
    Endif
    Return llReturn
    *** End of Setup code: DO NOT REMOVE
  Endproc


Enddefine
*
*-- EndDefine: cabasics
**************************************************
Have a good time and enjoy!

Hans
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform