Saturday, April 16, 2011

Return a string using EnterpriseLibrary

This code sample gives a simple example of handling out parameter of stored procedure using EnterpriseLibrary.

Prerequisites: EnterpriseLibrary 4.1

1. Add the reference to Microsoft.Practices.EnterpriseLibrary.Data.dll
2. Add the reference to Microsoft.Practices.EnterpriseLibrary.Common.dll
3. In the web.config file, create the database conection string
4. In the business layer, class file add reference to

using Microsoft.Practices.EnterpriseLibrary.Data;


public string GetEmployeeId(string strEmpName)
{
string strEmployeeId = string.Empty;
Database objDatabase = DatabaseFactory.CreateDatabase("HRPortal");
DbCommand objDBCommand = objDatabase.GetStoredProcCommand("spHR_GetEmployeeId");
objDatabase.AddInParameter(objDBCommand, "EmpName", DbType.String, strEmpName);
objDatabase.AddOutParameter(objDBCommand, "iEmpId", DbType.String);
objDatabase.ExecuteScalar(objDBCommand);
strEmployeeId = objDatabase.GetParameterValue(objDBCommand, "iEmpId").ToString();
return strEmployeeId;
}

Related Posts:

  • Return a string using EnterpriseLibraryThis code sample gives a simple example of handling out parameter of stored procedure using EnterpriseLibrary.Prerequisites: EnterpriseLibrary 4.11. A… Read More
  • Enterprise Library 5Yep check out the following (2) links for the labs and samples:patterns & practices – Enterprise Library:http://entlib.codeplex.com/Hands-on Labs:http… Read More

0 comments:

Popular Posts

Recent Posts

Unordered List

Text Widget

Blog Archive