Page 1 of 1

SQL Query error

Posted: Thu Jun 16, 2011 11:51 pm
by jjc
Hi All
i have this SQL Query :

Code: Select all

-- Region Parameters
DECLARE @p1 Decimal(5,4) = 0
DECLARE @p2 Decimal(5,4) = 0
DECLARE @p3 Decimal(5,4) = 0
DECLARE @p4 Decimal(5,4) = 0
DECLARE @p6 Decimal(5,4) = 0
-- EndRegion
SELECT [t5].[CityCode]
	FROM (
SELECT [t0].[CityCode]
	FROM [Hotel_Meals_TBL] AS [t0]
    CROSS JOIN [HotelRoom_TBL] AS [t1]
    INNER JOIN [City_TBL] AS [t2] ON [t0].[CountryCode] = [t2].[CountryCode]
    WHERE ([t0].[CountryCode] = {Variable1} ) AND ([t0].[CityCode] = [t2].[CityCode]) AND ([t0].[HotelCodeID] = [t1].[HotelCodeID]) AND ([t0].[_24Dec] = @p1) AND ([t0].[Dinner] = @p2) AND ([t1].[SGL_ShoulderSeason] = @p3) AND ([t1].[SGL_TopPeakSeason] > @p4)
    UNION
SELECT [t3].[CityCode]
	FROM [Transport_TBL] AS [t3]
	INNER JOIN [City_TBL] AS [t4] ON [t3].[CountryCode] = [t4].[CountryCode]
    WHERE ([t3].[CountryCode] = {Variable1} ) AND ([t3].[CityCode] = [t4].[CityCode]) AND ([t3].[_1Pax_RealContractCost] = @p6)
    ) AS [t5]

and when i compile the report i receive this error in the MessaseError :

Code: Select all

Incorrect syntax near ')'.
Incorrect syntax near ')'.
and in the Stack Trace this one :

Code: Select all

 at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   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.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.Dictionary.StiDictionary.Connect()
   at Stimulsoft.Report.Viewer.StiViewerControl.RefreshDialogs()
   at Stimulsoft.Report.Viewer.StiViewerControl.set_Report(StiReport value)
   at Stimulsoft.Report.Viewer.Design.StiWinViewerWrapper.set_Report(StiReport value)
   at Stimulsoft.Report.Design.Controls.StiDesignerPreviewControl.btRefresh_Click(Object sender, EventArgs e)
i don't know why this message appear but i tested the query and it is right,can you advice me where is the error or where i wrong?

Thanks so much for your attention,

have a good time,

Cheers

SQL Query error

Posted: Fri Jun 17, 2011 5:43 am
by Alex K.
Hello,

Please send us your report with test data for analysis.

Thank you.

SQL Query error

Posted: Fri Jun 17, 2011 6:01 am
by jjc
hi Aleksey,
i sent to you the file by you requested.

Thanks so much for your support.

Have a good time.

Cheers

SQL Query error

Posted: Fri Jun 17, 2011 6:38 am
by Alex K.
Ok. Thank you.