473,511 Members | 14,799 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How To Join Two Table in DataGridView

1 New Member
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
1 4322
Rabbit
12,516 Recognized Expert Moderator MVP
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

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

Similar topics

1
18508
by: Keith Simeon | last post by:
Hello all, I've recently started playing with Hibernate, and have a question regarding many-to-many relationships using a join or cross table (I've also heard these referred to as a transition...
2
2007
by: bodleyhenley | last post by:
Please help me with this! :) I have a database of servers, one of the things I am recording information about is what software is on each server. Obviously this is a many to many so I have a...
6
6284
by: davegb | last post by:
I'm trying to create a self-join table to show the relationship between employee and supervisor. In another thread, I was advised to create a SupervisorID in the employee table, a separate...
1
1618
by: LL | last post by:
Hi, My sql join two table, how to call the fill method? thanks. string sqlStr = "select * from table1, table2"; SqlDataAdapter myCommand = new SqlDataAdapter(sqlStr, myConnection);DataSet...
3
1681
by: CanFlightSim | last post by:
I am not very strong in databases, so you must forgive any obvious stupidity. After having a good look at our Sales Managemend database, we decided there is something basially wrong. Our Agents...
3
2079
by: ssims | last post by:
I've been thinking about this problem for awhile, and can't seem to come up with a valid answer. I've got two tables, Surveys and Instructors. When a survey is completed there are one or two...
9
2406
by: koehlerc14 | last post by:
I'm trying to create a form that imports a text file and join zip code fields to our "Master" database x2. I import the txt file and name it based on a "strTableName" which includes the date, a...
0
1121
by: RP | last post by:
I am using I want to transfer certain columns from my DataGridView (or table) to a text file. Though it is easy to read a row and write into a file, but I want that each column written is equally...
6
3785
by: BD | last post by:
Hi, all. I need to enforce a one-to-many relationship on 2 tables, with a join table. Say the join table contains account information. It has cust_no and acct_no. Both cust_no and acct_no are...
0
1157
by: Todd Nichols | last post by:
I have the main form for the "one" side of the relationship and a subform for the "many" side, linked by the primary key of the main table to the foreign key of the join table (the many-side table). ...
0
7252
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7371
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7517
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5077
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1583
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.