C # - How to get long raw oracle type

How to get long initial type value with C #?

+4
source share
2 answers

Since you have not posted any code, I do not know how much you know. I assume that you already understand how to execute the query and get the result using OracleDataReader.

There is one combination with the LONG and LONG RAW columns. You must set the InitialLONGFetchSize property of your OracleCommand to a nonzero value.

The default value of InitialLONGFetchSize is zero, which means that data will not be retrieved for LONG or LONG RAW columns. If you set the value to -1, all data will be restored. You might not want to do this for larger values. If you set it to anything above zero, the number of bytes will be fetched and cached.

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

+16
source

Here is the code to solve this problem.

  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; } } 
+1
source

Source: https://habr.com/ru/post/1307021/


All Articles