Is it possible to avoid assertion warn during ms sql requests (debug)

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
9/26/2012 12:35:32 PM
Gravatar
Total Posts 70

Is it possible to avoid assertion warn during ms sql requests (debug)

Hi Joe,

Is it possible to avoid the assertion warnings in debug mode (ms sql at least) during db requests?

I mean warnings from MojoPortal.Data.MSSQL.SQLParameterHelper.cs (137) etc..

I should confess this is annoying a lot during debug with DB requests..Sorry if it is hard but it could really help with heavy debug.

Best regards, Igor

9/26/2012 2:26:09 PM
Gravatar
Total Posts 18439

Re: Is it possible to avoid assertion warn during ms sql requests (debug)

Hi Igor,

Those debug asserts are meant to help developers find and fix mistakes in the code. For example if the sql parameter names or types or counts declared in code don't match the parameters in the actual stored procedure.

If you are encountering such errors in mojoPortal code please let me know where they are so I can fix them, ie post a stack trace. I would not expect you to be encountering lots of errors such as this but if you are encountering them I would like to get bug reports about the specific details.

When not in debug mode sql server is fairly forgiving and errors won't happen in production if the types and counts are correct and only the names are wrong, but still its best to track down any such mistakes and fix them.

Best,

Joe

9/26/2012 3:37:54 PM
Gravatar
Total Posts 70

Re: Is it possible to avoid assertion warn during ms sql requests (debug)

Joe, sorry, I missed the example. Please, take a look: http://www.softpilot2000.com.ua/log/mojo_assert.jpg

I know what it is required more details, I will try to found a reason. Sorry for boring you. Regards, Igor

 

9/26/2012 3:45:28 PM
Gravatar
Total Posts 18439

Re: Is it possible to avoid assertion warn during ms sql requests (debug)

Hi Igor,

That is an error in custom code not in mojoPortal code. So the debug assert is alerting you to the mistake in the custom code. In your custom code DBSearch.FetchSearchKeywords there are parameters declared incorrectly for the store procedure it calls. If you compare the params in the stored proc and fix the params in the code so they match the proc this debug assert error will stop happening. 

If we did not have the debug assert it would be harder to find this error in your custom code and it could result in a bug that is hard to find. But since you get this error during debugging it brings your attention to the problem so you can fix it.

Best,

Joe

9/26/2012 4:30:50 PM
Gravatar
Total Posts 70

Re: Is it possible to avoid assertion warn during ms sql requests (debug)

Joe, sorry, just for make it clear:

Stored procedure: 2 parameters: ALTER PROCEDURE [dbo].[_sh_Search_SelectKeywords] @ss varchar(25), @num int
AS ...

Custom code, DAL :

 public static IDataReader FetchSearchKeywords(string keyword,int resNum)
{
SqlParameterHelper sph = new SqlParameterHelper(GetWriteConnectionString(), "_sh_Search_SelectKeywords", 2);
sph.DefineSqlParameter("@ss", SqlDbType.NVarChar, 25, ParameterDirection.Input, keyword);

=======Assert is rising here======
sph.DefineSqlParameter("@num", SqlDbType.Int, ParameterDirection.Input, resNum);
return sph.ExecuteReader();

}

Joe, sorry, but the question: why "@ss varchar(25)" in stored procedure doesn't match the "SqlDbType.NVarChar, 25" in custom code? Is this an error?

Sorry for boring!

Best regards, Igor.

9/26/2012 4:38:09 PM
Gravatar
Total Posts 1203
Proud member of the mojoPortal team

Help support mojoPortal!
Add-on modules

Re: Is it possible to avoid assertion warn during ms sql requests (debug)

varchar is limited to 8-bit representation. nvarchar can store Unicode data, so they are not the same data type.

http://stackoverflow.com/questions/144283/what-is-the-difference-between-varchar-and-nvarchar

Hope that helps,

Jamie

9/26/2012 4:45:55 PM
Gravatar
Total Posts 70

Re: Is it possible to avoid assertion warn during ms sql requests (debug)

Thanks a lot! varchar and nvarchar are not matching! Of course..

Best regards, Igor

You must sign in to post in the forums. This thread is closed to new posts.