Collins Aigbekhai

Collins Aigbekhai

  • NA
  • 171
  • 504

Datagridview not able to retrieve record

Aug 24 2018 3:36 AM
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 

Answers (6)