我在开发c/s结构系统,需要这样的功能:
在一个window窗口里放入一个能够上传图片的控件
就是让用户点击后在自己的机子上找到所需要的图片,然后通过这个控件保存到数据库中(SqlServer),
然后再所需要的地方显示出来,
请问在.net的window自带的控件又没有这样的功能呀,
请给出详细代码和解释,
谢谢,等待中

解决方案 »

  1.   

    http://dev.csdn.net/develop/article/22/22114.shtm
      

  2.   

    用不着控件,把文件读到Stream里,作为Image字段的字节数组参数,Insert或Update就行了。
    public static byte[] FileToByteAarray(string fileName)
    {
    try
    {
    FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
    int FileSize = Convert.ToInt32(fs.Length);
    byte[] stream = new byte[FileSize];
    fs.Read(stream, 0, FileSize); 
    return stream;
    }
    catch(Exception ex)
    {
    MessageBox.Show(ex.ToString());
    return null;
    }
    }
      

  3.   

    用户选择显示和保存到数据库中是两码事。要是显示,你可以用图形控件显示。而要保存到数据库中,就和chinasdp()  的方法差不多了