Take a look at the Data Access block, included with the Enterprise Library.
http://www.gotdotnet.com/codegallery...2-91be63527327
Depending on the version (1.x or 2.x), it will vary, but the concept remains
the same
It reduces database calls to this pseudo code
Database db = Database.CreateFactory("");
DBCommand cmd = db.GetStoredProcCommandWrapper("StoredProcName");
cmd.AddInParameter("InboundParam1", DbType.String, ParamValue);
cmd.AddOutParameter("OutParam1", DbType.Int32, 4);
cmd.AddOutParameter("OutParam2", DbType.Int32, 4);
db.ExecuteNonQuery(cmd);
cmd.GetParameterValue("OutParam1"); //get value of outbound param
cmd.GetParameterValue("OutParam2"); //get value of outbound param
2 things I really like about it is
1. No need for @; the prefix is defined by the DB type in the setup
2. In theory, you can change the connection string to another DB type with
no changes to the data tier.
HTH,
Morgan
"Alex" <no****@hotmail.com> wrote in message
news:43*********************@news.zen.co.uk...
Hi...
I have a stored procedure that takes in a large number of parameters
(around 30) and returns (as output parameters) another 10 or so.
At the moment, each parameter is declared, defined and added in my C# code
as follows:
SqlParameter prmCustAcctID = cmd.CreateParameter();
prmCustAcctID.ParameterName = "@CustAcctID";
prmCustAcctID.SqlDbType = SqlDbType.NVarChar;
prmCustAcctID.Direction = ParameterDirection.Input;
prmCustAcctID.Size = 30;
prmCustAcctID.Value = strCustAcctID;
cmd.Parameters.Add(prmCustAcctID);
Multiply this by around 40, and you get a very long block of code!!!
Is there a better/faster/more improved way of doing something like this
for large numbers of parameters?
Thanks!
Alex