Home All Groups Group Topic Archive Search About

how to get output parameters using enterprise library 2.0

Author
1 Feb 2006 3:34 AM
xisco
hi,
how do I get output parameters from sql 2005 query using the entlib 2,0?
I noticed the dbcommandwrapper is not there anymore.

thanks
xisco

Author
2 Feb 2006 2:40 AM
Triax
DBCommandWrapper has been deprecated. The parameter functions are off the
Database class now. Here's some code from the QuickStart.

        public string GetProductDetails(int productID)
        {
            // Create the Database object, using the default database
service. The
            // default database service is determined through configuration.
            Database db = DatabaseFactory.CreateDatabase();

            string sqlCommand = "GetProductDetails";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

            // Add paramters
            // Input parameters can specify the input value
            db.AddInParameter(dbCommand, "ProductID", DbType.Int32,
productID);
            // Output parameters specify the size of the return data
   db.AddOutParameter(dbCommand, "ProductName", DbType.String, 50);
   db.AddOutParameter(dbCommand, "UnitPrice", DbType.Currency, 8);

            db.ExecuteNonQuery(dbCommand);

            // Row of data is captured via output parameters
            string results = string.Format(CultureInfo.CurrentCulture, "{0},
{1}, {2:C} ",
                                           db.GetParameterValue(dbCommand,
"ProductID"),
             db.GetParameterValue(dbCommand, "ProductName"),
             db.GetParameterValue(dbCommand, "UnitPrice"));

            return results;
        }

HTH

___________________________
Triax


Show quote
"xisco" <xi***@hotmail.com> wrote in message
news:uXZu0BuJGHA.2248@TK2MSFTNGP15.phx.gbl...
> hi,
> how do I get output parameters from sql 2005 query using the entlib 2,0?
> I noticed the dbcommandwrapper is not there anymore.
>
> thanks
> xisco
>
Author
2 Feb 2006 3:09 AM
xisco
Great. thanks!


Show quote
"Triax" <nore***@noreply.com> wrote in message
news:%232oi7H6JGHA.2392@TK2MSFTNGP09.phx.gbl...
> DBCommandWrapper has been deprecated. The parameter functions are off the
> Database class now. Here's some code from the QuickStart.
>
>        public string GetProductDetails(int productID)
>        {
>            // Create the Database object, using the default database
> service. The
>            // default database service is determined through
> configuration.
>            Database db = DatabaseFactory.CreateDatabase();
>
>            string sqlCommand = "GetProductDetails";
>            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
>
>            // Add paramters
>            // Input parameters can specify the input value
>            db.AddInParameter(dbCommand, "ProductID", DbType.Int32,
> productID);
>            // Output parameters specify the size of the return data
>   db.AddOutParameter(dbCommand, "ProductName", DbType.String, 50);
>   db.AddOutParameter(dbCommand, "UnitPrice", DbType.Currency, 8);
>
>            db.ExecuteNonQuery(dbCommand);
>
>            // Row of data is captured via output parameters
>            string results = string.Format(CultureInfo.CurrentCulture,
> "{0}, {1}, {2:C} ",
>                                           db.GetParameterValue(dbCommand,
> "ProductID"),
>             db.GetParameterValue(dbCommand, "ProductName"),
>             db.GetParameterValue(dbCommand, "UnitPrice"));
>
>            return results;
>        }
>
> HTH
>
> ___________________________
> Triax
>
>
> "xisco" <xi***@hotmail.com> wrote in message
> news:uXZu0BuJGHA.2248@TK2MSFTNGP15.phx.gbl...
>> hi,
>> how do I get output parameters from sql 2005 query using the entlib 2,0?
>> I noticed the dbcommandwrapper is not there anymore.
>>
>> thanks
>> xisco
>>
>
>

AddThis Social Bookmark Button