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

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top