Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Asp.Net Programming

Enterprise Library 2.0 Data Access Application Block


Hello,

Could someone tell me how to run a simple SQL stored procedure using
the Enterprise Library 2.0 Data Access?

I have in my VB.NET code the following database:
      Dim db As Database = DatabaseFactory.CreateDatabase

Thanks,
Miguel

You need to define whether or not the stored procedure returns rows or not.

"shapper" <mdmo@gmail.com> wrote in message

news:1170947831.823929.194660@s48g2000cws.googlegroups.com...

From memory:

                Dim dbCommandWrapper As DatabaseCommandWrapper =
db.GetStoredProcCommandWrapper("dbo.uspSomeProcedure")

                dbCommandWrapper.AddInParameter("@EmpID", DbType.Int,
12345 )

                ' Output parameters specify the size of the return data
                'dbCommandWrapper.AddOutParameter("@numberRowsAffected",
DbType.Int32, 0)

                Dim rowsAffected As Int32
                rowsAffected = db.ExecuteNonQuery(dbCommand)

' there are diffferent methods. ExcecuteReader, LoadDataSet.. you have to
match yours to what you want it to do

-----------------------------------------------Reply-----------------------------------------------

Ahh, sorry, I gave you a 1.1 example:

Here is 2.0

        private Microsoft.Practices.EnterpriseLibrary.Data.Database
GetDatabase()
        {

            // Create the Database object, using the default database
service. The
            // default database service is determined through configuration.
            Database db = DatabaseFactory.CreateDatabase();

            return db;
        }

private void UpdateEmployeeData(int empid )

{
            Database db = this.GetDatabase();

            DbCommand dbc = db.GetStoredProcCommand("dbo.uspSomeProcedure);

            db.AddInParameter(dbc , "@EmpID", DbType.Int32, empid);

            db.AddOutParameter(dbc , "@numberRowsAffected", DbType.Int32,
0);

db.ExecuteNonQuery(dbc )

}
"sloan" <s@ipass.net> wrote in message

news:ep1ZIj5SHHA.4872@TK2MSFTNGP03.phx.gbl...

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc