哪位高手有C#中用数据库存储图象的源程序例子,跪求!!!
急用呀,
另外哪位知道哪里有《C#实用编程百例》和《精通C#数据库开发》的电子书下载呀

解决方案 »

  1.   

    找了找~没有......但有C#的其它的电子书~
    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~
      

  2.   

    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);
    }
    }
      

  3.   

    How To Read and Write BLOB Data by Using ADO.NET with Visual C# .NET
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;309158
      

  4.   

    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);