ASP.NET - how to display in gridview reports - Asked By Jahir on 14-Feb-12 02:15 AM

i have from date, services, userid, username, credit debit(radiobtnlist) amount

now i want to display reports from tables each are diff tables how ?
i want qry ?

adap = new SqlDataAdapter("select a.fromdate,b.servicename,c.userid,c.username,d.type,e.debit, from creditadd a,serve b,memreg c, serviceamount d,creditdeduct e where a.fromdate between 07-02-2012 and 14-02-2012", con);

ds = new DataSet();


GridView1.DataSource = ds;


how to take reports from other tables ?

Somesh Yadav replied to Jahir on 14-Feb-12 02:24 AM
Here is the solution.

public DataTable compareDataTables(DataTable First, DataTable Second) { First.TableName = "FirstTable"; Second.TableName = "SecondTable";

        //Create Empty Table
DataTable table = new DataTable("Difference");
DataTable table1 = new DataTable();
//Must use a Dataset to make use of a DataRelation object
(DataSet ds4 = new DataSet())
//Add tables
.Tables.AddRange(new DataTable[] { First.Copy(), Second.Copy() });

//Get Columns for DataRelation
DataColumn[] firstcolumns = new DataColumn[ds4.Tables[0].Columns.Count];

for (int i = 0; i < firstcolumns.Length; i++)
[i] = ds4.Tables[0].Columns[i];

DataColumn[] secondcolumns = new DataColumn[ds4.Tables[1].Columns.Count];

for (int i = 0; i < secondcolumns.Length; i++)
[i] = ds4.Tables[1].Columns[i];

//Create DataRelation
DataRelation r = new DataRelation(string.Empty, firstcolumns, secondcolumns, false);


//Create columns for return table
for (int i = 0; i < First.Columns.Count; i++)

Hope it helps.
Web Star replied to Jahir on 14-Feb-12 02:30 AM
If you want to display data as report format in girdview where as data filter from different table than you just use JOIN query when you fetch data from database to fill DataSet only other thing are same.
Sandeep Mittal replied to Jahir on 14-Feb-12 02:31 AM
I think you want to show something like header/ details relationship data in gridview

Refer this post ->
kalpana aparnathi replied to Jahir on 14-Feb-12 03:30 AM