Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am designing a rdlc file which needs to display data from two different tables in a single dataset. How can i achieve this?

I wanna bind Fields from two different DataTables to TextBoxes in a rdlc file.

Thanks and Regards,
Posted
Updated 2-Jan-13 21:04pm
v3

you can create a sql view/store-procedure and set it as report-source
else
you can directly write sql-query while setting data-source for your report.

Happy Coding!
:)
 
Share this answer
 
Comments
zoozjar 3-Jan-13 2:34am    
Thanks for ur answer :)
I wanna bind data from two different DataTables to TextBoxes in a rdlc Report Form...! How can i achieve...

Thanks...! :)
Aarti Meswania 3-Jan-13 2:44am    
you are asking for parameters.

so, simply use comboboxes and bind both with two different data-sources.
like you usual do it as,
cmb1.datasource = dt1
cmb1.displayMember = "name"
cmb1.valuemember = "Id"...

if you want to use textboxes then learn auto-suggest in text box
http://www.codeproject.com/Articles/243368/AutoComplete-Textbox
You can create a DataTable type object with custom columns and then later add values to those columns when you query your data:

C#
DataTable joinedData = new DataTable();
joinedData.Columns.Add("Name",typeof(string));
joinedData.Columns.Add("Address",typeof(string));
joinedData.Columns.Add("Salary",typeof(int));


Here maybe Name and Address are in one table and maybe salary is on a different table.

When querying the data, use a left join or right join to join the tables based on Id or any type of column from your tables depending on your schema. After you make a join statement and store the data in a variable such as 'var query', then iterate through it and add each row's data like the example:

C#
var query = //Type some form of join LINQ statement to left join the 2 tables and store it in in query variable.

foreach (var item in query)
{
    joinedData.Rows.Add(item.Name,item.Address,item.Salary);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900