c# - saving datagridview output as log file -index was outside bounds of array error -



c# - saving datagridview output as log file -index was outside bounds of array error -

i have datagridview displays message on messagebox after query run.at sametime want write logfile. works fine on message box of code want same info saved logfile.i tried code getting error everytime.

private void backgroundworker_import_dowork(object sender, doworkeventargs e) { //finally, loop through each row in dataview , execute insert statements against database int reccount = 0; successcount = 0; failedcount = 0; dv.rowfilter = "execute_bit in ('1')"; using(mysqlconnection connectionmysql = new mysqlconnection(connectionstringmysql)) { connectionmysql.open(); mysqlcommand commandmysql = new mysqlcommand(); commandmysql.connection = connectionmysql; foreach(datarowview rowview in dv) { reccount++; backgroundworker_import.reportprogress(reccount); commandmysql.commandtext = rowview["sql"].tostring(); seek { successcount = successcount + commandmysql.executenonquery(); } grab (exception) { failedcount++; } } } } private void backgroundworker_import_runworkercompleted(object sender, runworkercompletedeventargs e) { string[] msg = new string[]; msg[0] = "records imported: " + successcount.tostring(); msg[1] = "records failed import: " + failedcount.tostring(); msg[2] = "records excluded import (20 min grace-period): " + (tblvehicles.rows.count - successcount - failedcount).tostring(); // write log! writetologfile(msg); //progressbar1.visible = false; } * * private void writetologfile(string[] msg) { string logfilefilename = "c:/luvi/logfile.txt"; file.appendalllines(logfilefilename, msg); }

c#

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -