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. Database & SysAdmin
  3. Database
  4. Sql2005: How to get the error msg thrown from Storedproc to C# class

Sql2005: How to get the error msg thrown from Storedproc to C# class

Scheduled Pinned Locked Moved Database
csharpsharepointdatabasehelptutorial
3 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.
  • K Offline
    K Offline
    kssknov
    wrote on last edited by
    #1

    hi i had created as SP to delete the record using where condtn.if the record doesnt exists the SP will throw an error as "No such record found" and return 0 . But my c# code gets -1 rows affected from the sql.its ok. My problm is how to get the "No such record found" from sql to c#. ALTER PROCEDURE SP_deleteUserMaster @LoginId nvarchar(30) AS begin set nocount on declare @ncnt int select @ncnt=(select count(*)from UserMaster where LoginId=@LoginId) if (@ncnt>0) begin DELETE FROM UserMaster WHERE LoginId=@LoginId end else raiserror('No record found',10,1) end RETURN

    senthil

    T 1 Reply Last reply
    0
    • K kssknov

      hi i had created as SP to delete the record using where condtn.if the record doesnt exists the SP will throw an error as "No such record found" and return 0 . But my c# code gets -1 rows affected from the sql.its ok. My problm is how to get the "No such record found" from sql to c#. ALTER PROCEDURE SP_deleteUserMaster @LoginId nvarchar(30) AS begin set nocount on declare @ncnt int select @ncnt=(select count(*)from UserMaster where LoginId=@LoginId) if (@ncnt>0) begin DELETE FROM UserMaster WHERE LoginId=@LoginId end else raiserror('No record found',10,1) end RETURN

      senthil

      T Offline
      T Offline
      Thats Aragon
      wrote on last edited by
      #2

      Hello! Put this line after raiserror sentense select 'No record found' And also into your code string result = (string)CommandName.ExecuteScalar(); I am not sure but may be this will help you. Regards..

      Keep Smiling :)

      K 1 Reply Last reply
      0
      • T Thats Aragon

        Hello! Put this line after raiserror sentense select 'No record found' And also into your code string result = (string)CommandName.ExecuteScalar(); I am not sure but may be this will help you. Regards..

        Keep Smiling :)

        K Offline
        K Offline
        kssknov
        wrote on last edited by
        #3

        thank u shah i ll check and reply rgds kssk

        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