supply default value to Optional Param array in case of array of structure variables

pvkiran

New member
Joined
Jul 19, 2006
Messages
4
Programming Experience
1-3
Hello All,
How do we supply default value to Optional Param array in case of array of structure variables?
I need to define a function which accepts 0 to indefinite number of arguements( Params()) and the arguements need to be
in array of structure variables.
VB.NET:
---------------------------------------------------------------------------------------
Public Function Populate_table(ByVal str As String, Optional ByVal Params() As ParamTypes =<Some Default Value>) As DataTable
Dim CmdObj As New System.Data.OleDb.OleDbCommand
Dim VDataAdapt As New System.Data.OleDb.OleDbDataAdapter
Dim Vdataset As New DataSet
Dim Vtable As New DataTable
Dim n, i As Int16
CmdObj.Connection = oCon
CmdObj.CommandText = str
n = UBound(Params, 1)
If n > 0 Then
Dim par As OleDb.OleDbParameter
For i = 0 To n - 1
par = New OleDb.OleDbParameter(Params(i).ParamName, Params(i).ParamType)
par.Value = Params(i).ParamValue
CmdObj.Parameters.Add(New OleDb.OleDbParameter(Params(i).ParamName, Params(i).ParamValue))
Next
End If
VDataAdapt.SelectCommand = CmdObj
VDataAdapt.Fill(Vdataset)
Return (Vdataset.Tables(0))
End Function
------------------------------------------------------------------------------------------
Public Class MyShare
Public Structure ParamTypes
Dim ParamName As String
Dim ParamType As String
Dim ParamValue As String
End Structure
Public nullParam(0) As ParamTypes
End Class
-------------------------------------------------------------------------------------------
How do we supply default value to the above function?
Is there no way out except over loading to the above problem?
thankx in advance
 
Last edited by a moderator:
Top Bottom