Help setting label boxes with values from MySql database

Hi,
    I have the following code:

    cnn1.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=;" & _
                          "DATABASE=;USER=;PASSWORD=;OPTION=3;"
    cnn1.Open
 

     SQL1 = "SELECT content_url FROM content WHERE content_category_id ='1'"
     rs1.Open SQL1, cnn1, adOpenForwardOnly, adLockOptimistic

   Set cnn1 = Nothing

Which makes a DB connection, however I also have 5 label boxes on a form and what I wish to do is scan the content_url table and display each promotion which is searchable via the content_category_id=1 and display each in their own label box, how can this be completed?

Thanks
damianb123Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dirk HaestProject managerCommented:
Loop over your recordset
In example below I assume that you created an array of your textboxes (all with the same name, but another index)

num = 0
Do While Not rs.EOF
    textbox(i).Text = rs!content_url
    num = num + 1
     rs.MoveNext
Loop
0
damianb123Author Commented:
They are label boxes, so they cannot be changed, but I didn't configure as an array, should I change to textboxes and set as an array?

Thx
0
Dirk HaestProject managerCommented:
You can change the caption of the labels.

If you don't have an array, you'll need to do something like this...

num = 0
Do While Not rs.EOF
   if num=0 then label1.caption = rs!content_url end if
   if num=1 then label2.caption = rs!content_url end if
   if num=2 then label3.caption = rs!content_url end if
   if num=3 then label4.caption = rs!content_url end if
   if num=4 then label5.caption = rs!content_url end if
    num = num + 1
     rs.MoveNext
Loop
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
damianb123Author Commented:
I changed my label boxes to an array in the end called Voucher and used this:

num = 0
Do While Not rs1.EOF
    Voucher(i).Caption = rs1!content_url
    num = num + 1
     rs1.MoveNext
Loop

Which does work, but ONLY populates the first label box out of the five listed.  There are three items in my database, which should be showing on the first 3 label boxes....

What have I done wrong????

Thx
0
damianb123Author Commented:
This worked a treat, thanks v much!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.