SNO Particulars Amt
1 Diesel Cost 1200
2 Rental Cost 1000
3 Service Tax 500
4 Edu Cess 200
from the above i arrive using crsytal report. i want to get the total 2900.how to get the total.
Total 2900
Satyapriya NayakPosted Oct 16, 2012, 10:05 AM
using System;
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.OleDb;
namespace Grade_Count
{
public partial class Form1 : Form
{
string ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["dsn"];
OleDbCommand com;
OleDbDataAdapter oledbda;
string str;
DataSet ds;
public Form1()
{
InitializeComponent();
}
private void btn_total_Click(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection(ConnectionString);
con.Open();
str = "select sum(Amt) from test";
com = new OleDbCommand(str, con);
txt_total_amount.Text = com.ExecuteScalar().ToString();
con.Close();
}
private void Form1_Load(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection(ConnectionString);
con.Open();
str = "select * from test";
com = new OleDbCommand(str, con);
oledbda = new OleDbDataAdapter(com);
ds = new DataSet();
oledbda.Fill(ds, "test");
dataGridView1.DataMember = "test";
dataGridView1.DataSource = ds;
con.Close();
}
}
}
Thanks