using System;
using System.Data;
using System.Data.OleDb;
using System.IO;
/// <summary>
/// Summary description for dbf
/// </summary>
public class dbf
{
private OleDbConnection conn;
private OleDbCommand cmd;
private OleDbDataReader dr;
private string sqlStr = "";
private DataSet myDataSet;
private OleDbDataAdapter myAdapter;
private int r_val;
public dbf()
{
//
// TODO: Add constructor logic here
//
}
public void oledb_conn()
{
conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\mockreal\map;Extended Properties=DBASE III;");
}
public DataSet Execute_dataset(string sqlStr)
{
oledb_conn();
conn.Open();
//sqlStr = "update G.dbf set CRIME=10 where PARCEL_NO='20'";
//Make a DataSet object
myDataSet = new DataSet();
//Using the OleDbDataAdapter execute the query
//cmd = new OleDbCommand(sqlStr,conn);
//int r_val = cmd.ExecuteNonQuery();
myAdapter = new OleDbDataAdapter(sqlStr, conn);
//Build the Update and Delete SQL Statements
//OleDbCommandBuilder myBuilder = new OleDbCommandBuilder(myAdapter);
try
{
//Fill the DataSet with the Table 'bookstock'
myAdapter.Fill(myDataSet);
conn.Close();
}
catch (Exception oEx)
{
throw (oEx);
}
return myDataSet;
}
public int Execute_command(string sqlStr)
{
oledb_conn();
conn.Open();
try
{
cmd = new OleDbCommand(sqlStr, conn);
r_val = cmd.ExecuteNonQuery();
}
catch (Exception oEx)
{
throw (oEx);
}
return r_val;
}
}This code snippet for retrive data from .dbf file using oledb.