Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8346009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:52:09+00:00 2026-06-09T06:52:09+00:00

I am currently trying to populate a drop box on a form in VB.Net

  • 0

I am currently trying to populate a drop box on a form in VB.Net from an MDB database for a project I am working on for work.

I have a table called “Months” in a database called “cancmov”, and the field i am trying to pull from is called MoveMonth.

The current code i am using is:-

Private Sub drpMovedFrom_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles drpMovedFrom.SelectedIndexChanged


    Dim ConnnectionString As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Admin\Desktop\CancellationsAndMovements\CancellationsandMovements\cancmov.mdb"
    Dim db As String = "SELECT MoveMonth FROM Months"
    Dim cn As New OleDbConnection(ConnnectionString)
    Dim da As New OleDbDataAdapter(db, cn)
    Dim ds As New DataSet()

    da.Fill(ds, "MoveMonth")

    With drpMovedFrom
        .DataSource = ds.Tables("MoveMonth")
        .SelectedIndex = 0
    End With

End Sub

As you can probably gather from the above, I am currently in the process of learning, so a lot of the above i am trying to get my head around. I actually pulled the above code from a similar question that had been asked i found on google. Any help will be greatly appreciated, even if it is just to point me at a resource where i can learn to do this for myself.

Thanking you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:52:13+00:00Added an answer on June 9, 2026 at 6:52 am

    A couple things right off the bat:

    You are calling this code when the drop down index changes. Probably not what you want since it will always set it back to zero.

    Also, try enclosing your disposable objects in using brackets:

    Private ds As New DataSet()
    Private ConnnectionString As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Admin\Desktop\CancellationsAndMovements\CancellationsandMovements\cancmov.mdb"
    
    Protected Overrides Sub OnLoad(e As EventArgs)
      Dim db As String = "SELECT MoveMonth FROM Months"
    
      Using cn As New OleDbConnection(ConnnectionString)
        Using da As New OleDbDataAdapter(db, cn)
          da.Fill(ds, "MoveMonth")
        End Using
      End Using
    
      With drpMovedFrom
          .DisplayMember = "MoveMonth"
          .DataSource = ds.Tables("MoveMonth")
          .SelectedIndex = 0
      End With
    
      MyBase.OnLoad(e)
    End Sub
    

    Also, the ComboBox has DisplayMember and ValueMember properties that you map to your DataSource. DisplayMember is the value you see visible in the list, ValueMember is typically an ID value for the visible property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to populate an UITableView from a plist downloaded from the internet.
Background - I'm trying to populate a drop down list with state information from
I am currently trying to populate a treeview from xml that is returned to
I'm trying to populate a table structure with around 5 fields of data from
I am trying to pass vars from a form using drop down lists, that
I'm currently trying to populate a table with thumbnails which point to images in
Currently I'm trying to populate a site dynamically. When I step through the code,
Im currently trying to downlaod a audio track from a WCF, i need some
I have no working knowledge of Java script and am trying to get into
I am currently trying to populate a cursor in the procedure. like that :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.