sql and dynamic labels...

F

Frank

Hello,

I hope this is the correct group to ask this question. I am fairly new
to programming, but have a gut feeling this is a pretty easy problem
to overcome. I hope I can explain the problem clearly enough.
Using VB.Net 2003 and MySql db.
I have a table (mySql) with the following fields:

main_category| category| sub_category| answer|date

Basically, the data will be along these lines:
Neuro | LOC | Status | answer1|date
Neuro | LOC | Status | answer2|date
Neuro | LOC | Status | answer3|date
Senso| Visi | Clarity | answer1|date
Senso| Visi | Clarity | answer2|date
etc...
I am trying to query the db and create labels in order to present the
user with the data in the following structure:

Main Category
Category
Sub Category
answer1
answer2
answer3
...

Main Category
Category
Etc...

I can create the labels ok, but I can't seem to find a way to
structure the data in the above format on the form for the user to
review.
Here's some code off the top of my head (not at the office right now,
so I will have to go by memory!):

dim myMain as new Arraylist
dim myCat as new Arraylist
dim mySub as new arraylist
dim myAns as new arraylist

dim strSql as string = "Select * from Test where date=" & strDate
myCmd = new mySqlcommand(strSql,myCon)
dim myRead as mysqldatareader = myCmd.executequery
do while myRead.read()
myMain.add(myRead("main_category"))
myCat.add(myRead("category")
....same for the other 2 fields
loop
myCon.close

dim myLabel as new label
for i = 0 to myMain.count - 1
myLabel = new label
myLabel.text = myMain(i)
myLabel.location = new system.drawing.point(x,y)
me.controls.add(myLabel)

myLabel = new label
myLabel.text = myCat(i)
myLabel.location = new system.drawing.point(x,y + 10)
me.controls.add(myLabel)
y += 20

....Then the sub categories
....then the answers...
next

Now, this is where things get a little tricky. As you can see from the
db, these arrays will be of different lengths, but I need to keep the
answers "aligned" with the Main Categories, Categories, and
Subcategories. Could someone please show me the light? Is it the way I
have structured the table, or does the answer lie elsewhere? Any help
will be greatly appreciated!

Thanks!!

Frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top