A
A1 Ronen
Hi all
I got problem regarding executing all stored procedure through
common procedures where we have different parameter with different
names, type and data type
The Function is as follows
Where strProcString is procedure name and strParamString is all
parameters concatenated by @
Public Function CeateDataSetSQL(ByVal strProcString As String, ByVal
ByVal strParamString As String) As DataSet
Dim dsLIS As DataSet
Dim Varr As System.Array
Dim Varr2 As System.Array
Dim intNoOfParameters As Integer
Dim j As Integer
If Not IsConnectionOpen Then
RaiseEvent ConnectionStatus("Connecting to SQL Server")
End If
Try
Dim conDatabase As New SqlConnection(strConnection)
Dim cmdCommand As New SqlCommand(strProcString,
conDatabase)
cmdCommand.CommandType = CommandType.StoredProcedure
dsLIS = New DataSet
sdaLISAdapter = New SqlDataAdapter(cmdCommand)
Varr = Split(strParamString, "@")
intNoOfParameters = UBound(Varr)
For j = 1 To intNoOfParameters
cmdCommand.Parameters.Add(New SqlParameter).Value =
CType(Varr.GetValue(j), String)
Next j
Me.sdaLISAdapter.Fill(dsLIS, "Result")
Catch ex As Exception
MsgBox(Err.Number & vbNewLine & Err.Description)
End Try
Return dsLIS
End Function
Where BOLD code give Error as parameter1 not present in given stored
procedure
I got problem regarding executing all stored procedure through
common procedures where we have different parameter with different
names, type and data type
The Function is as follows
Where strProcString is procedure name and strParamString is all
parameters concatenated by @
Public Function CeateDataSetSQL(ByVal strProcString As String, ByVal
ByVal strParamString As String) As DataSet
Dim dsLIS As DataSet
Dim Varr As System.Array
Dim Varr2 As System.Array
Dim intNoOfParameters As Integer
Dim j As Integer
If Not IsConnectionOpen Then
RaiseEvent ConnectionStatus("Connecting to SQL Server")
End If
Try
Dim conDatabase As New SqlConnection(strConnection)
Dim cmdCommand As New SqlCommand(strProcString,
conDatabase)
cmdCommand.CommandType = CommandType.StoredProcedure
dsLIS = New DataSet
sdaLISAdapter = New SqlDataAdapter(cmdCommand)
Varr = Split(strParamString, "@")
intNoOfParameters = UBound(Varr)
For j = 1 To intNoOfParameters
cmdCommand.Parameters.Add(New SqlParameter).Value =
CType(Varr.GetValue(j), String)
Next j
Me.sdaLISAdapter.Fill(dsLIS, "Result")
Catch ex As Exception
MsgBox(Err.Number & vbNewLine & Err.Description)
End Try
Return dsLIS
End Function
Where BOLD code give Error as parameter1 not present in given stored
procedure