Database.ExecuteNonQuery (String, Object[]) Executes the storedProcedureName using the given parameterValues and returns the number of rows affected. 我在使用ExecuteNonQuery这个方法时,如果参数没有输出参数,则下面的方法是可用的,但如果有Output参数的话,该怎么构造呢?
难道必须象下面这样?
dbc.AddOutParameter("@ProductName",System.Data.DbType.String,50);
能否可以象Database.ExecuteNonQuery("xxxsp",sss,ssss,out fff, out dfds)
这样呢?
难道必须象下面这样?
dbc.AddOutParameter("@ProductName",System.Data.DbType.String,50);
能否可以象Database.ExecuteNonQuery("xxxsp",sss,ssss,out fff, out dfds)
这样呢?
IDataParameter[] parameters = new SqlParameter[1];
parameters[0]=new SqlParameter("@Total", SqlDbType.Int);//返回记录总数, 非 0 值则返回
parameters[0].Direction=ParameterDirection.Output;SqlConnection connection = new SqlConnection(connectionString);
SqlDataReader returnReader;
connection.Open();
SqlCommand command = BuildQueryCommand( connection,storedProcName, parameters );
command.CommandType = CommandType.StoredProcedure;
command.ExecuteNonQuery();
Total = (int)command.Parameters[id].Value;
returnReader = command.ExecuteReader();
return returnReader;