//First we should add the following Namespace
using System.Data;
using System.Data.OleDb;
{
OleDbConnection connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\ERDATA.mdb;Persist Security Info=True");
connection.Open();
String query = "Select sum(amount) FROM Tran";
OleDbDataAdapter dadaptor = new OleDbDataAdapter(query, connection);
DataSet ds = new DataSet();
dadaptor.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
String sum = ds.Tables[0].Rows[0][0].ToString();
lblTotal.Text = "Rs. " + sum;
}
connection.Close();
connection.Dispose();
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment