TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Atul Rokade
NA
141
44.1k
how to retrieve value in datagridview by autocomplete text
Oct 13 2016 12:11 PM
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();
}
Reply
Answers (
8
)
Getting image from database
How to export mvc webpage into PDF?