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???

Recommended Answers

You will want to look into this.

Jump to Post

All 2 Replies

  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 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.