locked
clr Stored Procedure hanging while exception RRS feed

  • Question

  • Hi,

    I'm kind of frustrated. My c# assembly is working but only if no exception occurs. I can catch that exception in the catch block but then the SP stucks in execution. When I do stop the query I can see the trace output from

    SqlContext.Pipe.Send("getMXRecord exception continue: " + ex + " ");

    but after that line, there is no code execution any more (return is not executed).

    Can please anybody give me a hint?

    Best Marco

     

    try
    {
    mxRecords = getMXRecords(host, (string)dnsServers[0]);
    
    }
    catch (Exception ex) 
    {
    SqlContext.Pipe.Send("getMXRecord exception continue: " + ex + " ");
    
    return mxRecords;
    }
    
    

     

     

    Thursday, February 3, 2011 2:14 PM

Answers

  • Bob,

    The code here looks no problem. To further diagnose this issue, I recommend that you post your detailed code here so that we can try to reproduce this issue. I performed a quick test with the following code, it worked perfectly:

      [Microsoft.SqlServer.Server.SqlProcedure]
      public static SqlInt32 Convert2Int(SqlString strVal)
      {
        // Put your code here
        try
        {
          return SqlInt32.Parse(strVal.ToString());
        }
        catch (Exception ex)
        {
          SqlContext.Pipe.Send("cannot do the conversion:" + ex);
          return -1;
        }
      }
    

    So the problem is probably in other place. Also please make sure that the latest service pack has been applied to your SQL Server before we move on.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Wednesday, February 9, 2011 6:58 AM

All replies

  • Have you tried debugging your assembly in SQL Server using the VS debugger?

    Cheers, Bob Beauchemin, SQLskills

    Thursday, February 3, 2011 7:25 PM
  • Bob,

    The code here looks no problem. To further diagnose this issue, I recommend that you post your detailed code here so that we can try to reproduce this issue. I performed a quick test with the following code, it worked perfectly:

      [Microsoft.SqlServer.Server.SqlProcedure]
      public static SqlInt32 Convert2Int(SqlString strVal)
      {
        // Put your code here
        try
        {
          return SqlInt32.Parse(strVal.ToString());
        }
        catch (Exception ex)
        {
          SqlContext.Pipe.Send("cannot do the conversion:" + ex);
          return -1;
        }
      }
    

    So the problem is probably in other place. Also please make sure that the latest service pack has been applied to your SQL Server before we move on.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Wednesday, February 9, 2011 6:58 AM