Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ADO an setting relationships
Message
De
07/05/2001 04:05:40
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
06/05/2001 16:40:56
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Divers
Thread ID:
00504033
Message ID:
00504087
Vues:
12
>Using ADO in Fox, can you access tables from SQL server and set a relation ship on the recordset the same as you can in foxpro? Ex: You ahe a form tahe has a header section for the one relationship and a grid that shows the meny relationship. As you know, in fox when you scroll through the one relationships you could see four associated items in the grid displaying the many.
> This is what i would like to do!!!

William,
Assuming you ask this for viewing ADO has an option to 'shape' a recordset. With shaping there are pointer fields which points to child sets. Using this kind of recordset with an activex MSHFlexgrid (hierarchical flex grid) you can show data in a treeview fashion.
oForm = createobject('myForm')
oForm.Show
Read events

Define CLASS myForm AS form
  Top = 0
  Left = 0
  Height = 450
  Width = 750
  DoCreate = .T.
  Caption = "HFlex Sample"
  Name = "Form1"

  Add OBJECT hflex AS olecontrol WITH ;
    Top = 0, ;
    Left = 0, ;
    Height = 420, ;
    Width = 750, ;
    Name = "Hflex", ;
    OleClass = "MSHierarchicalFlexGridLib.MSHFlexGrid"

  Procedure Init
    #Define TESTDATALOC C:\ddrive\TEMP\testdata.DBC
    Local oRecordset,oConnection, strCn, strShp

    lcSel1 = [ select customer.cust_id, ]+;
      [   customer.Company,]+;
      [   orders.order_id,]+;
      [   orders.Order_date ]+;
      [ from customer ]+;
      [  inner join orders on customer.cust_id = orders.cust_id ]+;
      [ where customer.cust_id like 'A%' ]

    lcSel2 = [ select od.order_id, od.line_no, ]+;
      [   products.prod_name, ]+;
      [   products.no_in_unit as 'Packaging', ]+;
      [   od.unit_price, ]+;
      [   od.Quantity, ]+;
      [   od.unit_price * od.quantity as ExtendedPrice ]+;
      [ from orditems as od ]+;
      [  inner join products on od.product_id = products.product_id ]

    strShp = [  SHAPE ]+;
      [(SHAPE {]+lcSel1+[ } as rs1 ]+;
      [	APPEND  ({]+lcSel2+[ } AS rsDetails RELATE order_id TO order_id),  ]+;
      [ SUM(rsDetails.ExtendedPrice) AS OrderTotal, ]+;
      [ ANY(rsDetails.order_id)) AS rsOrders ]+;
      [COMPUTE  rsOrders, ]+;
      [SUM(rsOrders.OrderTotal) AS CustTotal, ]+;
      [ANY(rsOrders.Company) AS Cmpny	]+;
      [   BY cust_id ]

    strCn =	[Provider=MSDataShape.1;Persist Security Info=False;]+;
      [Data Source="Data Provider = MSDASQL;]+;
      [DSN=Visual FoxPro Database;UID=;SourceDB=TESTDATALOC;]+;
      [SourceType=DBC;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;]+;
      [Deleted=Yes;";Data Provider=MSDASQL ]

    oRecordset = CreateObject("adodb.recordset")
    oConnection = CreateObject("adodb.connection")

    With oConnection
      .Provider = "MSDataShape"
      .ConnectionString = strCn
      .Open
    Endwith
    With oRecordset
      .ActiveConnection = oConnection
      .Source = strShp
      .Open
    Endwith
    With this.hflex
      .FixedCols = 0
      .AllowUserResizing = 1 && Allow col sizing
      .Datasource = oRecordset
      .Mergecells = 3
      .GridColorBand(0) = rgb(255,0,0) && Play with gridline coloring
      .GridColorBand(1) = rgb(0,0,255)
      .GridColorBand(2) = rgb(0,255,0)
      .ColPosition(2,0) = 0 && Change col ordering
      .ColPosition(2,0) = 1
      .ColPosition(2,1) = 0
      .ColWidth(1,1) = 0 && Make some cols invisible
      .ColWidth(2,1) = 0
      .ColWidth(5,1) = 0
      .ColWidth(0,2) = 0
    Endwith
  Endproc

  Procedure queryunload
    Clear events
  Endproc

Enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform