2
Contributors
2
Replies
6
Views
7 Years
Discussion Span
Last Post by kayfar
0

Hi Kayfar,

Try this code.

private void button1_Click(object sender, EventArgs e)
        {
            OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Northwind.mdb");
            conn.Open();
            String sqlText = "SELECT * FROM Customers WHERE CompanyName LIKE '%" + textBox1.Text + "%'";
            OleDbDataAdapter adapter = new OleDbDataAdapter(sqlText, conn);
            DataTable dtCust = new DataTable();
            adapter.Fill(dtCust);
            conn.Close();
            dataGridView1.DataSource = dtCust;
        }

Also refer this link.

Microsoft Office Access 2007 - Like Operator

0

sorry..i'm new in c#..i got this error..

Line 27:         OleDbDataAdapter adapter = new OleDbDataAdapter(sqlText, conn);
Line 28:         DataTable dtCust = new DataTable();
Line 29:         adapter.Fill(dnis);
Line 30:         conn.Close();
Line 31:         dataGridView1.DataSource = dnis;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.