https://blog.51cto.com/whitewolfblog/834757
sql = @"UPDATE HD_Binds SET HD_From=@From,HD_To=@To,HD_RegIP=@IP,HD_Expire=@Expire,HD_Connect=1 WHERE HD_CompanyID=" + CompanyID + @" AND HD_Machine=@Machine AND HD_DEL=0";
//sql= sql.Replace("@From", From).Replace("@To", To).Replace("@IP", IP).Replace("@Expire", DateTime.Now.AddSeconds(30).ToString()).Replace("@Machine", Machine);
cmd = new OleDbCommand(sql, Con);
cmd.Parameters.AddWithValue("@From", From);
cmd.Parameters.AddWithValue("@To", To);
cmd.Parameters.AddWithValue("@IP", IP);
cmd.Parameters.Add("@Expire", OleDbType.DBDate).Value = DateTime.Now.AddSeconds(30);
//cmd.Parameters.Add("@CompanyID", OleDbType.Integer).Value = CompanyID;
cmd.Parameters.Add("@Machine", OleDbType.VarChar, 100).Value = Machine;
int count = cmd.ExecuteNonQuery();
return count.ToString();
顺序影响update执行结果,当上述@Machine移前后,执行为0,表示未执行。 |