mrt based query with parameters
Posted: Tue May 22, 2012 1:51 pm
In the standalone designer I open an mrt fiile containing a connection to a sql database, with a query :
When the query runs as a test, it works fine, but when the report is previewed, it reports the following error:
If I provide an "expression" value to the Parameter 'object', this error goes away. Is that expected behavior.
However, if I then attempt from the C# code to apply the parameter:
The change does not propogate to override that value I set in the expression (above).
Can you explain what I'm doing wrong...? How can I create an mrt that works in both the standalone designer, AND called from csharp ?
Thanks.
Code: Select all
select * from tblStatement where ID = @prmStatementID
Code: Select all
----------------------------
[General Info]
Application: Stimulsoft Reports.Net
Framework: v4.0.30319
Version: Version: 2012.1.1300 from 3 April 2012
MachineName: TANGERINE2
OSVersion: Microsoft Windows NT 6.1.7601 Service Pack 1
UserName: brian
----------------------------
[Exception Info]
Message: The parameterized query '(@prmStatementID int)select * from tblStatement where ID = @prmS' expects the parameter '@prmStatementID', which was not supplied.
Statement(s) could not be prepared.
Source: .Net SqlClient Data Provider
StackTrace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at Stimulsoft.Report.Dictionary.StiSqlSource.UpdateParameters()
at Stimulsoft.Report.Dictionary.StiSqlAdapterService.ConnectDataSourceToData(StiDictionary dictionary, StiDataSource dataSource, Boolean loadData)
at Stimulsoft.Report.Dictionary.StiDataSource.Connect(StiDataCollection datas, Boolean loadData)
at Stimulsoft.Report.Dictionary.StiDataSourcesCollection.Connect(StiDataCollection datas, Boolean loadData)
at Stimulsoft.Report.Dictionary.StiDictionary.Connect(Boolean loadData)
at Stimulsoft.Report.Engine.StiRenderProviderV2.ConnectToData(StiReport report)
at Stimulsoft.Report.Engine.StiRenderProviderV2.Render(StiReport report, StiRenderState state)
at Stimulsoft.Report.Engine.StiReportV2Builder.RenderSingleReport(StiReport masterReport, StiRenderState renderState)
at Stimulsoft.Report.StiReport.RenderReport(StiRenderState renderState)
at Stimulsoft.Report.StiReport.Render(StiRenderState renderState, StiGuiMode guiMode)
at Stimulsoft.Report.Design.Controls.StiDesignerPreviewControl.btRefresh_Click(Object sender, EventArgs e)
----------------------------
[Assemblies]
mscorlib, Version = 2.0.0.0
Stimulsoft.Base, Version = 2012.1.1300.0
Stimulsoft.Report, Version = 2012.1.1300.0
Stimulsoft.Report.Design, Version = 2012.1.1300.0
System.Windows.Forms, Version = 2.0.0.0
If I provide an "expression" value to the Parameter 'object', this error goes away. Is that expected behavior.
However, if I then attempt from the C# code to apply the parameter:
Code: Select all
report["prmStatementID"] = 17745;
Can you explain what I'm doing wrong...? How can I create an mrt that works in both the standalone designer, AND called from csharp ?
Thanks.