Click here to Skip to main content
13,097,884 members (56,444 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Please Help to This i am using VB.Net

My Table Have Data Like this

RegNO   Name   PaidAmount Class Section 
A100	AAAA	500        I	A
A200	BBBB	750        I	A
A100	AAAA	150        I	A
A300	CCCC	400        I	A
A400	DDDD	300        I	A
A100	AAAA	100        I	A
A300	cccc	350        I	A
A400	DDDD	450        I	A		

I Want Show DataGridview Like this

RegNO   Name   PaidAmount Class Section 
A100	AAAA	750       I	A
A200	BBBB	750       I	A
A300	CCCC	750       I	A
A400	DDDD	750       I	A

[edit]Code block added - OriginalGriff[/edit]
Posted 13-Jan-13 1:15am
Updated 13-Jan-13 1:21am
Sandeep Mewara 13-Jan-13 10:11am
And what have you tried?
Navas Khanj 14-Jan-13 1:30am
Dim strSQL6 As String = "SELECT Regno, SName, SUM(AmountPaid), FeeType, Class, Section FROM FeeTrans where class='" & cboClass.Text & "' and section='" & cboSection.Text & "' and FeeType='" & cboFeeType.Text & "' GROUP BY Regno, SName, FeeType, Class, Section"
Dim DaAp6 As New SqlDataAdapter(strSQL6, con)
Dim DSet6 As New DataTable

With Me.DataGridView1

.Columns.Add("Regno", "RegNo")
.Columns.Add("SName", "Student Name")
.Columns.Add("AmountPaid", "Amount_Paid")
.Columns.Add("FeeType", "Fee Type")
.Columns.Add("Class", "Class")
.Columns.Add("Section", "Section")
.Columns(0).Width = 60
.Columns(1).Width = 150
.Columns(2).Width = 100
.Columns(3).Width = 100
.Columns(4).Width = 80
.Columns(5).Width = 80

' .AllowUserToAddRows = False
.EditMode = DataGridViewEditMode.EditProgrammatically
.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter
End With

For Each dr As DataRow In DSet6.Rows
With Me.DataGridView1.Rows(Me.DataGridView1.Rows.Count - 1)
.Cells("Regno").Value = dr("Regno")
.Cells("SName").Value = dr("SName")
.Cells("Amount_Paid") = dr("AmountPaid")
.Cells("FeeType").Value = dr("FeeType")
.Cells("Class").Value = dr("Class")
.Cells("Section").Value = dr("Section")
End With
My Error is Not Show Amount Filed in DatagridView.. Please tell me how to slove this proble.
Navas Khanj 13-Jan-13 10:53am
Thanks..It's Working.. DataSet.. but when i use DataTable that time this Error Show This Line .Cells("Amount_Paid") = dr("AmountPaid") Error Is:(Column 'AmountPaid' does not belong to table .)

1 solution

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

Solution 1

The query you need is:
SELECT RegNO, Name, SUM(PaidAmount), Class, Section FROM myTable
GROUP BY RegNO, Name, Class, Section
Maciej Los 13-Jan-13 7:42am

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 |
Web04 | 2.8.170813.1 | Last Updated 13 Jan 2013
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