report

marjune

Member
Joined
May 4, 2010
Messages
16
Programming Experience
Beginner
hi, i'm confused about how to make a report which is from join tables!!
 
A report is a report. It only has one data source. How that data source was created is pretty much irrelevant to the report. If you want to join multiple tables then your SQL query needs to include a JOIN.
 
VB.NET:
Expand Collapse Copy
Dim sSqlStatement = "SELECT * FROM TableName;"
Dim da = New SqlDataAdapter(sSqlStatement, oConnection)
Dim ds = New DataSet
da.Fill(ds, "TableName")

DataGridView1.DataMember = "TableName"
DataGridView1.DataSource = ds
[CODE/]
 
If what you actually wanted was to display data in a DataGridView then that's what you should have said in the first place. When you say "report" it implies using Crystal Reports or SQL Server Reporting Services or something like that. A grid is just a grid.

Anyway, as I said earlier, the original source of the data is completely irrelevant to the grid. It simply displays the contents of a DataTable with no regard whatsoever for where the data came from. You already have the answer to your question:
If you want to join multiple tables then your SQL query needs to include a JOIN.
Are you really saying, without actually saying, that you don;t know how to perform a join in SQL? If so then this is a database question, not a WinForms question.
 
dude!!! i don't have problem with sql query, join, etc...
my problem is how to pass the data source from my query to the report,,
 
dude!!! you're already doing it!!!

I will say again, the DataGridView doesn't care where the data in the DataTable came from. Your SQL query can take data from 1, 2 or a thousand tables in the database. It doesn't matter. It's still one query. One query populates one DataTable and you already know how to bind a DataTable to a DataGridView because you're already doing it. I will say again, all you need to do is change your query to include a join. Everything else is the same. I don't know how to say it any more clearly.
 
my datagrid is just an example of what youre asking lately that how can i pass data from a single table as the data source!!!

But the real issue here is how to pass a data source to the Report1.rdlc
 
my datagrid is just an example of what youre asking lately that how can i pass data from a single table as the data source!!!

But the real issue here is how to pass a data source to the Report1.rdlc

No, that is NOT an example of what I asked. I specifically asked how you pass data from a single table to the report. Let's be clear here: do you know how to set the data source for a reporting services report when the data comes from a single table or not? If you do then you can answer my question: how are you doing that?
 
You know, you don't actually have to add two exclamation marks to the end of everything you post. If you were speaking, would you be shouting all of those comments? If not, what are the exclamation marks for?

Back on topic, the answer is exactly what I've been saying all along. You use a DataTable as the data source for your report just as you are now. You simply need a DataTable that is the result set of a SQL query containing a JOIN. You can add a stored procedure or view to your database that joins multiple tables and then let the Data Source wizard generate a DataTable for you. You can also add a DataTable to your DataSet manually in the designer, although I'm not 100% sure whether that affects the Data Source as well. There's only one way to find out though.
 
Back
Top