i am having an error to a code that i was practicing online, i actually copy codes from someone to practice and see the output | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

i am having an error to a code that i was practicing online, i actually copy codes from someone to practice and see the output

here is the code public static void LoadData(string qry, DataGridView gv, ListBox lb) { //serial no in gridview gv. CellFormatting += new DataGridViewCellFormattingEventHandler(gv_CellFormatting); try { SqlCommand cmd = new SqlCommand(qry, con); cmd. CommandType = CommandType. Text SqlDataAdapter sda = new SqlDataAdapter(cmd) ; DataTable dt = new DataTable() ; da. Fill(dt); for(int i = 0; i < lb. Items. Count; i++) { string colNam1 = ((DataGridView) lb. Items[i].ToString() } gv. DataSource = dt; } catch (Exception ex) { MessageBox. Show(ex.ToString()) ; con. Close() ; } } i just copy the code to someone but while watching it they didn't encounter error on that part but I do so idk what to do should i link something? thank u for help :)

9th Jul 2023, 1:18 PM
mira
mira - avatar
4 Answers
+ 2
mira There are a few syntax errors in the code.Here are modified versions See this thread and learn what is your mistake.. https://code.sololearn.com/c7kcE6bINn3t/?ref=app
9th Jul 2023, 2:56 PM
Darpan kesharwani🇮🇳[Inactive📚]
Darpan kesharwani🇮🇳[Inactive📚] - avatar
+ 1
What programming language is this? I can only understand python,c++,is,html
9th Jul 2023, 1:35 PM
Aquarius
Aquarius - avatar
0
c# in visual studio
9th Jul 2023, 1:40 PM
mira
mira - avatar
0
Darpan kesharwani thank u very much for the help i really appreciate it :)
9th Jul 2023, 4:59 PM
mira
mira - avatar