C# connect to dbf

using System.Data.OleDb;

...

            OleDbConnection _connection = new OleDbConnection();
            StringBuilder ConnectionString = new StringBuilder("");
            ConnectionString.Append(@"Provider=Microsoft.Jet.OLEDB.4.0;");
            ConnectionString.Append(@"Extended Properties=Paradox 5.x;");
            ConnectionString.Append(@"Data Source=D:\dbf;");
            _connection.ConnectionString = ConnectionString.ToString();
            try { _connection.Open(); }
            catch (Exception _e) { MessageBox.Show("Error openning database! " + _e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
            OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM kadr.db;", _connection);
            DataSet dsRetrievedData = new DataSet();
            da.Fill(dsRetrievedData);
            this.dataGridView1.DataSource = dsRetrievedData;
            this.dataGridView1.DataMember = dsRetrievedData.Tables[0].TableName;

2 comments:

  1. а как выбрать поле по условию типа where != 'kaka'

    ReplyDelete
    Replies
    1. ну вон в запросе где select и дописать where

      Delete