日期:2014-05-16 浏览次数:22422 次
List<byte> list = new List<byte>();
for (int i = 0; i < 5000; i++)
{
Random r = new Random(i);
int dd = r.Next(0, 253);
list.Add((byte)dd);
}
byte[] imageb = list.ToArray();
MySqlConnection sqlcon = new MySqlConnection("server=192.168.0.2;database=test;port=3306;User Id=root;Connect Timeout=8;password=123456");
StringBuilder strSql = new StringBuilder();
strSql.Append("insert into N(");
strSql.Append("imagexx)");
strSql.Append(" values (");
strSql.Append("@imagexx)");
MySqlCommand sqlcom = new MySqlCommand(strSql.ToString(), sqlcon);
sqlcom.Parameters.Add("@imagexx", MySqlDbType.Blob, imageb.Length).Value = imageb;
sqlcon.Open();
sqlcom.ExecuteNonQuery();
sqlcom.Dispose();
sqlcon.Close();
sqlcon.Dispose();