rows in table to columns in dbgrid


I have a table with several rows and I want to display them in a dbgrid as columns. Example: (the text between brackets is the columnheader)

The table looks like this:
[Weeknr]     [Hours]    [Text]
  01                  22         txt1
  02                  12         txt2
  03                  44         txt3

And I want it to be displayed in a dbgrid like this:

[01]  [02]  [03]
 22     12    44
txt1  txt2  txt3

Doe anyone know how to do this?
Who is Participating?
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.

Add an ADODC control to your form,
set the properties and connect the DBGrid to the ADODC.
The grid will be filled automaticly !
ConifeerAuthor Commented:
If I do that the dbgrid would look like this:
[Weeknr]     [Hours]    [Text]
  01                 22          txt1
  02                 12          txt2
  03                 44          txt3

But I want the weeknumbers as the columnheaders of the dbgrid.
Yes, but you can set the columnheader designtime and runtime !
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

ConifeerAuthor Commented:
How do I set the columnheaders runtime to the weeknumbers?
Somthing like:

Counter = 0
For i = WeekStart To WeekEnd
  DataGrid1.Columns(Counter).Caption = "Month " & CStr(Counter)
  Counter = Counter + 1
Next i

Be sure to have enough columheader:
Else add them :

Dim col as Column
Set col = DataGrid1.Columns.Add
col.Caption = "Hello"
Set col = Nothing


ConifeerAuthor Commented:
Adjusted points to 60
ConifeerAuthor Commented:
Ok, now I have the columnheaders but how do I fill the rest of the datagrid. Do I have to fill it cell by cell and if so, how do I do that.
Since it is not possible to add rows to a datagrid you have to build a 'help-table':
Build it containing 52 field (named something like NAME1 thru NAME52).
Then write a stored procedure to fill this table:
The first row with all availible week,
the second row with the hours, the third row with the text.
Then connect the datagrid to this table.

Other way: don't use the datagrid but the listview !
Ok, you have to write some code if you want to edit the field, but it's lots faster and you don't have to use the help-table !


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
ConifeerAuthor Commented:
Well, this is the core of my problem. If there is no way to add rows then i would have to use that help table, because there is a lot of editing involved.
Well, thank you anyway for your time.
You're welcome !

:-) RoverM
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.