Hello all, I would like you to critique my code. In the past I've create modules rather than classes. The class I've created is for our n-tier structure. We are forbidden to call stored procedures directly, and I thought it was goofy to create a new function for each SP that gets called. I'm hoping this will be the only function used to call any stored procedure. What do you think?

VB Code:
  1. Imports System.Data.SqlClient
  2. Public Class DalBx
  3.     Private sSPname As String
  4.     Private sConnString As String
  5.     Private hsParms As New Hashtable
  6.     Private bEncryptedConn As Boolean
  7.  
  8.     Function GetData() As DataSet
  9.         Try
  10.             If bEncryptedConn Then
  11.                 Dim commBC As New BCBSMT.CommonBC
  12.                 sConnString = commBC.DecryptString(sConnString)
  13.             End If
  14.  
  15.             Dim sqConn As SqlConnection = New SqlConnection(sConnString)
  16.             Dim sqCmd As New SqlCommand
  17.             Dim sqDa As New SqlDataAdapter
  18.             Dim sqCb As SqlCommandBuilder
  19.             Dim sqPrm As SqlParameter
  20.             Dim dsRtn As New DataSet
  21.  
  22.             sqCmd = sqConn.CreateCommand
  23.             sqCmd.CommandText = sSPname
  24.             sqCmd.CommandType = CommandType.StoredProcedure
  25.  
  26.             sqConn.Open()
  27.             sqCb.DeriveParameters(sqCmd)
  28.             sqConn.Close()
  29.  
  30.             For Each sqPrm In sqCmd.Parameters
  31.                 If hsParms.Contains(sqPrm.ParameterName) Then
  32.                     sqPrm.Value = hsParms.Item(sqPrm.ParameterName)
  33.                 End If
  34.             Next
  35.  
  36.             sqDa.SelectCommand = sqCmd
  37.             sqDa.Fill(dsRtn)
  38.  
  39.             Return dsRtn
  40.         Catch oEx As Exception
  41.             Dim dsError As New DataSet
  42.             Dim dt As New DataTable
  43.             dt.TableName = "ErrorTable"
  44.             dt.Columns.Add("ErrorDescription")
  45.             dt.Rows.Add(dt.NewRow)
  46.             dt.Rows(0).Item(0) = oEx.ToString
  47.             dsError.Tables.Add(dt)
  48.  
  49.             Return dsError
  50.         End Try
  51.     End Function
  52.  
  53. #Region "Properties"
  54.  
  55.     Property SPname() As String
  56.         Get
  57.             Return sSPname
  58.         End Get
  59.         Set(ByVal Value As String)
  60.             sSPname = Value
  61.         End Set
  62.     End Property
  63.     Property ConnString() As String
  64.         Get
  65.             Return sConnString
  66.         End Get
  67.         Set(ByVal Value As String)
  68.             sConnString = Value
  69.         End Set
  70.     End Property
  71.     Property Parameters() As Hashtable
  72.         Get
  73.             Return hsParms
  74.         End Get
  75.         Set(ByVal Value As Hashtable)
  76.             hsParms = Value
  77.         End Set
  78.     End Property
  79.     Property EncryptedConnection() As Boolean
  80.         'Has the connection string been encrypted
  81.         Get
  82.             Return bEncryptedConn
  83.         End Get
  84.         Set(ByVal Value As Boolean)
  85.             bEncryptedConn = Value
  86.         End Set
  87.     End Property
  88.  
  89. #End Region
  90.  
  91. End Class