When am trying to display data to datagridview from database, only first row inserted properly
please find the below code. please correct the below code
- public void filldata(String bno)
- {
- textBox1.Text = bno;
- OleDbConnection con = new OleDbConnection(@"Provider=SQLOLEDB;Data Source=DESKTOP\SQLEXPRESS;User ID=sa; Password = REGENT; Initial Catalog=Meena; Integrated secutity=SSPI");
- con.Open();
- OleDbCommand cmd = new OleDbCommand(("Select * from data1 where Sno = '" +bno +"'"), con);
- OleDbDataAdapter da = new OleDbDataAdapter();
- da.SelectCommand = cmd;
- DataTable dt = new DataTable();
- da.Fill(dt);
- dataGridView1.AutoGenerateColumns = false;
- dataGridView1.DataSource = dt;
- dataGridView1.Columns[1].DataPropertyName = "Itemcode";
- dataGridView1.Columns[2].DataPropertyName = "Description";
- dataGridView1.Columns[3].DataPropertyName = "Uom";
- dataGridView1.Columns[4].DataPropertyName = "Qunatity";
- dataGridView1.Columns[5].DataPropertyName = "Rate";
- dataGridView1.Columns[6].DataPropertyName = "Amount";
- con.Close();
- }
In the above picture, three fields not filled in datagrid. How to resolve this issue.