我希望我的报告显示库存少于搜索文本框中插入的值的所有产品。有错误。
这是存储过程:
CREATE PROCEDURE [dbo].[GetInventoryReport]
@Stock int
AS
SELECT *
FROM Product
WHERE Stock < @Stock
ORDER BY Stock ASC
这是用户在搜索文本框中输入值时的代码。
private void txtSearch_TextChanged(object sender, EventArgs e)
{
DataTable dtbl = GetInventoryReport_Result();
rptInventoryStock.Visible = true;
rptInventoryStock.LocalReport.ReportPath = "InventoryReport.rdlc";
rptInventoryStock.LocalReport.DataSources.Clear();
rptInventoryStock.LocalReport.Add(new ReportDataSource("IOOP_DatabaseDataSet", dtbl));
this.rptInventoryStock.RefreshReport();
}
这是GetInventoryReport_Result()
:
private DataTable GetInventoryReport_Result()
{
DataTable dtbl = new DataTable();
try
{
SqlCommand sqlCmd = new SqlCommand("GetInventoryReport", sqlCon);
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.Parameters.AddWithValue("@Stock", txtSearch.Text.Trim());
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
sqlDa.Fill(dtbl);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error Message");
}
finally
{
if (sqlCon != null)
sqlCon.Close();
}
return dtbl;
}
错误:
'Microsoft.Reporting.WinForms.LocalReport'不包含 “添加”的定义,没有扩展方法“添加”接受第一个 “Microsoft.Reporting.WinForms.LocalReport”类型的参数可以是 发现(您是否缺少using指令或程序集引用?)
答案 0 :(得分:1)
您错过了<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<div ng-app="app" ng-controller="ctrl">
<form name="form" ng-submit="submit()" novalidate>
<div>
<select name="select" ng-model="selectedOption" ng-options="option as option.text for option in options" required>
<option value="">--Please select--</option>
</select>
</div>
<div ng-if="form.select.$invalid && form.$submitted">Please make a selection</div>
<div>
Selected option is valid: {{form.select.$valid}}
</div>
</form>
</div>
<强>替换强>
.DataSources
。通过强>
rptInventoryStock.LocalReport.Add(new ReportDataSource("IOOP_DatabaseDataSet", dtbl));