没人帮帮忙么?我写了这么多的。而且代码也能运行。

解决方案 »

  1.   

    解决了已经
    在前台添加一个按钮ID为b_imageimport
    按钮后台代码如下。(只对一条记录操作,本例只是一个实验代码,可设计循环逐条写入)protected void b_imageimport_Click(object sender, EventArgs e)
        {
            DB2Connection db2conn = new DB2Connection("Database=MYFIRST");
            String sqlstr = "update users set userphoto=@userphoto where userid=103";
            DB2Command db2cmd = new DB2Command(sqlstr, db2conn);
            //!!!!!!!!!!文件操作开始!!!!!!!!!!!!
            FileStream fstream = new FileStream("K:\\pic\\200837152945362.jpg", FileMode.Open, FileAccess.Read);
            byte[] blob=new byte[fstream.Length];
            fstream.Read(blob, 0, blob.Length);
            fstream.Close();
            DB2Parameter db2para = new DB2Parameter("@userphoto",DB2Type.VarBinary,blob.Length,ParameterDirection.Input,false,0,0,null,DataRowVersion.Current,blob);
            db2cmd.Parameters.Add(db2para);
            //!!!!!!!!!!!!!!!!!!!!!文件操作完毕!!!!!!!!!
            db2conn.Open();
           db2cmd.ExecuteNonQuery();
           db2conn.Close();    }测试成功,请斑竹给分吧。。