0

In my C# code, I need to debug my store procedure in SQL server 2008 R2 from Visual Studio 2013.

I followed the solution here:

How to debug SQL Server T-SQL in Visual Studio 2012

I can only select "Application Debugging" for the whole server not one database if I want to do debugging.

But, I only need to debug for one procedure on one server !!!

My C#:

        //call my procedure
        cmd = new SqlCommand("sql_server_2008_my_procedure", connection);
        cmd.CommandType = CommandType.StoredProcedure;

        SqlParameter retval = cmd.Parameters.Add("@my_return_value", SqlDbType.TinyInt);
        retval.Direction = ParameterDirection.ReturnValue;

        cmd.ExecuteNonQuery();  // I can step into the store procedure from here ?

        int my_return_value = (int)cmd.Parameters["@my_return_value"].Value;

        using (SqlDataReader myreader = cmd.ExecuteReader())
        {
            if (my_return_value == 1) 
            {
                throw new Exception("sql_server_2008_my_procedure return a wrong status !");
            }
            while (reader.Read())
            {
                     int s = reader.GetInt32(0) 
                     // do something ...
            }
       }

And, in C# debug status, I cannot step into the procedure even though I have set up "application debugging" in SQL server object explorer of VS 2013.

Where I can step into my procedure ?

thanks !

Community
  • 1
  • 1
user3448011
  • 1,469
  • 1
  • 17
  • 39

2 Answers2

0

Do you have problem with that procedure? Just check what is the value of the parameter and than test it in ssms caling it with exactly same value

laspalmos
  • 149
  • 1
  • 3
  • 20
0

There is no way you can step into the Stored Procedure from a .Net program however you do can open the Stored Procedure and set a break point so it will stopped there. This is a certain kind of limitation about multi-tier SQL debugging, you can check Microsoft link here for more detail: http://msdn.microsoft.com/en-us/library/vstudio/kkyhd4yb(v=vs.100).aspx

Simon Wang
  • 2,843
  • 1
  • 16
  • 32