Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Updated 21-Nov-12 3:57am
v2
Comments
ZurdoDev 21-Nov-12 9:58am    
Sounds like you want to use the PIVOT function. http://msdn.microsoft.com/en-us/library/ms177410(v=sql.105).aspx
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

Try this. Actually your question is not understandable.

VB
TextBox1.Text = datatable.Rows(0).Item("column_name").ToString
TextBox2.Text = datatable.Rows(0).Item("column_name").ToString
...
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900