C# - How to get oracle long raw type value

前端 未结 2 1433
南笙
南笙 2020-11-30 12:58

How to get long raw type value with C#?

相关标签:
2条回答
  • 2020-11-30 13:45

    Since you haven't posted any code, I don't know how much you know. I'm going to assume you already understand how to execute a query and get back a result set using OracleDataReader.

    There is one gotcha with LONG and LONG RAW columns. You must set the InitialLONGFetchSize property of your OracleCommand to a non-zero value.

    The default value of InitialLONGFetchSize is zero, which means no data will be retrieved for LONG or LONG RAW columns. If you set it to -1, all data will be retrieved . You might not want to do this for large values. If you set it to anything above zero, that's how many bytes will be intially fetched and cached.

    You should read the documentation for InitialLONGFetchSize, because there are some other details you need to know.

    0 讨论(0)
  • 2020-11-30 13:49

    Here is Code to solve this issue.

              Byte[] img;
            con.Open();
            OracleCommand command = new OracleCommand("Select Image as BLOBDATA FROM tbltestImage ", con);
            command.InitialLONGFetchSize = -1;
            OracleDataReader rdr = command.ExecuteReader();
    
            DataTable dt = new DataTable();
            dt.Load(rdr);
            con.Close();
             if (dt.Rows.Count > 0)
            {
    
                if (dt.Rows[0]["BLOBDATA"].ToString() != "")
                {
    
                    img = (Byte[])dt.Rows[0]["BLOBDATA"];
    
    
                    MemoryStream ms = new MemoryStream(img);
    
                    Bitmap bitmap = new Bitmap(ms);
    
                    pictureBox2.Image = bitmap;
    
                    pictureBox2.SizeMode = PictureBoxSizeMode.StretchImage;
                }
    
    
    
    
            }
    
    0 讨论(0)
提交回复
热议问题