When am trying to display data to datagridview from database, only first row inserted properly
- 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.

Jignesh KumarRank #91 · 22.9K reputationPosted Jun 6, 2019, 8:40 PM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Jun 6, 2019, 5:57 AM EDT
Meena S44 reputationPosted Jun 6, 2019, 8:11 AM EDT
Gajendra JangidRank #157 · 14.9K reputationPosted Jun 6, 2019, 8:10 PM EDT
Meena S44 reputationPosted Jun 6, 2019, 8:50 PM EDT
Meena S44 reputationPosted Jun 6, 2019, 8:53 PM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Jun 6, 2019, 9:23 PM EDT
Jignesh KumarRank #91 · 22.9K reputationPosted Jun 6, 2019, 11:49 PM EDT
Amit MohantyRank #112 · 20K reputationPosted Jun 27, 2019, 3:33 AM EDT