Thanks for your reply; but I changed my code but in the line of
".DataSource = Nothing" I got previous error;
I tell you my problem again:
first time I call 'DoFillComboWithValues' routin I don't get any error but when I call it in the second time I got this error in the
'.DataSource = dvBasicValues' line, after I changed my code as you ask me, I got this error over ".DataSource = Nothing" line
I think I must set dataset to nothing ( as you told me ) but I don't know how can I do it?
Public Sub DoFillComboWithValues(ByRef MyComboBox As
ComboBox, ByVal strStoredProcedureName As String, ByVal shoTableID As Short, ByVal strValueMember As String, ByVal strDisplayMember As String)
Dim ds As DataSet = SqlHelper.ExecuteDataset(g_strConnection, CommandType.StoredProcedure, strStoredProcedureName, New SqlParameter("@TableID", shoTableID))
Dim dtBasicValues As DataTable = ds.Tables(0)
Dim dvBasicValues As DataView = dtBasicValues.DefaultView
dvBasicValues.Sort = "Basic_Default"
Dim foundIndex As Integer = dvBasicValues.Find(1)
With MyComboBox
.Items.Clear()
.ValueMember = strValueMember 'second time that I call this routin I got error here
.DisplayMember = strDisplayMember
.DataSource = dvBasicValues
End With
'I added your sugestion here
Public Sub DoFillComboWithValues(ByRef MyComboBox As
ComboBox, ByVal strStoredProcedureName As String, ByVal shoTableID As Short, ByVal strValueMember As String, ByVal strDisplayMember As String)
Dim ds As DataSet = SqlHelper.ExecuteDataset(g_strConnection, CommandType.StoredProcedure, strStoredProcedureName, New SqlParameter("@TableID", shoTableID))
Dim dtBasicValues As DataTable = ds.Tables(0)
Dim dvBasicValues As DataView = dtBasicValues.DefaultView
dvBasicValues.Sort = "Basic_Default"
Dim foundIndex As Integer = dvBasicValues.Find(1)
With MyComboBox
.Items.Clear()
.DataSource = Nothing 'second time I got eror here
.ValueMember = strValueMember
.DisplayMember = strDisplayMember
.DataSource = dvBasicValues
End With