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. Exception Handling

Exception Handling

Scheduled Pinned Locked Moved ASP.NET
questioncsharpdatabasevisual-studiosysadmin
5 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.
  • R Offline
    R Offline
    rockyl
    wrote on last edited by
    #1

    Hi, One of my webmethods throw an exception: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: The provided Supervisor emailID either invalid or do not exists in the database at ManageEmployeeServices.AddEmployee(Int64 EmpID, String EmpName, String EmpEmailID, String SupervisorEmailID, String LocationName) in c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\WebSites\ManageEmployeeServices\App_Code\ManageEmployeeServices.cs:line 53 --- End of inner exception stack trace --- And In my client I want to display only the bolded text as it is the actual error message. So how can I trunctate all the unwanted string from the error message? Thanks:

    Rakesh

    S 1 Reply Last reply
    0
    • R rockyl

      Hi, One of my webmethods throw an exception: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: The provided Supervisor emailID either invalid or do not exists in the database at ManageEmployeeServices.AddEmployee(Int64 EmpID, String EmpName, String EmpEmailID, String SupervisorEmailID, String LocationName) in c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\WebSites\ManageEmployeeServices\App_Code\ManageEmployeeServices.cs:line 53 --- End of inner exception stack trace --- And In my client I want to display only the bolded text as it is the actual error message. So how can I trunctate all the unwanted string from the error message? Thanks:

      Rakesh

      S Offline
      S Offline
      StylezHouse
      wrote on last edited by
      #2

      Try this? [WebMethod] string MethodName { try { ..Your Code return ""; } catch (SqlException ex) { return ex.Message; } } So in the event of an error, your method will return the error message, otherwise returns an empty string, or null if you prefer?

      R 1 Reply Last reply
      0
      • S StylezHouse

        Try this? [WebMethod] string MethodName { try { ..Your Code return ""; } catch (SqlException ex) { return ex.Message; } } So in the event of an error, your method will return the error message, otherwise returns an empty string, or null if you prefer?

        R Offline
        R Offline
        rockyl
        wrote on last edited by
        #3

        hi, My intention is to return a dataset from the web method so how can I mention the return type as string? Regards,

        Rakesh

        S 1 Reply Last reply
        0
        • R rockyl

          hi, My intention is to return a dataset from the web method so how can I mention the return type as string? Regards,

          Rakesh

          S Offline
          S Offline
          StylezHouse
          wrote on last edited by
          #4

          You can declare the dataset outside of the Try block, and in the event of an error, add an Errors Table too it that contains all of the info. Then check for the existance of that table on the return trip.

          R 1 Reply Last reply
          0
          • S StylezHouse

            You can declare the dataset outside of the Try block, and in the event of an error, add an Errors Table too it that contains all of the info. Then check for the existance of that table on the return trip.

            R Offline
            R Offline
            rockyl
            wrote on last edited by
            #5

            Great! that worked... Thanks a lot.

            Rakesh

            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