Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8463019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:20:56+00:00 2026-06-10T14:20:56+00:00

I am debugging code someone else wrote that calls a lot of stored procedures

  • 0

I am debugging code someone else wrote that calls a lot of stored procedures (sql server 2008 r2) from C# code. The C# code looks like this

SqlCommand sqlCommand = new SqlCommand(strSP, ConnectionOpen());
sqlCommand.CommandType = CommandType.StoredProcedure;
sqlCommand.CommandTimeout = intTimeOut;
//System.Data.SqlClient.SqlParameter[] prmSQL
if (prmSQL != null)
{
  while (i < prmSQL.Length)
  {
    sqlCommand.Parameters.Add(prmSQL[i]);
    i = i + 1;
  }
}

SqlDataReader sqlReader = sqlCommand.ExecuteReader();

For debugging my stored procedures I really need the string that sql management studio needs which is like
exec sp_name param one, param two (with quotes if needed for strings and dates..)
The sql command object does not provide this string via some property. The only way I know is to run the sql profiler on sql server and grab the string. Unfortunately the DBA’s do not like this since they say running the profiler impacts performance. Is there any addin or code snippet you guys use to get the sp exec string from c# code ? Whats the best way to get this string ? Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:20:58+00:00Added an answer on June 10, 2026 at 2:20 pm

    You could use a tool like mvc-mini-profiler available on NuGet (note: the name is misleading; it isn’t limited to MVC). Minor clarification – since it wraps the connection, you would need to use the abstract DbConnection rather than SqlConnection, and then you just tweak the one line of code (probably in a utility class somewhere) that creates your connection, i.e. instead of:

    var conn = new SqlConnection(someString);
    return conn;
    

    you might use:

    var conn = new SqlConnection(someString);
    return new StackExchange.Profiling.Data.ProfiledDbConnection(
                conn, MiniProfiler.Current);
    

    There’s a couple of other steps to enable it (all shown on the site page), but it literally takes 2 minutes to add to an MVC application. The output is that it monitors, in real time, for enabled users (developers etc), all the activity. We use it 24×7 on stackoverflow/stackexchange (meaning: we made very sure it didn’t impact performance). A live demo is available on https://data.stackexchange.com/ – just log in, and the profiling data is visible top-left. It automatically presents the data in a form runnable from SSMS, because that is how we often use it – so: it presents parameters as though they were variable declarations / initializations.

    It also plays nicely with ORMs such as LINQ-to-SQL and dapper-dot-net (and many others).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently debugging someone else's code that flips the ups and downs relative
I'm working on debugging some code someone else wrote (using Mootools as the base
I'm debugging someone else's code for a web page that is made with ASP.NET
Most programmers will have had the experience of debugging/fixing someone else's code. Sometimes that
While debugging javascript written by someone else, I came across some code that I've
Lets start by saying that I am debugging someone else's code :-) The error
I am debugging someone else's JavaScript code and a majority of the code is
I'm busy debugging someone else's code and I've come across something I think is
I have been playing around with some debugging and wrote some C code that
I'm new to using logcat and debugging in Android. I've analyzing someone else's code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.