基于Oracle提供的ODP.net类库,做Oracle数据库操作。程序开始运行正常,在运行一段时间后(几小时),出现如下错误:
Number=-3000
Message=数据提供方内部错误(-3000)
Source=Oracle Data Provider for .NET
DataSource=test
引发该错误的操作为查询数据库中的某条记录。记录中包含BLOB类型字段。SQL操作如下:
byte[] data;
string strSql = "select data from test where id = "+id;
OracleCommand cmd = new OracleCommand(strSql, db);
OracleDataReader reader = cmd.ExecuteReader();
if (reader.Read())
{   
    if (!reader.IsDBNull(0))
    {
        data = reader.GetOracleBlob(0).Value;
    }
    else
    {
        data = null;
    }    
}
reader.Close();

解决方案 »

  1.   

    给你个方法参考:
    string conn_str = "Provider=OraOLEDB.Oracle.1;Password=agoodjob;Persist Security Info=True;User ID=ams;Data Source=ims;Extended Properties=";//Provider必須用OraOLEDB.Oracle.1
       
       OleDbDataAdapter da = new OleDbDataAdapter();
       DataSet ds = new DataSet();
       OleDbConnection conn = new OleDbConnection(conn_str);
       OleDbCommand cmd = new OleDbCommand("SELECT PHOTO FROM WEB_DB.USERS WHERE USER_ID = 1", conn);
       da.SelectCommand = cmd;
       cmd.Connection.Open();
       da.Fill(ds);   byte[] img = new byte[0];
       DataRow dr;
       dr = ds.Tables[0].Rows[0];   if (!ds.Tables[0].Rows[0]["PHOTO"].ToString().Equals(""))
       {
        img =  (byte[])dr["PHOTO"];
       }   Response.ContentType= "image/*";
       Response.BinaryWrite (img);   conn.Close();
      

  2.   

    多谢CathySun118 帮忙。咱俩用的类库不一样,没有可比性。初步估计是类库的使用方法不当引起的这个错误。在性能比较好的机器上不出现上述错误。
      

  3.   

    问题解决。
    解决方法:升级ODP.net开发库。由10.1.0.200 升级到10.1.0.400。