By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,417 Members | 904 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,417 IT Pros & Developers. It's quick & easy.

How To Join Two Table in DataGridView

P: 1
Hi.. I am Using This Code For Join Table..
Expand|Select|Wrap|Line Numbers
  1. con.Open()
  2.         Dim strSQL5 As String = "SELECT Fees_Transaction.Regno, Fees_Transaction.ST_Name, SUM(Fees_Transaction.Amount_Paid) as FTAmountPaid, SUM(FeesMaster.FeeAmount) As TotalFeeAmount FROM Fees_Transaction" & _
  3.             " INNER JOIN FeesMaster ON Fees_Transaction.Regno=FeesMaster.Regno WHERE  Fees_Transaction.class='" & cboClass.Text & "'  AND Fees_Transaction.FeeType=FeesMaster.FeeType " & _
  4.             "GROUP BY Fees_Transaction.Regno, Fees_Transaction.ST_Name"
  5.  
  6.  
  7.         Dim DaAp5 As New SqlDataAdapter(strSQL5, con)
  8.         Dim DSet5 As New DataTable
  9.         DaAp5.Fill(DSet5)
  10.         '========================================
  11.         With Me.DGV1
  12.             .Columns.Add("Regno", "RegNo")
  13.             .Columns.Add("ST_Name", "Student Name")
  14.             .Columns.Add("Amount_Paid", "Amount Paid")
  15.             .Columns.Add("Remaining", "Remaining")
  16.             .Columns.Add("TotalAmt", "Total Amount")
  17.             .Columns.Add("FeeType", "Fee Type")
  18.             .Columns.Add("Class", "Class")
  19.             .Columns.Add("Section", "Section")
  20.             .Columns(0).Width = 85
  21.             .Columns(1).Width = 250
  22.             .Columns(2).Width = 150
  23.             .Columns(3).Width = 150
  24.             .Columns(4).Width = 140
  25.             .Columns(5).Width = 150
  26.             .Columns(6).Width = 90
  27.             .Columns(7).Width = 90
  28.             ' .AllowUserToAddRows = False
  29.             .EditMode = DataGridViewEditMode.EditProgrammatically
  30.             .ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter
  31.         End With
  32.  
  33.         For Each dr As DataRow In DSet5.Rows
  34.             Me.DGV1.Rows.Add()
  35.             With Me.DGV1.Rows(Me.DGV1.Rows.Count - 1)
  36.                 .Cells("Regno").Value = dr("Regno")
  37.                 .Cells("ST_Name").Value = dr("ST_Name")
  38.                 .Cells("Amount_Paid").Value = dr("FTAmountPaid")
  39.                 .Cells("TotalAmt").Value = dr("TotalFeeAmount")
  40.                 '  .Cells("FeeType").Value = "Total"
  41.                 '   .Cells("Class").Value = dr("Class")
  42.                 '   .Cells("Section").Value = dr("Section")
  43.             End With
  44.         Next
  45.  
  46.           con.Close()

But This Code is Woking.. Wht is my Problem.. I Use SUM both Table. Fees_Transcation SUM Function working For Two condition (regno and Feetype) and FeesMaster I Want Sum FeeAmount For Regno and Class wise but it's not sum that condition.. Please wht prb i did ..
Jan 24 '13 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,382
Do you mean the code is not working? I have no idea what you are trying to say. Your english is unclear. Try posting sample data and results and reword what you're trying to do.
Jan 24 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.