Click here to Skip to main content
13,143,693 members (27,719 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have a sql query where the data come in and want to convert rows into columns in a datagridview how I can do this.

I have a query which gets the "idStudent" "CodStudent" "NameStudent" and "notes1" "Notes2" "Notes3" "Notes4" and extracted as rows and I need to display it in a datagridview ("notes1" "Notes2" "Notes3 "" Notes4 ") as columns help please
Posted 21-Nov-12 3:48am
Updated 21-Nov-12 3:57am
ryanb31 21-Nov-12 9:58am
Sounds like you want to use the PIVOT function.
Fathima, Coimbatore 22-Nov-12 2:17am
Can u send the required format.
idoug12 22-Nov-12 3:00am
This is the required format that I want to show in a datagrigview in VB.NET
Id Student----CodStudent--- NameStudent-----Notes1-----Notes2----Notes3---Notes4
---1----------000000123------John Adams------- A---------B---------A+-------B
---2----------000000124------Lisa Simpson----- A+--------B---------A+-------B

this format I get from the SQL query, as you can see I load activities as rows

IdStudent----CodStudent---- NameStudent------ activities Notes
--1----------000000123------John Adams------- Notes1---- A
--1----------000000123------John Adams------- Notes2---- B
--1----------000000123------John Adams------- Notes3---- A+
--1----------000000123------John Adams------- Notes4---- B
--2----------000000124------Lisa Simpson------Notes1---- A+
--2----------000000124------Lisa Simpson------Notes2---- B
--2----------000000124------Lisa Simpson------Notes3---- A+
--2----------000000124------Lisa Simpson------Notes4---- B

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Try this. Actually your question is not understandable.

TextBox1.Text = datatable.Rows(0).Item("column_name").ToString
TextBox2.Text = datatable.Rows(0).Item("column_name").ToString

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170915.1 | Last Updated 22 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100