Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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
Edited 13-Jan-13 1:21am
v2
Comments
Sandeep Mewara at 13-Jan-13 10:11am
   
And what have you tried?
Navas Khanj at 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
DaAp6.Fill(DSet6)
 
'========================================
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
Me.DataGridView1.Rows.Add()
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
Next
My Error is Not Show Amount Filed in DatagridView.. Please tell me how to slove this proble.
Navas Khanj at 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
good
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
  Permalink  
Comments
Maciej Los at 13-Jan-13 7:42am
   
+5!

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

  Print Answers RSS
0 OriginalGriff 490
1 Gihan Liyanage 338
2 ChauhanAjay 180
3 Vinay Mistry 160
4 Sergey Alexandrovich Kryukov 153
0 Sergey Alexandrovich Kryukov 9,011
1 OriginalGriff 7,941
2 CPallini 2,603
3 Richard MacCutchan 2,121
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 13 Jan 2013
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