I can not retireve record to row in datagridview, using cell_leave event and using the first cell as index to retrieve from database the code is as follows:
private void dgv_CellLeave(object sender, DataGridViewCellEventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=Me; Database=Services;Integrated Security=true");
string str = ("SELECT Code,Category,ItemColor,Price FROM Item WHERE Code='" +col0+ "'");
SqlCommand cmd = new SqlCommand(str, con);
con.Open();
DataTable table = new DataTable();
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
da.Fill(table);
dgv.DataSource = table;
}
}
Please can someone help me?
the image

Jignesh KumarRank #91 · 22.9K reputationPosted Aug 23, 2018, 11:48 PM EDT
Gaurav RajRank #2,919 · 493 reputationPosted Aug 24, 2018, 12:20 AM EDT
Jignesh KumarRank #91 · 22.9K reputationPosted Aug 24, 2018, 6:19 PM EDT
Collins Aigbekhai131 reputationPosted Aug 29, 2018, 2:08 AM EDT
Collins Aigbekhai131 reputationPosted Aug 29, 2018, 2:09 AM EDT
Jignesh KumarRank #91 · 22.9K reputationPosted Aug 29, 2018, 7:21 AM EDT