Quote Originally Posted by tvb2727 View Post
I would like to connect it with the way I posted earlier instead of connecting it to the data source. The reason is because I might read this data via a stream reader instead of the database. So how can I set the selected value with the code I posted?

Not sure why cant you use DataTable even if you are fetching data from StreamReader?

anyway the alternative could be:
Code:
Private Sub load_year_combobox()
        Try : Dim SQLdtr2 As Data.OleDb.OleDbDataReader : Dim SQLcmd As Data.OleDb.OleDbCommand
Dim arrYear As New ArrayList
            Dim sql_select As String = "" : Dim timer_integer As Integer = 0 : Dim timer_count As Integer = 0
            sql_select = "SELECT db_name, year_id " + _
                "FROM tbl_past ORDER BY ID"
            SQLcmd = New Data.OleDb.OleDbCommand(sql_select, mainconnection)
            mainconnection.Open() : SQLdtr2 = SQLcmd.ExecuteReader
            
            Do : While SQLdtr2.Read()
                    arrYear.Add(New ComboBoxItem(SQLdtr2 ("year_id"), SQLdtr2 "db_name"))               
 End While
            Loop While SQLdtr2.NextResult : mainconnection.Close()
cmbYear.DataSource = arrYear
cmbYear.DisplayMemeber = "db_name"
cmbYear.ValueMember = "year_id"
        Catch ex As Exception
            MsgBox(ex.ToString) : m.errors(show_error, ex.ToString, error_l)
        End Try
    End Sub