Ok, Heres The Situation. I Have A Combo Box That Gets Populated With(String) Information From A Sql Query. However, The Information That Will Be Saved Back Into The Database Will Be In An Integer Form, Which Is The ID Number. How Do I Use Valuemember To Correspond Each Item In The Combobox With The Field ID. Heres Some Code, If Someone Could Show Me Where And How To Add In That Information, It Would Be Much Appreciated.
Thanks In Advance
-=Simcoder=-
Code:
[VB]
Private Sub PopulateBoxes()
Try
Dim strSelect As String
Dim Command As New SqlCommand
Dim SqlReader As SqlDataReader
DefineControls()
Command.Connection = SQLConn
strSelect = "SELECT [fldClassName] FROM tblClasses"
Command.CommandText = strSelect
This Is Where I Tried To Use Valuemember
cboClass.DataSource = SqlReader
cboClass.ValueMember = "fldClassName"
SqlReader = Command.ExecuteReader()
Do While SqlReader.Read()
If Not cboClass.Items.Contains(SqlReader.Item(0)) Then
If Not IsDBNull(SqlReader.Item(0)) Then
cboClass.Items.Add(SqlReader.Item(0))
End If
End If
Loop
SqlReader.Close()
Catch
MessageBox.Show(Err.Description)
End Try
End Sub
And When The Index Changes On The Combo Box, Change The Text
To Say What Valuemember Is Selected
Private Sub cboClass_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboClass.SelectedIndexChanged
Me.Text = cboClass.SelectedValue()
End Sub
[/VB]
Thanks In Advance
-=Simcoder=-