1 year ago

#337848

test-img

kvj

Creating a Report in C#/.NET that Queries a SQL Server

I have been tasked to create a report that queries multiple instances of data from a SQL Server.

The SQL Server side of this is complete as I already have all the SQL queries and views and tables already created on the SQL Server side.

However for the presentation interface where this queried data will be displayed I want to create and use RDLC Reports or Windows forms application using C#/Visual Studio.

Initially I tried using RDLC Reports and ASP.NET but ran into some issues. On the Main page of the report, there needs to be results of multiple query results. Mostly these results are sum/calculation values. Here is a brief explanation of what the Main Page is supposed to look like.

Main Page

TextBox/Cell1 = Query result of (select sum(ordercost) from dbo.salesorders)

TextBox/Cell2= Query result of (select sum(orderquantity) from dbo.salesorders)

TextBox/Cell3= Query result of (select sum(partsordered-partshipped) from dbo.workorders)

Button which when clicked on executes these Queries and loads the data into these cells/text boxes.

Basically this is what I am trying to achieve. I am trying to use RDLC Reports, however, when I create a table/tablinx in the .rdlc file, the above queries (which are declared in a SqlCommand

 string query = "Select SUM(ordercost) from dbo.salesorders";
 SqlCommand cmd = new SqlCommand(query); 

Doesn't execute and deliver the data.

Probably because the query only returns 1 value?

However, when I change the query to:

string query = "Select * from dbo.salesorders",

I am getting the entire table's worth of data, which is not what I want. I just need the sum values.

Any ideas why this is not working as expected using RDLC Report?

Is it best to not proceed with RDLC and try this with Windows Forms or any other reporting method?

Thanks.

c#

.net

visual-studio

rdlc

0 Answers

Your Answer

Accepted video resources