数据库二进制流读取和写入的问题 我取出来的时候byte数组与数据库里面的一样,只不过sql数据库里面的是十六进制,取出来的是二进制 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我把取的代码贴出来SqlConnection conn = new SqlConnection("Data Source=7VPNEWKF451EK4E;Initial Catalog=test;Integrated Security=True"); conn.Open(); SqlCommand scmd = null; string sql = "select img from t_img where id='2013-12-30 8:51:23'"; scmd = new SqlCommand(sql, conn); byte[] by = (byte[])scmd.ExecuteScalar(); FileStream fs = new FileStream("D://2.jpg", FileMode.Create); BinaryWriter bw = new BinaryWriter(fs); bw.Write(by); bw.Close(); conn.Close(); //关闭资源 c#遍历控件的问题 c# 中像excel中插入图表 先在Datagridview里显示添加的数据,然后再提交到数据库中。 C# string 类型问题. 想做一个1秒刷新一次表记录内容的WEB程序,什么方式好呢? 水晶报表打印时让行随字数的增多自动加高,并且想用空行填充空白的页面。 物理表与映射表之间的冲突 各位大哥救我!C#下开发PDA的问题 Win7旗舰版 VS2010 TF31003 新人求一个问题 不知道是优化了哪些服务,导致Visual Studio2005一遇到调试错误就自动关闭调试,有没有朋友能解决呢? 制作类似于foxmail的电子邮件客户端【功能复杂一些那种!
conn.Open();
SqlCommand scmd = null;
string sql = "select img from t_img where id='2013-12-30 8:51:23'";
scmd = new SqlCommand(sql, conn);
byte[] by = (byte[])scmd.ExecuteScalar();
FileStream fs = new FileStream("D://2.jpg", FileMode.Create);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(by);
bw.Close();
conn.Close(); //关闭资源