我要完成类似的事情:传递OracleLob作为参数传递给函数
try
{
openConnection();
OracleCommand cmd = new OracleCommand("SELECT CUSTOMER_ID, IMAGE_BLOB FROM CUSTOMER_IMAGE WHERE CUSTOMER_ID IN (3026)", conn);
string pubID = "";
OracleDataReader reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess);
//create the report object
MemoryStream memStream;
DataSet ds = new DataSet();
DataTable ImageTable = new DataTable();
BinaryReader binReader;
DataRow dr;
byte[] byteArrName;
OracleLob blob;
while (reader.Read())
{
pubID = reader.GetValue(0).ToString();
// Obtain a LOB
blob = reader.GetOracleLob(1);
// Create a byte array of the size of the Blob obtained
byteArrName = new byte[blob.Length];
// Read blob data into byte array
int i = blob.Read(byteArrName, 0, System.Convert.ToInt32(blob.Length));
//Copied the contents of byte array to stream
memStream = new MemoryStream(byteArrName);
//Create a column of type byte[]
ImageTable.Columns.Add(new DataColumn("id", typeof(string)));
ImageTable.Columns.Add(new DataColumn("image", typeof(System.Byte[])));
//Reading the stream which has the blob data
binReader = new BinaryReader(memStream);
dr = ImageTable.NewRow();
dr["id"] = pubID;
//ReadBytes method to add a byte array of the image stream.
dr["image"] = binReader.ReadBytes((int)binReader.BaseStream.Length);
ImageTable.Rows.Add(dr);
memStream.Close();
binReader.Close();
}
ds.Tables.Add(ImageTable);
//Creating a temporary dataset which hold the image
ds.WriteXmlSchema(@Directory.GetCurrentDirectory() + "\\temp.xsd");
reader.Close();
conn.Close();
}
现在,我将填充在水晶报告认为temp.xsd使得图像将动态显示。这只是我从头开始编写的示例代码,但为了适应我的情况,我需要获取已在dtAcctSigner.Rows[0]["IMAGE_BLOB"],
中的图像,以便想知道是否有任何方法可以获取此BLOB,就像我在上面的代码中获取的那样,代码为
OracleDataReader.GetOracleLob();
对于这一点,我需要的数据表(类型OracleLob)的列作为参数传递给这样的功能:
Update(dtAcctSigner.Rows[0]["IMAGE_BLOB"]);
和函数去如下:
public void Update(OracleLob a)
{
// I want to do take the OracleLob and make into a memorystream and put it into temp.xsd here
}
但我得到一个错误:
cannot convert 'object' to 'OracleLob'
请让我知道我做错了什么。
你需要清理你的问题那么..也不要发布空白的代码方法..如果我们要帮助你,你必须对你遇到的问题更加清楚/具体..这有点混乱/很难请遵循你正在努力完成的任务 请在你如何传递Update(dtAcctSigner.Rows [iCount1] [“SIGNATURE_BLOB”])上显示完整的代码; 以及声明数据表 – MethodMan
好的谢谢。将编辑代码。 –
大多数人在下列情况下投票结果如下 1.没有显示出足够的个人研究 2.非常抽象的本质 3.是不是一个真正的问题..等 – MethodMan