哪位高手有C#中用数据库存储图象的源程序例子,跪求!!! 哪位高手有C#中用数据库存储图象的源程序例子,跪求!!!急用呀,另外哪位知道哪里有《C#实用编程百例》和《精通C#数据库开发》的电子书下载呀 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 找了找~没有......但有C#的其它的电子书~ASP.NET高级编程.pdfASP.NET深入编程中文教程(PDF).rarC# Language Specification.docC#参考大全.pdfC#基本书写规范技术文档.rarC#入门经典.rarMicrosoft .NET程序设计技术内幕.rarwindows应用高级编程-C#编程篇.pdf......有C#中用数据库存储图象的源程序例子,打包用QQ传给你吧~ 要的话请Q270417857~ try { Stream file; file = File.OpenRead(".\\jj.jpg"); BinaryReader sr = new BinaryReader(file); int n = (int)file.Length; //Console.Write(sr.ReadBytes(n).ToString()); byte[] buf = new byte[n]; buf = sr.ReadBytes(n); sr.Close(); string connstr = "server=rd-yb;database=wwzy;uid=sa;pwd=mps"; SqlConnection connection = new SqlConnection(connstr); string strSQL = "insert into nn(body)values(@buf)"; SqlCommand command = new SqlCommand(strSQL,connection); buf=@buf; SqlParameter paramData = new SqlParameter( "@buf", SqlDbType.Image ); paramData.Value = buf; command.Parameters.Add( paramData ); connection.Open(); int numRowsAffected = command.ExecuteNonQuery(); //connection.Close(); Console.Write("OK"); string sql="SELECT * FROM nn" ; command.CommandText = sql; command.Connection = connection; SqlDataReader myDataReader = command.ExecuteReader(); if(myDataReader.Read() == true) { Stream file1; file1 = File.OpenWrite(".\\jjd.jpg"); byte[] mydata=((byte[])myDataReader["body"]); Console.Write(mydata.ToString()); BinaryWriter sw = new BinaryWriter(file1); sw.Write(mydata); sw.Close(); } Console.ReadLine(); } catch(System.Exception e) { Console.Write(e.Message); } } How To Read and Write BLOB Data by Using ADO.NET with Visual C# .NEThttp://support.microsoft.com/default.aspx?scid=kb;EN-US;309158 string pth=System.IO.Directory.GetCurrentDirectory(); string[] hpic=txtpic.Text.Split('.');//txtpic为输入文件名的文本框 string tf=pth+"\\"+Guid.NewGuid()+hpic[1]; System.IO.File.Copy(txtpic.Text,tf,true); FileStream fs=new FileStream(tf,FileMode.Open); byte[] buf=new byte[fs.Length]; fs.Read(buf,0,(int)(fs.Length)); fs.Close(); System.IO.File.Delete(tf); if(sqlcn.State==ConnectionState.Closed) sqlcn.Open(); dt1.Tables["person"].Rows[mybind.Position]["pic"]=buf;//mybind的定义: private BindingManagerBase mybind;-------------------------------------------------------------下面是如何把字段pic的值读到picturebox中 MemoryStream ms=new MemoryStream(); byte[] mydt=(byte[])dt1.Tables["person"].Rows[mybind.Position]["pic"]; ms.Write(mydt,0,mydt.Length); picbx.Image=Image.FromStream(ms,true); 如何获得一个连接地址的数据 委托是引用类型还是值类型? WinForm 如何获得Panel中被选中的控件 关于MySQL与oracle调用.NET写的DLL库 小弟请教一个“类”的问题 视图操作 Js操作Frame下的dom 请问各位,下面的画笔应该怎样设置 PropertyGrid 中浮点数 格式化显示 在C#中的重载是不是只有在基类方法是virtual的情况下才行? 紧急! 考试题--->画图:给你三个点,请画一个基于这三个点的圆. 请问:如何得到一个代理服务器地址的响应时间
ASP.NET高级编程.pdf
ASP.NET深入编程中文教程(PDF).rar
C# Language Specification.doc
C#参考大全.pdf
C#基本书写规范技术文档.rar
C#入门经典.rar
Microsoft .NET程序设计技术内幕.rar
windows应用高级编程-C#编程篇.pdf
......
有C#中用数据库存储图象的源程序例子,打包用QQ传给你吧~ 要的话请Q270417857~
{
Stream file;
file = File.OpenRead(".\\jj.jpg");
BinaryReader sr = new BinaryReader(file);
int n = (int)file.Length;
//Console.Write(sr.ReadBytes(n).ToString());
byte[] buf = new byte[n];
buf = sr.ReadBytes(n);
sr.Close(); string connstr = "server=rd-yb;database=wwzy;uid=sa;pwd=mps";
SqlConnection connection = new SqlConnection(connstr); string strSQL = "insert into nn(body)values(@buf)";
SqlCommand command = new SqlCommand(strSQL,connection); buf=@buf;
SqlParameter paramData = new SqlParameter( "@buf", SqlDbType.Image );
paramData.Value = buf;
command.Parameters.Add( paramData );
connection.Open();
int numRowsAffected = command.ExecuteNonQuery();
//connection.Close();
Console.Write("OK"); string sql="SELECT * FROM nn" ;
command.CommandText = sql;
command.Connection = connection; SqlDataReader myDataReader = command.ExecuteReader();
if(myDataReader.Read() == true)
{
Stream file1;
file1 = File.OpenWrite(".\\jjd.jpg");
byte[] mydata=((byte[])myDataReader["body"]); Console.Write(mydata.ToString());
BinaryWriter sw = new BinaryWriter(file1);
sw.Write(mydata);
sw.Close(); }
Console.ReadLine(); }
catch(System.Exception e)
{
Console.Write(e.Message);
}
}
http://support.microsoft.com/default.aspx?scid=kb;EN-US;309158
string[] hpic=txtpic.Text.Split('.');//txtpic为输入文件名的文本框
string tf=pth+"\\"+Guid.NewGuid()+hpic[1];
System.IO.File.Copy(txtpic.Text,tf,true);
FileStream fs=new FileStream(tf,FileMode.Open);
byte[] buf=new byte[fs.Length];
fs.Read(buf,0,(int)(fs.Length));
fs.Close();
System.IO.File.Delete(tf);
if(sqlcn.State==ConnectionState.Closed)
sqlcn.Open();
dt1.Tables["person"].Rows[mybind.Position]["pic"]=buf;
//mybind的定义:
private BindingManagerBase mybind;
-------------------------------------------------------------
下面是如何把字段pic的值读到picturebox中
MemoryStream ms=new MemoryStream();
byte[] mydt=(byte[])dt1.Tables["person"].Rows[mybind.Position]["pic"];
ms.Write(mydt,0,mydt.Length);
picbx.Image=Image.FromStream(ms,true);