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
Your Filters
Interested
Ignored
     
0 Shai Vashdi 1,518
1 OriginalGriff 383
2 Manas Bhardwaj 324
3 Tadit Dash 305
4 Peter Leow 255
0 Sergey Alexandrovich Kryukov 9,575
1 OriginalGriff 5,856
2 Peter Leow 4,405
3 Maciej Los 3,540
4 Abhinav S 3,513


Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 13 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid