c# - Fatal error encounterd when using MySqlDataReader -


i'm getting following error @ c# winforms application:

fatal error encountered during data read

i'm using mysql.data v4.0.30319.

here's code:

int catcount = 1;      while (catcount < 13) {     mysqlconnection con = new mysqlconnection("server=server;user id=user;password=password;database=db;");     con.open();     mysqldatareader rd;     string query = "select oc_newsletter_old_system.email oc_newsletter_old_system oc_newsletter_old_system.cat_uid = "  + catcount;     mysqlcommand mc = new mysqlcommand(query, con);     rd = mc.executereader();     try     {               while (rd.read())         {             string email = rd.getstring(0);             boolean insert = true;             int realcat = 0;             switch (catcount)             {                 case '1':                     filebrian += email + "\r\n";                     break;                 case '2':                     filedunamis += email + "\r\n";                     break;                 case '3':                     filefrohlich += email + "\r\n";                     break;                 case '4':                     filegaithers += email + "\r\n";                     break;                 case '5':                     filegospel7 += email + "\r\n";                     break;                 case '6':                     filelifeshop += email + "\r\n";                     realcat = 1;                     break;                 case '7':                     filemeyer += email + "\r\n";                     break;                 case '8':                     fileopwekking += email + "\r\n";                     break;                 case '9':                     filepelgrimkerken += email + "\r\n";                     realcat = 2;                     break;                 case 10:                     filepelgrimklanten += email + "\r\n";                     realcat = 2;                     break;                 case 11:                     filepelgrimpers += email + "\r\n";                     insert = false;                     break;                 case 12:                     filepelgrimscholen += email + "\r\n";                     insert = false;                     break;             }              if (insert == true)             {                     string salt = "h1bsqnp6wyxjxhf29ziuwsihg8nixe05";                 byte[] asciibytes = asciiencoding.ascii.getbytes(salt + email);                 byte[] hashedbytes = md5cryptoserviceprovider.create().computehash(asciibytes);                 string hashedstring = bitconverter.tostring(hashedbytes).replace("-", "").tolower();                 string query2 = "insert ignore `oc_ne_marketing` (`email`,`code`, `subscribed`, `store_id`) values ('" + email + "', '" + hashedstring + "', '1', '" + realcat + "')";                 mysqlconnection connection = new mysqlconnection("server=server;user id=user;password=password;database=db;");                 connection.open();                 try                 {                     mysqlcommand cmd1 = new mysqlcommand(query2, connection);                     cmd1.commandtext = query2;                     cmd1.executenonquery();                     cmd1.dispose();                 }                                 {                     connection.close();                 }             }             application.doevents();         }     }         {         rd.close();         con.close();     }      catcount++;     progressbar1.performstep();     progressbar1.refresh();     application.doevents(); } 

i'm getting error @ line:

while (rd.read()) 

the thing found out far problem closing reader , connection, far know setup right...

so guys got idea what's matter???

a2a, sake of completeness.

from here:

the workaround customize net_xxx_timeout settings. example, issue following after openning connection , before executing datareader:

var c = new mysqlcommand("set net_write_timeout=99999; set net_read_timeout=99999", con); c.executenonquery(); 

here's source mysql.data in connection class:

protected override void dispose(bool disposing) {   if (state == connectionstate.open)     close();   base.dispose(disposing); } 

which means disposing enough close (its bizarre otherwise). same holds true sqlconnection too..


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -