如何在 visual studio 2013 年的报表查看器中显示数据 table
How to show data table in report viewer in visual studio 2013
我有一个名为 reportviewer1.A 的报表查看器,报表名为 report.rldc。我使用以下代码获取数据并转换为数据 table。现在我想在报表查看器中显示数据 table 的数据。
代码在下面提到。请帮助:(
SqlDataAdapter dataadapter = new SqlDataAdapter(command);
DataTable table = new DataTable();
table.TableName = "Report showing result for " +
ComboBoxCategory.SelectedItem.ToString()+" +
ComboBoxQueryChoice.SelectedItem.ToString() +" from " +
dateTimePickerStarting.Value.ToString()+" to "+dateTimePickerEnding.Value.ToString();
table.Clear();
dataadapter.Fill(table);
命令文本是
SELECT Distinct Sale.Product_ID , S_Article ,
S_Size , SUM(S_Quantity) AS QuantitySold,SUM(Profit) AS Profit
FROM Product,Sale
WHERE Product.Product_ID=Sale.Product_ID
and(S_Date between (@Startdate)
and (@Enddate))" + SelectedCateogry +
" Group By Sale.Product_ID,(S_Article),(S_Size)
Order BY Profit DESC"
var ConnString = System.ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString;
SqlDataAdapter dataadapter;
DataTable someDataTable = new DataTable("ReportViewResults);
using (SqlConnection connStr = new SqlConnection(ConnString))
{
using (SqlCommand cmd = new SqlCommand("yourStoredProc or Sql Query", connStr))
{
cmd.CommandType = CommandType.StoredProcedure;//change to Text if your passing sql string
dataadapter= new SqlDataAdapter(cmd);
new SqlDataAdapter(cmd).Fill(someDataTable);
}
}
我有一个名为 reportviewer1.A 的报表查看器,报表名为 report.rldc。我使用以下代码获取数据并转换为数据 table。现在我想在报表查看器中显示数据 table 的数据。 代码在下面提到。请帮助:(
SqlDataAdapter dataadapter = new SqlDataAdapter(command);
DataTable table = new DataTable();
table.TableName = "Report showing result for " +
ComboBoxCategory.SelectedItem.ToString()+" +
ComboBoxQueryChoice.SelectedItem.ToString() +" from " +
dateTimePickerStarting.Value.ToString()+" to "+dateTimePickerEnding.Value.ToString();
table.Clear();
dataadapter.Fill(table);
命令文本是
SELECT Distinct Sale.Product_ID , S_Article ,
S_Size , SUM(S_Quantity) AS QuantitySold,SUM(Profit) AS Profit
FROM Product,Sale
WHERE Product.Product_ID=Sale.Product_ID
and(S_Date between (@Startdate)
and (@Enddate))" + SelectedCateogry +
" Group By Sale.Product_ID,(S_Article),(S_Size)
Order BY Profit DESC"
var ConnString = System.ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString;
SqlDataAdapter dataadapter;
DataTable someDataTable = new DataTable("ReportViewResults);
using (SqlConnection connStr = new SqlConnection(ConnString))
{
using (SqlCommand cmd = new SqlCommand("yourStoredProc or Sql Query", connStr))
{
cmd.CommandType = CommandType.StoredProcedure;//change to Text if your passing sql string
dataadapter= new SqlDataAdapter(cmd);
new SqlDataAdapter(cmd).Fill(someDataTable);
}
}