bind combobox at runtime from recordset

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #3059
    Ritesh
    Member

    I have a combobox control named cmbEmpName on the windows form i want to bind this combobox from database.
    i am using adodob recordset for binding combobox. i have got a recordset but how i can bind all EmployeeName from this recordset. i am using this code:

    Dim con As New ADODB.connection
    Dim rs As New ADODB.recordset
    rs = Getrecords(ConStr, strQuery)

    please suggest me

    #3060

    Hello Ritesh

    Try this code:

    Dim con As New ADODB.connection
    Dim rs As New ADODB.recordset
    rs = Getrecords(ConStr, strQuery)
    If rs.RecordCount > 0 Then
    rs.MoveFirst()
    For i As Integer = 0 To rs.RecordCount – 1
    cmbEmpName.items.Add(rs.Fields(“EmployeeName”).value)
    rs.MoveNext()
    Next
    End If

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.