I am new to Microsoft Report Viewer and trying to a use for the first time. I have just created a blank report in Visual Studio and added a textbox with the valie:
=Fields!vehicle_chassis_number.Value
In Visual Studio, hee is my Code:
data_set =
new DataSet();
reportViewer1.ProcessingMode =
ProcessingMode.Local;
LocalReport rep = reportViewer1.LocalReport;
rep.ReportPath =
@"C:\Users\Jassim\Documents\Visual Studio 2008\Projects\Taajeer\Taajeer\Report1.rdlc";
sql_connection =
new SqlConnection("Data Source=.\\SQLEXPRESS;initial catalog=rent_a_car_company;integrated security=true");
sql_connection.Open();
sql_command =
new SqlCommand("sp_get_agreement_by_id", sql_connection);
sql_command.CommandType =
CommandType.StoredProcedure;
sql_command.Parameters.Add(
"@vehicle_id", SqlDbType.Int).Value = 1;
sql_adapter =
new SqlDataAdapter(sql_command);
sql_adapter.Fill(data_set);
sql_adapter.Dispose();
// sql_connection.Close();
ReportDataSource dsReport = new ReportDataSource();
dsReport.Name =
"Invoice_sprocInvoiceView";
dsReport.Value = data_set.Tables[
"Invoice"];
rep.DataSources.Add(dsReport);
reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.DataSources.Add(dsReport);
reportViewer1.RefreshReport();
rep.Refresh();
this.reportViewer1.RefreshReport();
but I am getting this error message:
Error 1 The Value expression for the textbox ‘textbox3’ refers to the field ‘vehicle_chassis_number’. Report item expressions can only refer to fields within the current data set scope or, if inside an aggregate, the specified data set scope. C:\Users\Jassim\Documents\Visual Studio 2008\Projects\Taajeer\Taajeer\Report1.rdlc Taajeer
Jassim Rahma