0
我會嘗試這種插入圖片到Oracle數據庫 - 但它不工作爲什麼在嘗試在Oracle中保存圖片時出現ORA-00936錯誤?
(在相同的代碼的SQL Server工作的優良)
string sampleImage = PicNativ;
BinaryReader sampleBR = null;
FileStream sampleFS = null;
OracleConnection sampleConnection = null;
OracleCommand sampleCommand = null;
FileInfo sampleFI = null;
byte[] sampleArr = null;
try
{
if (EDIT_M == 1)
Oracle = "update Sex set Name = '" + txtC.Text.Trim() +
"',pic = @p_pic where ID like '" + txtC4.Text.Trim() + "'";
else
Oracle = "insert into Sex (Id,Code,Name,pic) values "+
"(Sex_Code.nextval,'" + txtA.Text.Trim() + "','" +
txtC.Text.Trim() + "', @p_pic)";
sampleFI = new FileInfo(sampleImage);
sampleFS = new FileStream(sampleImage, FileMode.Open, FileAccess.Read);
sampleBR = new BinaryReader(sampleFS);
sampleArr = sampleBR.ReadBytes((int)sampleFI.Length);
using (sampleConnection = new OracleConnection(Conect))
{
sampleConnection.Open();
using (sampleCommand = new OracleCommand())
{
sampleCommand.Connection = sampleConnection;
sampleCommand.CommandText = Oracle;
sampleCommand.Parameters.
Add("@p_pic", OracleDbType.Blob).Value = sampleArr;
sampleCommand.ExecuteNonQuery();
}
}
}
finally
{
sampleBR.Close();
sampleFS.Close();
}
「它不工作」非常含糊。你能給出確切的問題嗎?您是否收到錯誤,數據是否完全丟失,不完整或無效? – 2009-04-21 09:01:04