Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles MyBase.Load Dim cn As New OleDbConnection Dim cm As OleDbCommand Dim da As New OleDbDataAdapter Dim strCnn As String Dim ds As New DataSet Dim strSQL As String strSQL = "SELECT * FROM tblDbTypes;" 'Function to build Connection string strCnn = CnnCtrlDB(strAppPath & "\CtrlDB.ACCDB") cn = New OleDbConnection(strCnn) Try 'Function to check db connection status Dim bCnn As Boolean = DBConnectionStatus(strCnn) If bCnn Then cn.Open() cm = New OleDbCommand(strSQL, cn) da.SelectCommand = cm da.Fill(ds) da.Dispose() cm.Dispose() cn.Close() End If 'This SHOULD set the combobox index to 'number in the DBID field in the DB - IT DON'T tsCboDBTypes.ComboBox.ValueMember = "DBID" 'This sets the combobox's DisplayMember to the 'value contained in the Db_Type field tsCboDBTypes.ComboBox.DisplayMember = "Db_Type" 'Binds the combobox to the DataSet tsCboDBTypes.ComboBox.DataSource = ds.Tables(0) Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub
'This sets the combobox.ValueMember to the 'number in the DBID column(field) of the dataset. 'I believe the ValueMember Method replaces the 'NewIndex method in VB6. ComboBox.ValueMember = "DBID"
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)