Я попытаюсь вставить картинку в базу данных Oracle - но она не работает
(тот же код на Sql-сервере работает отлично)
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();
}