Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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 4:48am
idoug12383
Edited 21-Nov-12 4:57am
RyanDev129.8K
v2
Comments
ryanb31 at 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 at 22-Nov-12 2:17am
   
Can u send the required format.
idoug12 at 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
good
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
...
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 380
1 OriginalGriff 250
2 DamithSL 210
3 Kornfeld Eliyahu Peter 200
4 Peter Leow 95
0 OriginalGriff 7,315
1 DamithSL 5,199
2 Sergey Alexandrovich Kryukov 4,917
3 Maciej Los 4,866
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 22 Nov 2012
Copyright © CodeProject, 1999-2014
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