Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. capturing RAISERROR message in the front end

capturing RAISERROR message in the front end

Scheduled Pinned Locked Moved ASP.NET
databasehelptutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sishya
    wrote on last edited by
    #1

    Hi , I have created a logic in stored procedure and in it i look if a variable satisfies certain condition ,if it doesn't i want to raiseerror with appropriate message.Pls tell me how to know if the error has occurred and capture the msg in the frontend.Pls let me know also the right syntax for writing msgs in RAISERROR . thnks in advance

    N 1 Reply Last reply
    0
    • S sishya

      Hi , I have created a logic in stored procedure and in it i look if a variable satisfies certain condition ,if it doesn't i want to raiseerror with appropriate message.Pls tell me how to know if the error has occurred and capture the msg in the frontend.Pls let me know also the right syntax for writing msgs in RAISERROR . thnks in advance

      N Offline
      N Offline
      Nagraj Naik
      wrote on last edited by
      #2

      Hi Sishya, I am explaining RAISERROR syntax by simple example.Modify it as your need. ALTER procedure sp_AddUsers @UserID varchar(20) as if @UserID='' Begin Raiserror('Missing User ID.',16,1) return(0) End Begin Transaction insert into Users (UserID) values(@UserID) Commit Transaction Regards, Nagraj Let's Teach Life To Laugh........:laugh:

      S 1 Reply Last reply
      0
      • N Nagraj Naik

        Hi Sishya, I am explaining RAISERROR syntax by simple example.Modify it as your need. ALTER procedure sp_AddUsers @UserID varchar(20) as if @UserID='' Begin Raiserror('Missing User ID.',16,1) return(0) End Begin Transaction insert into Users (UserID) values(@UserID) Commit Transaction Regards, Nagraj Let's Teach Life To Laugh........:laugh:

        S Offline
        S Offline
        sishya
        wrote on last edited by
        #3

        hi , pls tell how to capture this Message in raise error from frontend interface and what about the 16,1 in Raiserror('Missing User ID.',16,1)

        N 1 Reply Last reply
        0
        • S sishya

          hi , pls tell how to capture this Message in raise error from frontend interface and what about the 16,1 in Raiserror('Missing User ID.',16,1)

          N Offline
          N Offline
          Nagraj Naik
          wrote on last edited by
          #4

          Hi sishya, 16,1 are savirity,status parameters for RAISERROR procedure.Don't think much about then you can get details on net regrading this. As your core problem To access this RAISEERROR return value....here is code. private void someMethod() { try { // Do a RAISERROR inside of a SQL block like // RAISERROR('You did something wrong with the value "%s"', 16, 1, @param1) } catch (SqlException sqle) { lblMessage.Text = sqle.Message; } catch (Exception err) { // Do something else with the exception } } I hope this will help you. Regards, Nagraj Let's Teach Life To Laugh........:laugh:

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups