Visual Studio C# datagridview to database -
this question has answer here: what nullreferenceexception, , how fix it? 33 answers i'm trying save data datagridview database . keep on getting nullreferenceexception: object reference not set instance of object try { foreach (datagridviewrow row in datagridview2.rows) { using ( conn = new sqlconnection(constring)) { using (sqlcommand cmd = new sqlcommand("insert tbl_students_marks values(@student, @t1, @t2, @t3, @t4)", conn)) { cmd.parameters.addwithvalue("@student", (row.cells["student number"].value).tostring()); cmd.parameters.addwithvalue("@t1", row.cells["test 1"].value); cmd.parameters.addwithvalue("@t2", row.cells["test 2"].value); cmd.param...