Bug #9859 Error occured during saving a large file into database
Submitted: 12 Apr 2005 21:41 Modified: 23 Jun 2005 8:46
Reporter: [ name withheld ] Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:1.0.4 OS:Windows (Win XP2 Pro SP2)
Assigned to: CPU Architecture:Any

[12 Apr 2005 21:41] [ name withheld ]
Description:
I have got the following problem with the MySQL Connector 1.0.4:
When I want to save in database (in the blob field) graphic file bigger than 1 MB, I recieve following exception:
„System.IO.IOException Unable to write data to the transport connection”
When the size of a file is, for example, 800 kb everything seems to be alright.

The environment: Win XP SP2, NET Framework 1.1 SP1

How to repeat:
public void SaveImgToDB(string imgName,string filename)
		{
//cmd-MySqlCommand
			System.IO.FileStream fs=new FileStream(filename,FileMode.Open,FileAccess.Read);
			byte [] imgData=new byte[fs.Length];
			fs.Read(imgData,0,imgData.Length);
			fs.Close();		cmd.Parameters.Add("img_desc",MySQL.MySqlDbType.VarChar).Value=imgName;	cmd.Parameters.Add("img",MySQL.MySqlDbType.LongBlob).Value=imgData;
			cmd.CommandText="INSERT INTO images (img_description,image) VALUES (?img_desc,?img)";
cmd.ExecuteNonQuery();
}
[16 May 2005 10:05] Vasily Kishkin
Could you please provide value of your max_allowed_packet ? When I tested this max_allowed_packet was 16M and I did't got any exceptions.
[19 May 2005 10:08] Jod75
I have the same problem.  My max_allowed_packet was not set in my ini file. Guess the system would then use the default.  I added the parameter and set it to 16M, as suggested.  Now data up to 16M is saved in a blob field but bigger are not and get the same error message - "Unable to write data to the transport connection."  It seems that data is passed in one packet only!!
[23 May 2005 8:46] Vasily Kishkin
Probably this URL will help you :
http://dev.mysql.com/doc/mysql/en/gone-away.html
[23 Jun 2005 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".