Results 1 to 8 of 8

Thread: combobox prob

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Posts
    7

    combobox prob

    hi,
    i want to know how i can populate my combobox using data directly from database (sql server ) and after how can i store the selectedindex (ie item selected by user) in another table. if u have any codes, post it here for me. i badly need help. HELP ME PLTZZZZZ!


    thks. but do u have the equivalent code in vb.net please.a m using vb.net + sql server

  2. #2
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961

    Re: combobox prob

    You have to loop across a recordset or an array to populate the combo.

    VB Code:
    1. Dim rs as DAO.Recordset
    2. rs = db.OpenRecordset("MyTable")
    3. With rs
    4.   .MoveLast
    5.   .MoveFirst
    6.   Do While Not .EOF
    7.     MyCombo.Items.Add(.Fields("ListName").Value)
    8.     If Not .EOF Then .MoveNext
    9.   End Do
    10. End With
    11. MyCombo.Text = txtUserSelectedValue.Text

  3. #3
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: combobox prob

    Quote Originally Posted by pvbangera
    You have to loop across a recordset or an array to populate the combo.

    VB Code:
    1. Dim rs as DAO.Recordset
    2. rs = db.OpenRecordset("MyTable")
    3. With rs
    4.   .MoveLast
    5.   .MoveFirst
    6.   Do While Not .EOF
    7.     MyCombo.Items.Add(.Fields("ListName").Value)
    8.     If Not .EOF Then .MoveNext
    9.   End Do
    10. End With
    11. MyCombo.Text = txtUserSelectedValue.Text

    why O why would you be using DAO????

  4. #4
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961

    Re: combobox prob

    I am comfortable with it.

  5. #5
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: combobox prob

    Quote Originally Posted by pvbangera
    I am comfortable with it.
    well you should look into ADO.NET, not only is if faster than ADO, its worlds faster than DAO, DAO isn't even supported by MS anymore

  6. #6
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961

    Re: combobox prob

    will u suggest ne site or link to e-book for learning ADO.Net. I dont even know ADO.

  7. #7
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: combobox prob

    you can find lots of info here
    http://msdn.microsoft.com/data/Default.aspx

  8. #8
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    Re: combobox prob

    Quote Originally Posted by shei786
    hi,
    i want to know how i can populate my combobox using data directly from database (sql server ) and after how can i store the selectedindex (ie item selected by user) in another table. if u have any codes, post it here for me. i badly need help. HELP ME PLTZZZZZ!


    thks. but do u have the equivalent code in vb.net please.a m using vb.net + sql server
    hey you ask this question here. http://vbforums.com/showthread.php?t=327348

    try my code if that what you needed.

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