E
Eric Sabine
Below is a sub I have which contains 4 lines of code. I would like to
reduce it to 1. My problem is that it takes 3 lines to create the array to
hold the sql parameter and since there's only one dimension in the array,
I'd like to do something more like what's at the bottom of this post, but a
lack of understanding prevents me from doing it properly. Any suggestions?
Sub getUserVendorAssignment(ByVal UserName As String)
' fill the table UserVendor in the local dataset with the
' results from the usp_dr_userVendorReceivingAssignments stored
procedure
' Pass in one parameter item which is received as a string
' 3 lines to create our parameter?
Dim arParms() As System.Data.SqlClient.SqlParameter = _
New System.Data.SqlClient.SqlParameter(0) {}
arParms(0) = New SqlParameter("@user_name", SqlDbType.VarChar, 8)
arParms(0).Value = UserName .ToUpper
localFillDataset( _
"dbo.usp_dr_userVendorReceivingAssignments", _
"UserVendor", _
arParms)
End Sub
--------------------
what I'd _like_ to do (I know it's wrong, it's just the "guess")
localFillDataset( _
"dbo.usp_dr_userVendorReceivingAssignments", _
"UserVendor", _
New SqlParameter() {CType(UserName , SqlParameter)})
reduce it to 1. My problem is that it takes 3 lines to create the array to
hold the sql parameter and since there's only one dimension in the array,
I'd like to do something more like what's at the bottom of this post, but a
lack of understanding prevents me from doing it properly. Any suggestions?
Sub getUserVendorAssignment(ByVal UserName As String)
' fill the table UserVendor in the local dataset with the
' results from the usp_dr_userVendorReceivingAssignments stored
procedure
' Pass in one parameter item which is received as a string
' 3 lines to create our parameter?
Dim arParms() As System.Data.SqlClient.SqlParameter = _
New System.Data.SqlClient.SqlParameter(0) {}
arParms(0) = New SqlParameter("@user_name", SqlDbType.VarChar, 8)
arParms(0).Value = UserName .ToUpper
localFillDataset( _
"dbo.usp_dr_userVendorReceivingAssignments", _
"UserVendor", _
arParms)
End Sub
--------------------
what I'd _like_ to do (I know it's wrong, it's just the "guess")
localFillDataset( _
"dbo.usp_dr_userVendorReceivingAssignments", _
"UserVendor", _
New SqlParameter() {CType(UserName , SqlParameter)})