mysql-C# MysQL用longblob字段存入二进制文件
楼主想把zip文件存到mysql数据库中,是用C#开发。但是在插入过程中报错了,代码如下:
byte[] bytes = null;
bytes = File.ReadAllBytes(@"E:\MySqlTest\MySqlTest\MySqlTest.zip");
MySql.Data.MySqlClient.MySqlConnection conn = SqlUtil.GetConn();
MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand();
cmd.CommandText = "insert into model (Model_ID, File) values(@ID, @ParaBlob)";
cmd.Parameters.Add("@ID", MySql.Data.MySqlClient.MySqlDbType.Int32);
cmd.Parameters.Add("@ParaBlob", MySql.Data.MySqlClient.MySqlDbType.LongBlob);
cmd.Parameters[0].Value = 15; cmd.Parameters[1].Value = bytes; cmd.Connection = conn; int affectedrows = cmd.ExecuteNonQuery();
插入时报错如下:
[img=http://img.bbs.csdn.net/upload/201505/29/1432865161_567708.png][/img]
请问我的sql语句插入时有什么问题吗多谢各位啦!
上一篇: css中行内元素和块级元素的区别介绍