Re: Cannot set CDX index on DBF file from C#
- From: "Cindy Winegarden" <cindy_winegarden@xxxxxxx>
- Date: Sat, 21 Jan 2006 17:11:16 -0500
"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
.
- Follow-Ups:
- Re: Cannot set CDX index on DBF file from C#
- From: Don K
- Re: Cannot set CDX index on DBF file from C#
- References:
- Cannot set CDX index on DBF file from C#
- From: Don K
- Cannot set CDX index on DBF file from C#
- Prev by Date: Re: Whene generating instalation disks...
- Next by Date: Re: Problem with pseudo-graphic
- Previous by thread: Cannot set CDX index on DBF file from C#
- Next by thread: Re: Cannot set CDX index on DBF file from C#
- Index(es):
Relevant Pages
|