我要完成類似的事情:傳遞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