this a serarcing button for list on the data table but give an error please find this
this work in c# with access

DataTable tablo = new DataTable();
               
                tablo.Columns.Add("no");
                tablo.Columns.Add("urun");
                tablo.Columns.Add("model");
                tablo.Columns.Add("adet");
                tablo.Columns.Add("boyut");
                tablo.Columns.Add("aciklama");



                try
                {

                    DataRow satir;

                        satir = tablo.NewRow();
                while (oku.Read())
                {
                    
                                   // here                
                    
                    satir[0] = oku[0];
                    satir[1] = oku[1];
                    satir[2] = oku[2];
                    satir[3] = oku[3];
                    satir[4] = oku[4];
                    satir[5] = oku[5];
                    tablo.Rows.Add(satir);


                }


               
                oku.Close();
                baglan.Close();
    dataGridView1.DataSource = tablo;
    
// to here give an error
            }
            catch
            {
                MessageBox.Show(":D");
            }

Show us full code.. the connection instantiation, and its connection string.

using System;
using System.Data.OleDb;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace som
{
    public partial class ara : Form
    {
        public ara()
        {
            InitializeComponent();
        } OleDbConnection baglan = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\öztürk\Desktop\som\som\b.accdb");

        OleDbCommand veri; OleDbDataReader oku;

        string urun;
        
        

        private void button1_Click(object sender, EventArgs e)
        {
            
                baglan.Open();

                // Sorgu içinde urun isimli bir değişken kullanmışsın ancak değişkene değer atamamışsın. Sorguya null olarak giriyor. Alttaki satırı eklemen lazım
                urun = textBox1.Text;

                veri = new OleDbCommand("select urun,model,adet,boyut,aciklama from ogrenci where urun='" + urun + "';", baglan);
                oku = veri.ExecuteReader();
                
                

                DataTable tablo = new DataTable();
               
                tablo.Columns.Add("no");
                tablo.Columns.Add("urun");
                tablo.Columns.Add("model");
                tablo.Columns.Add("adet");
                tablo.Columns.Add("boyut");
                tablo.Columns.Add("aciklama");



                try
                {

                    DataRow satir;

                       
                while (oku.Read())
                {
                    
                                        textBox1.Text = oku["urun"].ToString();
                                        textBox2.Text = oku["model"].ToString();
                                        textBox3.Text = oku["adet"].ToString();
                                        textBox4.Text = oku["boyut"].ToString();
                                        textBox5.Text = oku["aciklama"].ToString();

                                        satir = tablo.NewRow();
                    
                    satir[0] = oku[0];
                    satir[1] = oku[1];
                    satir[2] = oku[2];
                    satir[3] = oku[3];
                    satir[4] = oku[4];
                    satir[5] = oku[5];
                    satir[5] = oku[5];
                    tablo.Rows.Add(satir);


                }


               
                oku.Close();
                baglan.Close();
    dataGridView1.DataSource = tablo;
    
            }
            catch
            {
                MessageBox.Show(":D");
            }
          

        }

        private void ara_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'bDataSet1.ogrenci' table. You can move, or remove it, as needed.
            this.ogrenciTableAdapter.Fill(this.bDataSet1.ogrenci);

        }

       

       
    }
}

What is the exact error message?

Maybe you need a password? If so, you can append this to your connection string:

Jet OLEDB:Database Password=password;

place

baglan.Open();

before

oku = veri.ExecuteReader();

Again: What is the exact error message?

Another idea: Is the db-File or one of its parent folders read/write protected?
Have you double-checked that the file is in the path specified?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.