damianb123
asked on
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
I have the following code:
cnn1.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=;" & _
"DATABASE=;USER=;PASSWORD=
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
ASKER
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
Thx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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
ASKER
This worked a treat, thanks v much!
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