Enterprise Library 2.0 Data Access Application Block

S

shapper

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
 
S

sloan

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
 
S

sloan

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 )

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top