I want move and sum dgvA to dgvB
example data in dgvA
| ID | Name | Money |
| 1 | AAAAA | 50 |
| 2 | AAAAA | 10 |
| 3 | BBBBBB | 5 |
| 4 | BBBBBB | 10 |
| 5 | BBBBBB | 20 |
I want move And sum dgvA to dgvB
| ID | Name | Money |
| 1 | AAAAA | 60 |
| 2 | BBBBBB | 35 |
need help ....code
Please also recommended code ...
| ID | Name | Money |
| 1 | AAAAA | 50 |
| 2 | AAAAA | 10 |
| 3 | BBBBBB | 5 |
| 4 | BBBBBB | 10 |
| 5 | BBBBBB | 20 |
| ID | Name | Money |
| 1 | AAAAA | 60 |
| 2 | BBBBBB | 35 |
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Aug 29, 2013, 8:59 PM EDT
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace
{
public partial class Form2 : Form
{
SqlConnection con = new SqlConnection(@"server = HOME-SAT/SQLEXPRESS;data source = .; initial catalog = test; user id=sa;pwd =pintu ;integrated security = SSPI");
SqlCommand com;
SqlDataAdapter sqlda;
DataSet ds;
string str;
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
con.Open();
str = "select distinct Name,sum(Money)as Money from emp group by Name";
com = new SqlCommand(str, con);
sqlda = new SqlDataAdapter(com);
ds = new DataSet();
sqlda.Fill(ds, "emp");
dataGridView2.DataMember = "emp";
dataGridView2.DataSource = ds;
con.Close();
}
private void Form2_Load(object sender, EventArgs e)
{
con.Open();
str = "select * from emp";
com = new SqlCommand(str, con);
sqlda = new SqlDataAdapter(com);
ds = new DataSet();
sqlda.Fill(ds, "emp");
dataGridView1.DataMember = "emp";
dataGridView1.DataSource = ds;
con.Close();
}
}
}