C# using FoxPro - Peformance Concern

I have an application where I am constantly needing to read and write from a FoxPro databases.  The dataset can be large, but it has around 12-15 at any given time.  I am using OleDbConnection, OleDbCommand and OldDbDataReader and it is VERY slow.  Any suggestions on how to speed up the reading and inserting?

Thanks.
tgidirectAsked:
Who is Participating?
 
pcelbaConnect With a Mentor Commented:
Then you are limited by C# speed in conjunction with OLE DB data access...

To speed it up is possible. DBF is more less a flat data file with fixed data record length and some heading. You may read the DBF file as a stream. The DBF file structure is described e.g. here: http://www.dbf2002.com/dbf-file-format.html
0
 
tusharkanvindeCommented:
You need the correct indexes in place so that they can be used to optimise the queries.
0
 
pcelbaCommented:
If your dataset has 12 - 15 records then you cannot make it faster.
If your dataset has 12 - 15 thousands of records then index could help but depends how you are reading your data. Could you post some query sample?

No index can speed up inserts.

Did you compare the speed to other data source?
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
tgidirectAuthor Commented:
I meant to say 12-15 fields...Sorry.
0
 
tgidirectAuthor Commented:
Sample Code below...

OleDbCommand dbComm = new OleDbCommand("SELECT * FROM [Table];", dbConn);
OleDbDataReader dbRead = dbComm.ExecuteReader();

while (dbRead.Read())
{
     Customer customer = new Customer();
     customer.First = dbRead["First"].ToString().Trim();
     customer.Middle = dbRead["Middle"].ToString().Trim();
     customer.Last = dbRead["Last"].ToString().Trim();
     customer.Address1 = dbRead["Addr"].ToString().Trim();
     customer.Address2 = dbRead["Altaddr1"].ToString().Trim();
     customer.City = dbRead["City"].ToString().Trim();
     customer.State = dbRead["State"].ToString().Trim();
     customer.Zip = dbRead["Zip"].ToString().Trim();
     list.Add(customer);
}

dbRead.Close(); dbRead.Dispose();
dbComm.Dispose();

Thank you.
0
 
pcelbaCommented:
SELECT * FROM [Table]  is not optimizable because it retrieves all table records.

If you change it to   SELECT * FROM [Table] WHERE CustomerID = 12345   then index on CustomerID column can speed it significantly up. (Suppose thousands of records in table, of course.)

The most visible speed improvement can be achieved by rewritting the app into Visual FoxPro language.
0
 
tgidirectAuthor Commented:
I need to read everything from the file to run through code and processing handled in the C# application.
0
 
CarlWarnerCommented:
In your OLE DB connection string, add a TABLEVALIDATE=0 to the trailing parameters and see if allowing the environment to not be so strict (needlessly in most cases) gives you a boost.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.