c# - Visual Studio 2010 Ignoring All query Errors? -
i using visual studio 2010 , asp.net c# language. try read excel sheet insert information microsoft sql database, found problem ignoring error in query statement.
for (int = 0; < objdatasetdto.tables[0].rows.count; i++) { start_time = convert.todatetime(objdatasetdto.tables[0].rows[i]["start"].tostring()); end_time = convert.todatetime(objdatasetdto.tables[0].rows[i]["end"].tostring()); if (objdatasetdto.tables[0].rows[i]["lecture_day"].tostring().equals("1")) { try { query = "insert [m].[lecture]([dd],[start_time],[end_time],[week_no],[sec_no], [room_no],[building_no]) "+ values('" + calendar1.selecteddate.toshortdatestring() + "','" + start_time.toshorttimestring() + "','" + end_time.toshorttimestring() + "','1','" + objdatasetdto.tables[0].rows[i]["section_no"].tostring() + "','" + objdatasetdto.tables[0].rows[i]["room_no"].tostring() + "','" + objdatasetdto.tables[0].rows[i]["building_no"].tostring() + "');"; ifexist = new sqlcommand(query, cnn); } catch (exception ex) { response.write(ex); } }//end if }// end loop
i wrote [dd] column instead of [date] test if detect error or not. ignores them completely.
how can solve problem.
you don't appear executing sqlcommand. try adding:
ifexist.executescalar();
Comments
Post a Comment