DBF

  • Thread starter Klaus Kaiser Apolinário
  • Start date
K

Klaus Kaiser Apolinário

Guys,
I have a DBF ( :-S ) pseud-database here, and I need to access this dbf with
C#, how I can make this???

Klaus Kaiser Apolinário
COL
 
I

Ignacio Machin

Hi Klaus,

I had a very hard time with some dbf from foxpro 2.5 ! , the thing is that
you can read them without problem, either using OleDB or ODBC, the real
problem is writting on them sometimes I got errors, at the end I did a mix
solution, to some tables I write it from C# to others I create a prg file
and use the fox.exe to execute the script :(

Here is the code I'm using now, I use OleDB , so you need the vfpoledb.dll
its come with any installation of VFP
void ExecuteQuery( string DataSource, string Query)
{
string connString;
OleDbConnection conn;
OleDbCommand command;
try
{
connString = "Provider=VFPOLEDB.1;Data Source="+ DataSource + ";";
conn = new OleDbConnection( connString);
conn.Open();
command = new OleDbCommand();
command.Connection = conn;
command.CommandText = Query;
command.ExecuteNonQuery();
conn.Close();
}
catch(Exception e)
{
}
}

This is how I read the table:
void ReadTable( DataSet data, string sourceFile, string tablename)
{
try
{
string connString;
OleDbConnection conn;
OleDbDataAdapter adapter;

connString = "Provider=VFPOLEDB.1;Data Source="+ sourceFile + ";";
conn = new OleDbConnection( connString);
conn.Open();
adapter = new OleDbDataAdapter( "select * from " +
TableName(sourceFile), conn);
adapter.Fill( data, tablename);
conn.Close();
adapter = null;
}
catch(Exception e)
{
}

}


Hope this help,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top