111,097
社区成员




string path = @"C:\Documents and Settings\user\My Documents\My Pictures\435.jpg";
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.ReadWrite);
long length = fs.Length;
Byte[] bt = new byte[length];
BinaryReader reader = new BinaryReader(fs);
bt = reader.ReadBytes((int)length);
string sql = "INSERT INTO camera(picture,pictureName,pictureLength,cid) VALUES(?picture,?pictureName,?pictureLength,?cid)";
MySQLCommand command2 = new MySQLCommand(sql, conn);
command2.Parameters.Add("?picture", DbType.Binary);
command2.Parameters.Add("?pictureName", DbType.String);
command2.Parameters.Add("?pictureLength", DbType.Int64);
command2.Parameters.Add("?cid", DbType.Int16);
command2.Parameters["?picture"].Value = bt;
command2.Parameters["?pictureName"].Value = "1.jpg";
command2.Parameters["?pictureLength"].Value = length;
command2.Parameters["?cid"].Value = 1;
command2.ExecuteNonQuery();