Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Quote:
My Table Details
 
Table1 Name is (FeesTransaction)

RegNO ST_Name Amount_Paid Class Section
A100 AAAA 750 I A
A200 BBBB 500 I B
A300 CCCC 800 I A
A400 DDDD 450 I A
 
Table2 Name is (FeesMasterN1)
 
RegNO SName TotalAmount Class Section
A100 AAAA 1500 I A
A200 BBBB 1500 I B
A300 CCCC 1500 I A
A400 DDDD 1500 I A
 

I Want DataGridView Like This


RegNO ST_Name PaidAmountTotalAmountClass Section
A100 AAAA 750 1500 I A
A200 BBBB 500 1500 I B
A300 CCCC 800 1500 I A
A400 DDDD 450 1500 I A
 
BUT MY DATAGRIDVIEW DISLPAY NOW LIKE THIS
 
RegNO ST_Name PaidAmountTotalAmountClass Section
A100 AAAA 750 1500 I A
A100 AAAA 750 1500 I A
A200 BBBB 500 1500 I B
A200 BBBB 500 1500 I B
A300 CCCC 800 1500 I A
A300 CCCC 800 1500 I A
A400 DDDD 450 1500 I A
A400 CCCC 800 1500 I A

 
How To Slove this Error Please Help Me..
My COde is..
con.Open()
 
DataGridView1.Rows.Clear()
DataGridView1.Columns.Clear()
Dim strSQL7 As String = "SELECT FeesTransaction.Regno, FeesTransaction.ST_Name, Sum(FeesTransaction.Amount_Paid)as TotalAmountPaid, FeesMasterN1.FeeAmount, FeesTransaction.FeeType, FeesTransaction.Class, FeesTransaction.Section FROM FeesTransaction INNER JOIN FeesMasterN1 ON FeesTransaction.Regno=FeesMasterN1.Regno WHERE FeesTransaction.class='" & cboClass.Text & "' and FeesTransaction.section='" & cboSection.Text & "' and FeesTransaction.FeeType='" & cboFeeType.Text & "' GROUP BY FeesTransaction.Regno, FeesTransaction.ST_Name, FeesTransaction.FeeType, FeesTransaction.Class, FeesTransaction.Section, FeesMasterN1.FeeAmount"
 
Dim DaAp7 As New SqlDataAdapter(strSQL7, con)
Dim DSet7 As New DataTable
DaAp7.Fill(DSet7)
 
'========================================
With Me.DataGridView1
.Columns.Add("Regno", "RegNo")
.Columns.Add("ST_Name", "Student Name")
.Columns.Add("Amount_Paid", "Amount Paid")
.Columns.Add("Remaining", "Remaining")
.Columns.Add("TotalAmt", "Total Amount")
.Columns.Add("FeeType", "Fee Type")
.Columns.Add("Class", "Class")
.Columns.Add("Section", "Section")
.Columns(0).Width = 85
.Columns(1).Width = 250
.Columns(2).Width = 150
.Columns(3).Width = 150
.Columns(4).Width = 140
.Columns(5).Width = 150
.Columns(6).Width = 90
.Columns(7).Width = 90
' .AllowUserToAddRows = False
.EditMode = DataGridViewEditMode.EditProgrammatically
.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter
End With
 
For Each dr As DataRow In DSet7.Rows
Me.DataGridView1.Rows.Add()
With Me.DataGridView1.Rows(Me.DataGridView1.Rows.Count - 1)
.Cells("Regno").Value = dr("Regno")
.Cells("ST_Name").Value = dr("ST_Name")
.Cells("Amount_Paid").Value = dr("TotalAmountPaid")
'.Cells("TotalAmt").Value = dr("FeeAmount")
.Cells("FeeType").Value = dr("FeeType")
.Cells("Class").Value = dr("Class")
.Cells("Section").Value = dr("Section")
End With
Next
con.Close()
Posted 14-Jan-13 22:56pm

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 420
1 OriginalGriff 230
2 DamithSL 175
3 Dave Kreskowiak 120
4 Zoltán Zörgő 114
0 OriginalGriff 7,740
1 DamithSL 5,694
2 Sergey Alexandrovich Kryukov 5,404
3 Maciej Los 5,061
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 15 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