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

Edited by Neethaa: need an access connection code

3
Contributors
2
Replies
5
Views
4 Years
Discussion Span
Last Post by xerohomicide
0
  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

Edited by xerohomicide

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.