Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
4
Reply
How to fill datagridview row by row in c# using barcode
Naeem Khan
Jul 20 2015 4:23 AM
1.3k
Reply
Hi,
I have a windows application developed in c#.
I have datagridview with three columns in it.
I will be scanning barcode in the text box.After scanning a particular barcode, i need to query the database and fill the barcodes info in the datagridview columns of the current row.
Like wise after scanning each barcode i need to fill the particular row like above.
i used this kind of code but its not working ..
try
{
MySqlConnection con = new MySqlConnection(StartUp.database);
con.Open();
MySqlCommand cmd = new MySqlCommand("select Accession_no,Title_in_full from t_book_details where Accession_no ='" + txt_accession_no.Text + "'", con);
MySqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
dr.Read();
gv_show_details.Rows[0].Cells[0].Value = dr[0].ToString();
gv_show_details.Rows[0].Cells[1].Value = dr[1].ToString();
gv_show_details.Rows.Add(dr);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
please give me idea where i m doing mistakes..
thanks in advance
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
4
)
Next Recommended Forum
To copy files from one location to shared location using C#
Merging several text files into a text with order