c# 图片存取问题 还是使用Command对象,用存储过程单独更新大对象列吧。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 数据库里面这个字段的数据类型是是什么啊?如果是SQLServer的话,应该用Image类型 1. 你用这样的方法的话,要存储的文件不能太大的, 太大的话,你想一想你要一下全读取内存里,怎么可行.2 .出错提示:将截断二进制或字符串 你的数据表中该列是什么类型的,?如果超出8000字节,要用varbinary(max)的.3. 文件大的话,要用分段保存,即一次保存一小段如8K到数据库中,读一段写入一段.网上有很多这样的例子. 截断是大小问题FileStream fs = new FileStream(@"D:\a.jpg", FileMode.Open,FileAccess.Read); Byte[] btye2 = new byte[fs.Length]; fs.Read(btye2 , 0, Convert.ToInt32(fs.Length)); fs.Close(); using (SqlConnection conn = new SqlConnection(sqlconnstr)) { conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "insert into Photo(imgfile) values(@imgfile)"; SqlParameter par = new SqlParameter("@imgfile", SqlDbType.Image); par.Value = bt; cmd.Parameters.Add(par); int t=(int)(cmd.ExecuteNonQuery()); conn.Close(); } SqlConnection conn=new SqlConnection() conn.ConnectionString="Data Source=localhost;Database=test;User Id=sa;Pwd=sa"; string strSql=""; SqlCommand cmd=new SqlCommand() reader.Read(); Response.ContentType="application/octet-stream"; Response.BinaryWrite((Byte[])reader["FImage"]); Response.End(); reader.Close(); 通过存储过程更新数据库中图片,图片太大消耗内存。要先清空那个原有的image,再插入 数据查询时提示标准表达式中数据类型不匹配 gridview findcontrol 使用无法找到控件 请教排查服务器繁忙和死循环的方法,或者是监控cpu占用的方法 路径问题 IIS里的两个会话超时设置,到底哪个起作用?马勒戈壁的。 熟悉vb.net的C#高手请进 请问PetShop是如何键入断点调试的 求助! 在线等待!关于水晶报表的数据显示问题!请各位帮忙! 求助!!gridview选择行,如何在另一个gridview中添加 css 如何控制只div的样式啊 如何在web页面做一个查询控件
2 .出错提示:将截断二进制或字符串 你的数据表中该列是什么类型的,?如果超出8000字节,要用varbinary(max)的.
3. 文件大的话,要用分段保存,即一次保存一小段如8K到数据库中,读一段写入一段.网上有很多这样的例子.
FileStream fs = new FileStream(@"D:\a.jpg", FileMode.Open,FileAccess.Read);
Byte[] btye2 = new byte[fs.Length];
fs.Read(btye2 , 0, Convert.ToInt32(fs.Length));
fs.Close();
using (SqlConnection conn = new SqlConnection(sqlconnstr))
{
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "insert into Photo(imgfile) values(@imgfile)";
SqlParameter par = new SqlParameter("@imgfile", SqlDbType.Image);
par.Value = bt;
cmd.Parameters.Add(par);
int t=(int)(cmd.ExecuteNonQuery());
conn.Close();
} SqlConnection conn=new SqlConnection()
conn.ConnectionString="Data Source=localhost;Database=test;User Id=sa;Pwd=sa";
string strSql="";
SqlCommand cmd=new SqlCommand()
reader.Read();
Response.ContentType="application/octet-stream";
Response.BinaryWrite((Byte[])reader["FImage"]);
Response.End();
reader.Close();
要先清空那个原有的image,再插入