public class dbfreader {
private string _path;
private oledbconnection
_connection;
public dbfreader(string dbfpath)
{
_path = dbfpath;
checkfile();
}
public oledbdatareader getreader()
{
try
{
_connection.open();
oledbcommand command = new oledbcommand("select * from [" + _path +
‘]‘, _connection);
return
command.executereader(commandbehavior.closeconnection);
}
catch
{
return null;
throw;
}
}
public void close()
{
_connection.close();
}
public void checkfile()
{
_connection = new oledbconnection("provider=vfpoledb.1;data
source=" + _path);
try
{
_connection.open();
}
catch
{
throw new emexception(1103);
finally
_connection.close();
} }
public class dbfwriter {
private string _path;
public string tablename;
private string _createcommand;
private oledbconnection _connection;
private oledbcommand _command;
public dbfwriter(string dbfpath,
string createcommand) {
_path =
dbfpath;
_createcommand = createcommand; }
public void open()
int index =
_path.lastindexof(‘\\‘);
tablename =
_path.substring(index + 1);
_connection =
new oledbconnection("provider=vfpoledb.1;data source=" + _path.substring(0,
index));
_command = new oledbcommand("create table [" + tablename + "] " +
_createcommand, _connection);
try
_connection.open();
_command.executenonquery();
throw; }
}
public void close()
_connection.close(); }
public void appenddata(string
command) {
_command.commandtext = command;
_command.executenonquery(); }
}