Results 1 to 6 of 6

Thread: [RESOLVED] Population in VB

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2008
    Posts
    90

    Resolved [RESOLVED] Population in VB

    Hi, Hope you can help. I am trying to populate a dropdownlist with a list of the usernames that are stored in my Access database so that the users dont have to keep running upto me and ask for there username. Thanks in advance

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: Population in VB

    You need to know the basics or the database management.
    Meaning, connecting to a database and retrieving data to an object.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2008
    Posts
    90

    Re: Population in VB

    Hi thanks for the reply i dont have my application at the minute im at work (YAY) so i will try and remember off the top of my head

    Dim connectionString As String =
    ("provider=Microsoft.Jet.OLEDB.4.0;" + "data source = W:\Apps\Mgmt\data.mdb")

    hope this helps.

  4. #4
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: Population in VB

    Ok.
    What i meant was that if you know how to get your data from the database there are many ways to use it.
    If you get the data then you can fill a dataset and populate your controls by setting their binding properties or by manually feeding the data.
    There are many articles here and on msdn on how you can do that.

  5. #5
    Fanatic Member
    Join Date
    Feb 2007
    Location
    Eindhoven
    Posts
    828

    Re: Population in VB

    here is an example of manual feeding of data

    vb Code:
    1. Dim connection As SqlClient.SqlConnection = New SqlClient.SqlConnection("Your connection string")
    2.         Dim Command As SqlClient.SqlCommand = New SqlClient.SqlCommand("SELECT UserName FROM UserNameTable")
    3.  
    4.         Try
    5.             connection.Open()
    6.             Dim reader As SqlClient.SqlDataReader = Command.ExecuteReader
    7.             If reader.HasRows Then
    8.                 While reader.Read
    9.                     Me.ComboBox1.Items.Add(reader.Item("Username").ToString)
    10.                 End While
    11.                 reader.Close()
    12.             End If
    13.         Catch ex As Exception
    14.             Debug.WriteLine(ex.ToString)
    15.         Finally
    16.             connection.Close()
    17.         End Try

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2008
    Posts
    90

    Re: Population in VB

    Hi, Thanks for that ill give it a try, looks the part let you know how i get on

    Many Thanks
    Stuart Jones
    Network Manager

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width