Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do I get onto the VB forum -- and use ADO with VFP d
Message
De
15/10/2000 15:14:13
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00429555
Message ID:
00429596
Vues:
17
>I was trying to get onto the VB forum to post this message, but UT kept telling me 'I need to select at least on filtered forum in your profile'
>
>Anybody know how to do this.
>
>Maybe somebody here can help me
>
>In VB, I am trying to access VFP database files using ADO, can this be done.
>I was playing around in VB but had no success .
>
>Regards,
>Gerard

Gerard,
I don't know how you would select VB forum.
You can access VFP files using ADO as in this sample :
Set escape on && Handy to interrupt long listings
Clear
Local oRecordset,oConnection, strCn, strShp

_Screen.fontname = "Courier New"
_Screen.fontsize = 10
Dimension aFontStyles[4,2]
aFontStyles[1,1] = .t.
aFontStyles[2,2] = .t.
aFontStyles[3,1] = .t.
aFontStyles[3,2] = .t.

#Define TESTDATALOC C:\ddrive\TEMP\testdata.DBC

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

strCn =	[Data Provider=MSDASQL;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;"]

strShp = [  SHAPE ]+;
  [(SHAPE {select customer.cust_id, customer.Company, orders.order_id from customer ]+;
  [		inner join orders on customer.cust_id = orders.cust_id where customer.cust_id like 'A%' } ]+;
  [ APPEND  ({select od.order_id, od.unit_price * od.quantity as ExtendedPrice  ]+;
  [		from orditems as od} 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 Comp	]+;
  [   	BY cust_id ]


With oConnection
  .Provider = "MSDataShape"
  .ConnectionString = strCn
  .Open
Endwith
With oRecordset
  .ActiveConnection = oConnection
  .Source = strShp
  .Open
Endwith
oRecordset.MoveFirst

Set alte on
Set alte to check1.txt
Set alte on
ListFields("",oRecordset,0)
Set alte off
Set alte to
Modi comm check1.txt

Function ListFields
Lparameters tcSetName, toRecordSet, tnTab
Local lcRecord
SetFont(tnTab)

If toRecordSet.Recordcount > 0
  Do while !toRecordSet.EOF
    lcRecord = space(tnTab*4)
    For Each ofield In toRecordSet.Fields
      With ofield
        If type(".Value") # "O"
          lcRecord = lcRecord + transform(.Value) + space(4)
        Else   && Another recordset is encountered
          ?
          ? lcRecord
          lcRecord = ""
          loRecordSet = ofield.Value
          ListFields(.Name, loRecordSet, tnTab + 1) && Recurse with new set
        Endif
      Endwith
    Endfor
    If !empty(lcRecord)
      ? lcRecord
    Endif
    SetFont(tnTab)
    toRecordSet.MoveNext
  Enddo
Endif

Function SetFont
Lparameters tnTab
_Screen.fontbold = aFontStyles[tnTab%4+1,1]
_Screen.fontitalic = aFontStyles[tnTab%4+1,2]
However if you're going to bind an Activex FlexGrid or HierarchialFlexGrid datasource I suggest you use MS Datacontrol instead of Adodb.connection (might be possible but I coldn't succeed).
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform