R
Russ
I have a subroutine that I call to bind a dataset to a combobox. It
works sometimes. See the code below..
1 Private Sub BindDropDownToDataSet( _
2 ByRef control As System.Windows.Forms.ComboBox, _
3 ByVal ds As DataSet)
4 Try
5 control.DataSource = ds.Tables(0)
6 control.ValueMember = ds.Tables(0).Columns(0).ColumnName
7 control.DisplayMember =
ds.Tables(0).Columns(1).ColumnName
8 Catch e As Exception
9 MsgBox(e.Message)
10 End Try
11 End Sub
Code to call my sub is ...
BindDropDownToDataSet(ComboBox1, Dataset1)
BindDropDownToDataSet(ComboBox2, Dataset2) <-- fails on this call
The problem is that one time it will work just fine. Then I call it
to fill another combobox and it fails on line 6 with the error ...
"Cast from type 'DataRowView' to type 'String' is not valid."
What is really weird is that while debugging, after it executes line 6
it goes to the catch. Then if I "Set the Next Statement" to line 6,
it works just fine.
works sometimes. See the code below..
1 Private Sub BindDropDownToDataSet( _
2 ByRef control As System.Windows.Forms.ComboBox, _
3 ByVal ds As DataSet)
4 Try
5 control.DataSource = ds.Tables(0)
6 control.ValueMember = ds.Tables(0).Columns(0).ColumnName
7 control.DisplayMember =
ds.Tables(0).Columns(1).ColumnName
8 Catch e As Exception
9 MsgBox(e.Message)
10 End Try
11 End Sub
Code to call my sub is ...
BindDropDownToDataSet(ComboBox1, Dataset1)
BindDropDownToDataSet(ComboBox2, Dataset2) <-- fails on this call
The problem is that one time it will work just fine. Then I call it
to fill another combobox and it fails on line 6 with the error ...
"Cast from type 'DataRowView' to type 'String' is not valid."
What is really weird is that while debugging, after it executes line 6
it goes to the catch. Then if I "Set the Next Statement" to line 6,
it works just fine.