Dec
4
Written by:
Steve Gray
12/4/2009 10:03 AM
This is an example of how the StoredProcedure.vb and CommandParameters.vb classes are used. This code assumes that the Microsoft Enterprise Library 4.1 is installed
Note that the database is passed in, this needs to be defined in the app.config or web.config file. Refer to the Enterprise Library examples for that.
First, create for each stored procedure that you want to access a function like this:
Public Shared Function FP_SOP10200_SEL_bySopnumbe3(ByVal strSopnumber As String, _
ByVal intSoptype As Int32, db as string) As storedProcedure
Dim sp As New storedProcedure("FP_SOP10200_SEL_bySopnumbe3", db)
sp.commandParameters.Add(New commandParameter("@vchrSopnumber", _
strSopnumber, DBType.String))
sp.commandParameters.Add(New commandParameter("@intSoptype", _
intSoptype, DBType.Int32))
Return sp
End Function
Then, call the stored procedure like this:
Grid1.DataSource = dynData.SPs.FP_SOP10200_SEL_bySopnumbe3(strSopnumber, _
intsoptype, AppUser.strLastDB).getTable
This is a little hard to follow, but bear with me. In step one, we create the FP_SOP10200_SEL_bySopnumbe3 function, and it returns a ‘StoredProcedure’ object. At the end of the line we add ‘.getTable’, or ‘.getReader’, or any of the methods in the StoredProcedure class.