Home » Performance » MySQL » Continous for loop query generates connection terminated unexpectedly?
Continous for loop query generates connection terminated unexpectedly? [message #2492] Sat, 12 January 2008 22:33
newtomysql  is currently offline newtomysql
Messages: 30
Registered: February 2007
Member
Dear All,
I have an application where I have one central server and many other local servers. So from each one of the local or the central server I can actually move a number serials. So then in the same time I have cental table which keeps a record of each serial and where it is active now I mean in which of the servers. So the problem comes when I move a big number (around 600) of serial say from server A to server B. Then in server B I will receive all the transfered serials and run a for loop to check each of the serial agains the central table which is kept in the central server. The problem is when serial number is small is ok but when it gets big I get the error connection terminated unexpectedly? I know is due to heave query so is there any solution to it ? Below is a snippet of my code.

for (int j = 0; j < gridReceiveSerial.RowCount; j++)
{
globalConnectionCentral1 myConnect1 = null;
MySqlDataReader myReader1 = null;
int serialExist = 0;
try
{
myConnect1 = new globalConnectionCentral1();
myConnect1.command.CommandText = "Select " +
"tblCentral.serialID " +
"From tblCentral" +
"Where tblCentral.serialStatus ='y' And " +
"tblCentral.serial='" + this.gridReceiveSerial[8, j].Value.ToString() + "'";

myReader1 = myConnect1.command.ExecuteReader();
if (myReader1.HasRows == true)
{
serialExist = 1;
MessageBox.Show("this.gridReceiveSerial[8, j].Value.ToString() + " " + "Exist");
}
else
{
}
}
catch (MySql.Data.MySqlClient.MySqlException ex)
{
MessageBox.Show("Connection Error" + ex.Message);
}

finally
{
myReader1.Close();
myConnect1.command.Dispose();
myConnect1.connection1.Close();
}
}
Previous Topic:Obtaining PK of Aggregate (MAX/MIN) Function Value
Next Topic:Ghost Tables
Goto Forum:
  


Current Time: Thu Jul 9 21:19:10 EDT 2009

Total time taken to generate the page: 0.01870 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7.
Copyright ©2001-2007 FUD Forum Bulletin Board Software

MySQL is a trademark of Sun Microsystems.
InnoDB is a trademark of Oracle Corp.

Percona Performance Forums are a service of Percona, Inc.
Not affiliated with Sun Microsystems or Oracle Corp.