ginTransaction();
OracleCommand myocmd = new OracleCommand("", myConnection);
myocmd.Transaction = myTransaction;
try
{
//语句块
myTransaction.Commit();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
myTransaction.Rollback();
}
finally
{
myConnection.Close();
}
}
?
?
2.4从数据表中读取图片数据
?
从
数据库中取一个图片数据,用二进制数组来存储,然后将其显示在指定的控件上。
?
byte[] tmpImage = (byte[])curRow["Pic"];
// fileLength是数组的长度(图片的大小)和curImageFormat图片格式。
fileLength = tmpImage.Length;
MemoryStream curStream = new MemoryStream(tmpImage);
picPersonel.Image = Image.FromStream(curStream);
curImageFormat = picPersonel.Image.RawFormat;
?
?
2.5 命令参数的创建和使用
?
创建命令参数
?
private OracleParameter CreateOraParam(string ParamName, object ParamValue)
{
OracleParameter Result = new OracleParameter();
Result.ParameterName = ParamName;
if (ParamValue != null)
{
Result.Value = ParamValue;
}
else
{
Result.Value = DBNull.Value;
}
Result;
}
?
?
?
insertComm.CommandText = "insert into TESTADODOTNET (ID) values (:pID)";
insertComm.Parameters.Add(CreateOraParam("pID", (txtID.Text.Trim() != "") ? txtID.Text.Trim() : null));
?