Re: Cannot set CDX index on DBF file from C#



"Don K" <don@xxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1137800771.484098.118920@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Hi Don,

> I am using .NET framework 2.0 to open Foxpro DBF files. I have
> successfully opened DBF files from C# using vfpoleddb driver (VFP 9.0)
> and SQL SELECT statements.
>
> The problem is that while the CDX index file is being opened as part of
> the connection / command process, none of the actual indexes (ie TAGs)
> within the CDX file are being selected, so when I run a select SQL
> against the DBF file which has 1 million plus records it is slow
> because no index is in use. ....

> So its not so much a question of "cannot" set an index, rather "don't
> know how" to set an index from C#.

As you may know, the FoxPro Index command requires exclusive use of the
table. The Index command is not supported via ODBC or OLE DB. You can,
however, set a PrimaryKey index via the Alter Table command.

> How do I know the CDX file is being opened? ......

The FoxPro data engine takes care of automatically opening CDX index files
when a table is opened. What you're really asking is how do you know if your
SQL commands are taking advantage of FoxPro's Rushmore index technology. The
Rushmore technology kicks in to optimize the Where clause of an SQL
statement whether the table's order is set to that index or not. For example
....Where CustomerID = 5 And CustomerName = "Smith" would run best if there
were indexes on both CustomerID and CustomerName. (Obviously you can't set
the index to both orders at once.)

> ....Does anyone know how to do "SET INDEX TO ORDER 1" in C#
> using OleDbConnection and OleDbCommand objects, or some other technique
> which would achieve the same end?

As above, you don't kneed Set Index To at all. What you need to do is make
sure the expressions in the Where clause of your SQL statements. What are
the expressions in your Where clause and do you know what the index
expressions are on your table?

One more thing - OLE DB adds another level of complexity to data retrieval,
so it's never going to be as fast as native FoxPro data retrieval. I've seen
newsgroup posts complaining about extreme slowness and never seen a good
solution to the problem.

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden@xxxxxxx www.cindywinegarden.com



.



Relevant Pages

  • Re: using Select SQL syntax and performance issues
    ... You could use the CREATE CURSOR command to make the cursor and then the ... APPEND FROM command to populate the empty cursor. ... Microsoft FoxPro Technical Support ... I'm new to foxpro but have a VB and sql server background. ...
    (microsoft.public.fox.helpwanted)
  • System.InvalidOperationException when attempting to add a record
    ... I am working on a VB.NET application that needs to add records to a FoxPro ... populate a DataRow and add it to the dataset. ... Standard stuff I've done many times with SQL Server and Access databases. ... command to specify the index to use. ...
    (microsoft.public.data.ado)
  • System.InvalidOperationException when attempting to add record
    ... I am working on a VB.NET application that needs to add records to a FoxPro ... populate a DataRow and add it to the dataset. ... Standard stuff I've done many times with SQL Server and Access databases. ... command to specify the index to use. ...
    (microsoft.public.data.oledb)
  • How to do certain task in SQL?
    ... I come from a Foxpro/dBase background (almost 20 yrs of DBF files) and ... I am not sure how to do certain tasks in SQL. ... Move to the last record in a table (in xBase, ... command. ...
    (microsoft.public.sqlserver.msde)
  • Re: using Select SQL syntax and performance issues
    ... I'm new to foxpro but have a VB and sql server background. ... > statement as I'm updating all records. ... any sql command I give is very slow. ...
    (microsoft.public.fox.helpwanted)