开发者

C# - How to get oracle long raw type value

How t开发者_运维知识库o get long raw type value with C#?


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.


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜