DotNetNuke (DNN) Error Log troubleshooting

Hello experts,

I am using DNN 7.4 with a custom module that I built. I am occasionally receiving the error shown below which I can see in the Event Viewer. The code that created this error will run multiple time successfully without any errors. Then, on occasion, this error will pop up. I have traced through all of my code and sql queries but can't find any syntax that even resembles, 'api'.

System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near 'api'. 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.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at HealthStream.Modules.ConnectDB.SQLExecute(String SQL) at HealthStream.Modules.HSTMAPIManager.SendUpdate(String AppLogID, String ApplicationID, String NRPID, String Status, String HSTMID, String OrgID) at DesktopModules_HealthStream_Scheduler_Resend_Failed_Requests.Page_Load(Object sender, EventArgs e) ClientConnectionId:dff2dfa0-e203-4057-933a-5f2b66f99bb2 Error Number:102,State:1,Class:15

Is there an additional table within DNN that would allow me to see the exact query that caused this issue?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vitor MontalvãoMSSQL Senior EngineerCommented:
Can be a dynamic SQL that was mal formed?
JCaracci1Author Commented:
Thank you for your response Vitor. I have gone through my sql with a fine tooth comb, and most of the time it runs with no errors. When I think everything is okay, then this error will pop up again in my log.

Is there a way to record the actual query that is causing this issue? I have it wrapped in a Try, Catch. When writing the error to the log, is there a way to catch the culprit sql statement and write to log also?

     - My Code -
Catch ex As Exception
     Write ex to db log <--Can I also catch the bad sql statement here and also write to log?
End Try
Vitor MontalvãoMSSQL Senior EngineerCommented:
If you have you SQL in a string, then write the value of the string in the exception.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JCaracci1Author Commented:
Thank you Vitor. I am updating my exception code now to include the SQL string along with the exception.
JCaracci1Author Commented:
Thanks, that helped me track down the error.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.