Iam creating one application where medicine_name is autocomplete text, base on that selection i want to populate Expiry_Date but whenever i run the code its given me Index was outside the bounds of the array exception, retrieve code i written on dataGridView1_CellEndEdit event i dont know where is im wrong here im pasting my code and screen shots of application and table structure
private void dataGridView1_CellEndEdit_1(object sender, DataGridViewCellEventArgs e)
{
string connectionString = null;
connectionString = ConfigurationManager.ConnectionStrings["AccessConnectionString"].ConnectionString;
con.ConnectionString = connectionString;
string medicinename = Convert.ToString(dataGridView1.Rows[e.RowIndex].Cells["Medicine_name"].Value);
DateTime Expiry_Date = Convert.ToDateTime (dataGridView1.Rows[e.RowIndex].Cells["Expiry_Date"].Value);
con.Open();
cmd = new OleDbCommand("select Expiry_Date from Medicine_Available_Detail where Medicine_Name='" + medicinename + "'", con);
OleDbDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
Expiry_Date = Convert.ToDateTime (dr.GetValue(5));// exeception coming on this line
}
con.Close();
}
Madhanmohan DevarajanRank #342 · 7.3K reputationPosted Oct 13, 2016, 11:10 AM EDT
Madhanmohan DevarajanRank #342 · 7.3K reputationPosted Oct 13, 2016, 9:11 AM EDT
Madhanmohan DevarajanRank #342 · 7.3K reputationPosted Oct 13, 2016, 11:02 AM EDT
Madhanmohan DevarajanRank #342 · 7.3K reputationPosted Oct 13, 2016, 12:07 PM EDT
Atul Rokade146 reputationPosted Oct 13, 2016, 10:43 AM EDT
Atul Rokade146 reputationPosted Oct 13, 2016, 10:46 AM EDT
Atul Rokade146 reputationPosted Oct 13, 2016, 12:00 PM EDT
Atul Rokade146 reputationPosted Oct 14, 2016, 9:31 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts