i use the access and find product but if there is many same product name how can ı list these
please write for access database in c# my normaly codes are below

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();



            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();




            }


            oku.Close();
            baglan.Close();

Use a datagrid, a repeater or possibly a literal control dependng on how you want to display the results (and whether this is for a web page or form application). Catch your results from the database in a dataTable via a dataAdapter and link that to your chosen output control.

OleDbDataAdapter da = new OleDbDataAdapter(veri);
DataTable dt = new DataTable();
da.Fill(dt); // load results into the dataTable

Then, depending on your chosen display method, use the dataTable to show the results on page.

thanks but where we fix this doesnt work

Why not? Explain your situation and we might be able to help you better.

the error message there is already exist didnt close file

these codes are below

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();

                 OleDbDataAdapter da = new OleDbDataAdapter(veri); DataTable dt = new DataTable(); da.Fill(dt); // load results into the dataTableOleDbDataAdapter da = new OleDbDataAdapter(veri);







                try
                {




                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();




                }



                oku.Close();
                baglan.Close();

            }
            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);

        }




    }
}

use "distinct" on your query

He wants to list the products not select just one so DISTINCT won't help.
The problem is with your dataAdapter.

OleDbDataAdapter da = new OleDbDataAdapter(veri);
 DataTable dt = new DataTable();
 da.Fill(dt); // attempt to open an already open connection.

You have already opened the connection with baglan.Open(). da.Fill() then tries to do the same thing but can't because the connection is already open.
You need to decide if you want to use the reader or the dataTable, at the moment you have both and they're just getting in each others way.
Your while(oku.Read()) code makes no sense either. If more than one record is returned the textboxes will simply display the last one in the reader (all records will populate the textboxes but will be instantly overwritten by the next one).

what must ı do on this can you write all off codes for me please
ım written again

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

namespace STOK
{
    public partial class araa : Form
    {
        public araa()
        {
            InitializeComponent();
        }
        OleDbConnection baglan = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\öztürk\Desktop\STOK1\program.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 = comboBox1.Text;

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



            while (oku.Read())
            {

                comboBox1.Items.Add(oku["urun"].ToString());

              textBox2.Text = oku["model"].ToString();
                textBox3.Text = oku["sayi"].ToString();
                textBox4.Text = oku["boyut"].ToString();
                textBox5.Text = oku["aciklama"].ToString();




            }


            oku.Close();
            baglan.Close();




    }

        private void araa_Load(object sender, EventArgs e)
        {
            comboBox1.Items.Add("KANEPE");
            comboBox1.Items.Add("OTURMA GRUBU");
            comboBox1.Items.Add("YATAK ODASI");
            comboBox1.Items.Add("YEMEK ODASI");
            comboBox1.Items.Add("MASA");
            comboBox1.Items.Add("SANDALYE");
            comboBox1.Items.Add("YATAK");
            comboBox1.Items.Add("YASTIK");
            comboBox1.Items.Add("YORGAN");
            comboBox1.Items.Add("UYKU SETİ");
            comboBox1.Items.Add("HALI");
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }


        }
    }
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.