strSql = "update sc生产制单_报表_款印绣辅图 set 列" + m.ToString() + "=@image where 生产制单号='" + a生产制单.编号 + "' ";
SqlCommand com2 = new SqlCommand(strSql, clsSql.cn);
SqlParameter sp2 = new SqlParameter("@image", SqlDbType.Image);
try
{
Stream ms2 = File.Open(strr列值, FileMode.Open, FileAccess.Read);
byte[] b2 = new byte[ms2.Length];
ms2.Read(b2, 0, b2.Length);
sp2.Value = b2;
com2.Parameters.Add(sp2);
try
{
com2.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
ms2.Dispose();
com2.Dispose();
}
catch (Exception)
{
MessageBox.Show("图片被另一个进程使用. 路径:" + strr列值.Trim());
continue;
}我的源码,怎么改进,以非独占的方式使用图片?
SqlCommand com2 = new SqlCommand(strSql, clsSql.cn);
SqlParameter sp2 = new SqlParameter("@image", SqlDbType.Image);
try
{
Stream ms2 = File.Open(strr列值, FileMode.Open, FileAccess.Read);
byte[] b2 = new byte[ms2.Length];
ms2.Read(b2, 0, b2.Length);
sp2.Value = b2;
com2.Parameters.Add(sp2);
try
{
com2.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
ms2.Dispose();
com2.Dispose();
}
catch (Exception)
{
MessageBox.Show("图片被另一个进程使用. 路径:" + strr列值.Trim());
continue;
}我的源码,怎么改进,以非独占的方式使用图片?
解决方案 »
- split如何忽略字符串最后一个空格
- c#高手请进!!!!!!!!!!!!!!!!!!!!!!
- showModalDialog返回ArrayList 数组问题
- 求 Dotfuscator 专业版 希望那位好心人把注册号拿出来共享,并提供下载地址 UP有分
- 如何让winform中datagrid的combo控件通过tab键得到焦点啊
- WinForms程序,在我的机器上编译运行没有问题,到另一台机器上就抱错,求解决办法!!!
- c#调用c++.dll文件函数!!急!!!!
- 打印时,页面设置后预览的问题
- 我想引用dll中类的函数怎么办?
- C#真的不能处理底层的功能吗?
- 求助:c# 怎么控制手机拨号上网啊?
- string 得一个小程序
这样用只读的方式异常的话
用这个吧
StreamReader sr = new StreamReader(xxxx);
FileStream _FileStream2 = new FileStream(@"C:\1.jpg", FileMode.Open, FileAccess.Read, FileShare.Read);不知道是不是你要的效果
FileStream _FileStream2 = new FileStream(@"C:\1.jpg", FileMode.Open, FileAccess.Read, FileShare.Read);不知道是不是你要的效果
sqldr.Read();
if (sqldr[0]!=DBNull.Value )
{
MemoryStream ms = new MemoryStream((byte[])sqldr["Photo"]);
pictureBox.Image = Image.FromStream(ms, true);
}
else
{
pictureBox.Image=null;
}
sqldr.Close(); 我是这样读取的
byte[] imgbyte=new byte [fs.Length];
BinaryReader br=new BinaryReader(fs);
imgbyte=br.ReadBytes(Convert.ToInt32(fs.Length));
图片转二进制