Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ADO VFP Databases and Tables
Message
De
19/04/2001 01:58:27
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00495992
Message ID:
00497123
Vues:
14
>I have created fox free tables in VB but not Databases with tables. Anyone have some ADO code for this?
>
>I have asked this in the VB forum, I was hoping someone in the fox community had the info.
>
>My humble thanks in advance,

Joe,
Are you asking creation or access ? If creation then I don't know if you could do that with ADO (possible with lowlevel).
For access here is a sample for free and dbc :
* Free
lcPath = 'c:\mycomplete path to free table dir"
oRecordset = CreateObject("adodb.recordset")
oConnection = CreateObject("adodb.connection")

lcConnStr = [Provider=MSDASQL.1;Persist Security Info=False;Mode=Read|Write;]+;
  [Extended Properties="DSN=Visual FoxPro Tables;UID=;SourceDB=]+;
  lcTablePath+;
  [;SourceType=DBF;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;]+;
  [Null=Yes;Deleted=Yes;"]
lcSelStr = 'select * from myTable'

With oConnection
  .Provider = "MSDASQL"
  .ConnectionString = lcConStr
  .Open
Endwith
With oRecordset
  .ActiveConnection = oConnection
  .Source = lcSelStr
  .Open
Endwith

* DBC - Little change in lcTablepath and SourceType
lcTablePath = 'c:\my complete path to DBC dir\myDatabase.dbc'
lcConnStr = [Provider=MSDASQL.1;Persist Security Info=False;Mode=Read|Write;]+;
  [Extended Properties="DSN=Visual FoxPro Database;UID=;SourceDB=]+;
  lcTablePath+;
  [;SourceType=DBC;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;]+;
  [Null=Yes;Deleted=Yes;"]


* Also you could use 'shape' in ADO which I think the only superlative option
* over native VFP
lcConStr = [Data Provider=MSDASQL;Persist Security Info=False;]+;
  [Data Source="Data Provider = MSDASQL;]+;
  [DSN=Visual FoxPro Database;UID=;SourceDB=]+lcFullDBCPath+[;]+;
  [SourceType=DBC;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;]+;
  [Deleted=Yes;"]

lcShapeStr = [  SHAPE ]+;
  [(SHAPE {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 'ANA%' } ]+;
  [	APPEND  ({select od.order_id, 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 } 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 = lcConnStr
  .Open
Endwith
With oRecordset
  .ActiveConnection = oConnection
  .Source = lcShapeStr
  .Open
Endwith
Since you use VB you know it better than me :) that if it's a flex or hflexgrid you need the oRecordset only at creation time. After then flex or hflex uses its own internal array.
IMHO if you need it for web interface then consider using VFP COM objects rather than ADO. VFP native access to tables seem much more faster than ADO. OTOH ADO is the nice way to create an XML even with multipl 'shaped' cursors.
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