Sub empno()
        ComboBox2.Items.Clear()
        sql = "select empno from tbl_empinfo"
        If rs.State = 1 Then rs.Close()
        rs.Open(sql, conn)
        Do While rs.EOF = False
            ComboBox2.Items.Add(rs(0).Value)
            rs.MoveNext()
        Loop
    End Sub

how do i write this for an access connection???
  Dim sql As String ="select empno from tbl_empinfo"
  Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(sql, conn)
  Dim a As OleDbDataAdapter = New OleDbDataAdapter(cmd)
  Dim ds As New DataSet
  conn.Open()
  a.Fill(ds)
  conn.Close()
  For Each data_row In ds.Tables(0).Rows
  ComboBox2.Items.Add(data_row.ToString())
  Next
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.