我被微软忽悠了 SQLHelper
于娜 2007-02-12 01:49:33 微软的 SQLHelper 大家一定都用过吧, 下面是一种的一段。
public static int ExecuteNonQuery(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
//create a command and prepare it for execution
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters);
//finally, execute the command.
int retval = cmd.ExecuteNonQuery();
// detach the SqlParameters from the command object, so they can be used again.
cmd.Parameters.Clear();
return retval;
}
我要说的是这个这句中的 cmd.Parameters.Clear() .为什么要写这句,多余!,就是因为这句导致了 存储过程的输出参数 无法接收, 取掉后就好了,难道微软就没想过吗?