jquery displays SQL stored procedure custom exception information

Source: Internet
Author: User

Learn MVC application development, changed the insus.net before the development of ASP, the previous development is the server side, and now use jquery Ajax in the implementation. Think of and consider a lot of problems, also encountered a lot of problems, some solved, some still stay, hope to solve them all.

As this problem, "Internal Server Error" http://www.cnblogs.com/insus/p/3418942.html let insus.net impressive, solve it himself, spent insus.net a lot of time.

Today's blog post, Insus.net is to share a better solution, the exception of the server or in the memory of the custom exception, can be displayed in jquery Ajax.

Come back and look here. "MVC member registration" http://www.cnblogs.com/insus/p/3439599.html in the stored procedure [dbo]. [Usp_member_register] will see the custom exception information to determine whether the account has been registered:

IF EXISTS (SELECT TOP 1 1 from [dbo].[ Member] WHERE [Account] = @Account) BEGIN    RAISERROR (N ' This username [%s] has already been registered, please change and re-register. ', 16,1, @Account)    returnend


Ok, we'll need this custom exception information to throw to jquery later.

Open the Practice project, find the previous JS class library "Create your own Common JS library" http://www.cnblogs.com/insus/p/3427673.html add two extension methods:



Then, open the view view that you want to reference this JS library, such as member/register.cshtml:


Then modify the jquery code to Comment out:

alert (Errorthrown);


Add an arrow sentence:

In the following live demo, Insus.net has tried to measure a user who has already been registered, and it has custom exception information that normally displays the stored procedure. It also tests that the stored procedure is deleted, and it can also hint that the stored procedure cannot be found. Finally insus.net which stored procedure to re-build, it can be used normally.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.