我想using
用于sql command
:
using(SqlCommand command = new SqlCommand("usp_UpdateUser", _sqlConnection, _sqlTransaction))
{
....
}
但在FillCommand(ref command)
我得到例外:
Cannot pass command as ref or out variable because it is using variable.
我的代码是:
SqlCommand command = new SqlCommand("usp_UpdateUser", _sqlConnection,
_sqlTransaction);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("@Id", SqlDbType.Int)).Value = Id;
FillCommand(ref command);
try
{
command.ExecuteNonQuery();
}
catch
{
throw;
}