protected void Button1_Click(object sender, EventArgs e)
    {
        var sgtr=ConfigurationManager.AppSettings["ConnStr"];
        OleDbConnection myConn = dbcls.GetATempConnection();
        OleDbCommand cmd = new OleDbCommand(sgtr,myConn);
        cmd.CommandType = CommandType.Text;
        //byte[] expbyte = System.Text.Encoding.Unicode.GetBytes("D:\我的文档\My Pictures\Panda004.jpg");
        FileStream fsPic = new FileStream(@"D:\我的文档\My Pictures\七剑下天山.jpg", FileMode.Open,FileAccess.Read);
        byte[] byPic = new byte[fsPic.Length];
        fsPic.Read(byPic, 0, System.Convert.ToInt32(fsPic.Length));        cmd.CommandText = "insert into xlutest (hhhh) values (':hhhh')";
        cmd.Parameters.Add(":hhhh", System.Data.OleDb.OleDbType.Binary, System.Convert.ToInt32(byPic.Length));
        cmd.Parameters[0].Value = byPic;  
        try
        {
            cmd.ExecuteNonQuery();
            Response.Write("OK");
        }
        catch(System.Exception ee)
        {
            Response.Write(ee.Message);
        }    }

解决方案 »

  1.   

    insert into xlutest (hhhh) values (':hhhh')这个好像不对,怎么就一个字段?Oracle无法找到RowId。。
      

  2.   

    这个应该没有问题,我有PL/sql developer只对hhhh字段插入一幅图片是没有问题的.
      

  3.   

    那位高手有一个.net的oledb+oracle的BLOB存储照片的代码吗?
      

  4.   

    感觉可能是oracle8.17的原因,是不是要装9i才能用??VS跟oralce的支持真的差。
      

  5.   

    要先INSERT 
    BLOB字段,先給個字符。
    然後再SELECT 
    取得BLOB,
    BLOB.WRITE
    建議你用9I 的oo4o
      

  6.   


    string strSql = "insert into table(a,blob) VALUES('a','b')";
                                
                                ocom.CommandText = strSql;
                                ocom.ExecuteNonQuery();
                                ocom.CommandText = "select * from  table where a='a' FOR UPDATE";
                                odr = ocom.ExecuteReader();
                                if (odr.Read())
                                {
                                    Oracle.DataAccess.Types.OracleBlob blob = odr.GetOracleBlob(1);
                                    blob.Write(bb, 0, bb.Length);
                                    blob.Close();
                                }
                       
                                tran.Commit();
    核心代碼供參考
    你如果裝9I OO4O,裡面有DEMO
      

  7.   

    Oracle.DataAccess.Types.OracleBlob 要用到哪个命名空间??
      

  8.   

    不要用微软的驱动操作ORACLE,总是觉得有这样那样的问题,
    用ORACLE 提供的OO4O,感觉好一些