日期:2014-05-17 浏览次数:20677 次
public static int Update(MacInfo model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("update MacInfo set ");
strSql.Append("Mac_Address=:Mac_Address,");
strSql.Append("Mac_Status=:Mac_Status");
strSql.Append(" where MacInfo_ID=:MacInfo_ID");
//strSql.Append("Mac_Address='"+model.Mac_Address+"',");//拼凑Update字符串是可以执行成功的
//strSql.Append("Mac_Status="+model.Mac_Status);
//strSql.Append(" where MacInfo_ID='"+model.MacInfo_ID+"'");
OracleParameter[] parameters = {
new OracleParameter(":MacInfo_ID", OracleDbType.Varchar2,17),
new OracleParameter(":Mac_Address", OracleDbType.Varchar2,17),
new OracleParameter(":Mac_Status", OracleDbType.Int32,4)};
parameters[0].Value = model.MacInfo_ID;
parameters[1].Value = model.Mac_Address;
parameters[2].Value = model.Mac_Status;
int result = DBHelper.ExecuteCommand(strSql.ToString(), CommandType.Text,parameters);
return result;
}
public static int ExecuteCommand(string queryString, CommandType commandType, params OracleParameter[] param)
{
int flag = 0;
using(OracleConnection con = new OracleConnection(ConnectionString))
{
OracleCommand command = new OracleCommand(queryString, con);
command.CommandType = commandType;
if(param != null)
{
for(int i = 0; i < param.Length; i++)
{
&nbs