Hi all,
I am fairly new to VB.NET and I am VERY new to all of this SQL/ADO stuff and need help. I have a SQL DB table that has 5 fields... ID, Product Type, Product Name, Product Code and Product Description
I have a windows form with a combobox and textbox on it. I am populating the combobox with the Product Code field contents using VB code (I think this is called "unbound"?) based on a SELECT filter (see code below). I would like to populate the textbox with the Product Description from the same record that was selected in the combobox.
I thought this would be as easy as setting the DataBindings:Text property of the textbox to the same binding source I am using to populate the combobox, but it does not work. I get an initial value in the textbox, but the textbox value does not change when a new value is selected in the combobox.
Can someone give me some tips on getting this to work?
Thanks in advance!
I am fairly new to VB.NET and I am VERY new to all of this SQL/ADO stuff and need help. I have a SQL DB table that has 5 fields... ID, Product Type, Product Name, Product Code and Product Description
I have a windows form with a combobox and textbox on it. I am populating the combobox with the Product Code field contents using VB code (I think this is called "unbound"?) based on a SELECT filter (see code below). I would like to populate the textbox with the Product Description from the same record that was selected in the combobox.
I thought this would be as easy as setting the DataBindings:Text property of the textbox to the same binding source I am using to populate the combobox, but it does not work. I get an initial value in the textbox, but the textbox value does not change when a new value is selected in the combobox.
VB.NET:
Dim strSQL As String = "SELECT [Product Code] FROM ProductCodes WHERE [Product Type] like '%DT%'"
Dim da As New SqlDataAdapter(strSQL, conn)
Dim ds As New DataSet
da.Fill(ds, "ProductCodes")
With cboProdCode[INDENT].DataSource = ds.Tables("ProductCodes")
.DisplayMember = "Product Code"
.ValueMember = "Product Code"
.SelectedIndex = 0
[/INDENT]
End With
Can someone give me some tips on getting this to work?
Thanks in advance!