System.Data.SqlClient.SqlException: Incorrect syntax near ')'

Posted by: naiyin on 23 January 2025, 6:18 pm EST

    • Post Options:
    • Link

    Posted 23 January 2025, 6:18 pm EST - Updated 23 January 2025, 6:20 pm EST

    I have 10 different SQL queries in the DataSource

    They all work perfectly in my SQL Management Studio and working in the 17.1 version, but after I upgrade the version to 17.3, I got the following errors. There is no way to debug. Please help me find the reasons. Also, why this Report Designer just not able to return a useful error message? At least tell me which dataset, btw all of them past the Dataset validation

    Exception details:
    GrapeCity.ActiveReports.ReportException: An unexpected error occurred. Additional information: 'Incorrect syntax near ')'.
    Incorrect syntax near ')'.
    Incorrect syntax near ')'.
    Incorrect syntax near ')'.' ---> System.Data.SqlClient.SqlException: Incorrect syntax near ')'.
    Incorrect syntax near ')'.
    Incorrect syntax near ')'.
    Incorrect syntax near ')'.
       at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
       at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
       at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
       at System.Data.SqlClient.SqlDataReader.get_MetaData()
       at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
       at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
       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()
       at GrapeCity.ActiveReports.Rendering.DataProcessing.RecordsAdapter.<GetEnumerator>d__8.MoveNext()
       at GrapeCity.Enterprise.Data.DataEngine.Extensions.MemoizeEnumerableExtensions.MemoizedReadOnlyList`1.CacheItem()
       at GrapeCity.Enterprise.Data.DataEngine.Extensions.MemoizeEnumerableExtensions.MemoizedReadOnlyList`1.<GetLiveEnumerator>d__8.MoveNext()
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       at System.Linq.Lookup`2.Create[TSource](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
       at System.Linq.GroupedEnumerable`3.GetEnumerator()
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)
       at GrapeCity.Enterprise.Data.DataEngine.DataProcessing.DataProcessor.<>c__DisplayClass10_1.<MakeListFn>b__2()
       at GrapeCity.Enterprise.Data.DataEngine.DataTree`1.List.get_Groups()
       at Gcef.Data.DataEngine.I...()
       at GrapeCity.Enterprise.Data.DataEngine.DataTree`1.List.get_Groups()
       at GrapeCity.ActiveReports.Core.Rendering.I..get_Contents()
       at GrapeCity.ActiveReports.Core.Rendering.I...GatherChildren(IFixedPage a)
       at GrapeCity.ActiveReports.Core.Rendering.I..Children( a)
       at GrapeCity.ActiveReports.Core.Rendering.I...MoveNext()
       at GrapeCity.ActiveReports.Core.Rendering.I...MoveNext()
       at GrapeCity.Enterprise.Data.Expressions.Tools.EnumerableExtensions.<Flatten>d__0`1.MoveNext()
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       at GrapeCity.ActiveReports.Core.Rendering.I..(IEnumerable`1 )
       at GrapeCity.ActiveReports.Core.Rendering.I..( , IReadOnlyList`1 )
       at GrapeCity.ActiveReports.Core.Rendering.I...()
       at GrapeCity.ActiveReports.Rendering.DocumentMapNode.<>c__DisplayClass3_0.<.ctor>b__0()
       at System.Lazy`1.CreateValue()
       at System.Lazy`1.LazyInitValue()
       at System.Lazy`1.get_Value()
       at GrapeCity.ActiveReports.Core.Rendering.I..(IMetadataDictionary , DocumentMapNode , ILayoutArea )
       at GrapeCity.ActiveReports.Core.Rendering.I..Build(IReport a, IMetadataDictionary b)
       at GrapeCity.ActiveReports.Core.Rendering.I..( , Point`1 ,  , Boolean , Boolean , Boolean , Int32 , Boolean )
       at GrapeCity.ActiveReports.Core.Rendering.I..BuildPages( a, Int32 b)
       at GrapeCity.ActiveReports.Core.Rendering.I...get_Pages()
       at GrapeCity.ActiveReports.Viewer.Common.Rdlx.GraphicsRenderingExtension.GetLayoutPages(CancellationToken cancel, Boolean awaitFullLayout)
       at GrapeCity.ActiveReports.Viewer.Common.Rdlx.GraphicsRenderingExtension.DrawPages(IFontsFactory fonts, CancellationToken cancellationToken, Boolean awaitFullLayout)
       at GrapeCity.ActiveReports.Viewer.Common.Rdlx.GraphicsRenderingExtension.Render(IReport report, CancellationToken cancel)
       at GrapeCity.ActiveReports.Viewer.Common.Rdlx.GraphicsRenderingExtension.Render(IReport report, StreamProvider streams, NameValueCollection settings, CancellationToken cancel)
       at GrapeCity.ActiveReports.Document.PageDocument.Render(IRenderingExtension renderingExtension, StreamProvider streams, NameValueCollection settings, Boolean forceDataRefresh, Boolean forceParameterDataRefresh, CancellationToken token, IProgress`1 progress)
       --- End of inner exception stack trace ---
       at GrapeCity.ActiveReports.Document.PageDocument.Render(IRenderingExtension renderingExtension, StreamProvider streams, NameValueCollection settings, Boolean forceDataRefresh, Boolean forceParameterDataRefresh, CancellationToken token, IProgress`1 progress)
       at GrapeCity.ActiveReports.Viewer.Common.Internal.RdlReport.<>c__DisplayClass23_0.<LoadImpl>b__8()
       at System.Threading.Tasks.Task.InnerInvoke()
       at System.Threading.Tasks.Task.Execute()

  • Posted 24 January 2025, 12:07 am EST

    Hi James,

    This is strange. Could you please provide us with your sample report, query, and sample database dump file so that we can try replicating this issue at our end and investigate further?

  • Posted 24 January 2025, 2:18 am EST

    I also found null object errors or sometimes blank pages that are caused by the following expression in the Hidden property.

    =iif(Fields!InvoiceNo.Value=First(Fields!InvoiceNo.Value, “InvoiceDetails”),false,true)

  • Posted 24 January 2025, 2:38 am EST

    Hi James,

    We would request that you provide us with your sample report, query, and sample database dump file so that we can try replicating your initial and second issue at our end and investigate further.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels