'Parameter class...
Public Class Parameters
Inherits System.Collections.CollectionBase
'Disposed flag for the class...
Private isDisposed As Boolean
'Constructors...
Public Sub New()
'This constructor does nothing...
End Sub
Public Sub New(ByVal pParam As String, ByVal pValue As Object)
'Dimensions...
Dim tempParam As IDataParameter
Select Case Data.Mode
Case DataModes.modeDefault, DataModes.modeSqlServer
tempParam = New SqlParameter(pParam, pValue)
Case DataModes.modeOleDb
tempParam = New OleDb.OleDbParameter(pParam, pValue)
End Select
list.Add(tempParam)
End Sub
'Allow addition of new parameter...
Public Sub Add(ByVal paramProperty As IDataParameter)
list.Add(paramProperty)
End Sub
Public Sub Add(ByVal pName As String, ByVal pValue As Object)
Dim tempParam As IDataParameter
If Data.Mode = DataModes.modeDefault Or Data.Mode = DataModes.modeSqlServer Then
tempParam = New SqlParameter(pName, pValue)
ElseIf Data.Mode = DataModes.modeOleDb Then
tempParam = New OleDbParameter(pName, pValue)
Else
Throw New Exception("XML options not supported")
End If
list.Add(tempParam)
End Sub
'Remove existing properties...
Public Sub Remove(ByVal pIndex As Int32)
'Just make sure...
If pIndex >= 0 And pIndex < list.Count Then
list.RemoveAt(pIndex)
Else
Throw New IndexOutOfRangeException("pValues in the range: 0 - " & list.Count - 1)
End If
End Sub
Public Sub Remove(ByVal pParam As IDataParameter)
list.Remove(pParam)
End Sub
'Destructor...
Public Sub Dispose()
If Not isDisposed Then
MyBase.Finalize()
isDisposed = True
End If
End Sub
End Class