1

Searchテキストボックスに挿入されている値よりも少ない在庫を持つすべての製品をレポートに表示させたい。エラーがあります。レポートビューアでパラメータを設定

これはストアドプロシージャです:ユーザーが検索テキストボックスに値を入力するとき

CREATE PROCEDURE [dbo].[GetInventoryReport] 
    @Stock int 
AS 
    SELECT * 
    FROM Product 
    WHERE Stock < @Stock 
    ORDER BY Stock ASC 

これはコードです。

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' does not contain a definition for 'Add' and no extension method 'Add' accepting a first argument of type 'Microsoft.Reporting.WinForms.LocalReport' could be found (are you missing a using directive or an assembly reference?)

答えて

1

あなたは交換してください.DataSources

を逃した:

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()するための機能であります

rptInventoryStock.LocalReport.DataSources.Add(new ReportDataSource("IOOP_DatabaseDataSet", dtbl)); 
rptInventoryStock.LocalReport.Add(new ReportDataSource("IOOP_DatabaseDataSet", dtbl)); 

関連する問題