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

  • Home
  • SEARCH
  • 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 6108123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:15:46+00:00 2026-05-23T14:15:46+00:00

While using Visual Studio 2010 for my ASP.NET website, we have code for a

  • 0

While using Visual Studio 2010 for my ASP.NET website, we have code for a stored procedure call:

SqlDataAccess sqlDataAccess = new SqlDataAccess();

SqlParameter[] parameters =
{
    new SqlParameter("@R", rptType.Replace("'", "''")),
    new SqlParameter("@M", hybrDct["mod"].ToString().Replace("'", "''")),
    new SqlParameter("@C", hybrDct["CG"].ToString().Replace("'", "''")),
    new SqlParameter("@Ts$", hybrDct["TFields"].ToString().Replace("'", "''")),
};

sqlDataAccess.ProcName = "MyStoredProc";
sqlDataAccess.Parameters = parameters;

Is it possible to get the execute printed out for debugging purposes instead of finding out each individual SqlParameter and typing it in individually?

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-05-23T14:15:46+00:00Added an answer on May 23, 2026 at 2:15 pm

    I use something like the following – everything goes through this and gets logged – you get the idea.

    /// <summary>
    /// Executes a stored procedure with no return.
    /// </summary>
    /// <returns>The number of records affected by stored proc.</returns>
    public static int ExecuteStoredProc(string storedProcName, params SqlParameter[] parameters)
    {        
        StringBuilder callDefinition = new StringBuilder();
        callDefinition.Append(string.Format("ExecuteStoredProc: {0} (", storedProcName));
        for (int i = 0; i < parameters.Count(); i++)
        {
            callDefinition.Append(string.Format("{0}={1}", parameters[i].ParameterName, parameters[i].Value));
            if (i < parameters.Count - 1)
            {
                callDefinition.Append(",");
            }
        }
        callDefinition.Append(")";
        log.Debug(callDefinition.ToString());
        using (var ctx = ConnectionManager<SqlConnection>.GetManager(ConnectionProfile.ConnectionName))
        {
            using (SqlCommand command = new SqlCommand(storedProcName, ctx.Connection))
            {
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.CommandTimeout = 1000;
                foreach (SqlParameter parameter in parameters)
                {
                    command.Parameters.Add(parameter);
                    //log your param here
                }
    
                return command.ExecuteNonQuery();
            }
        }
    }
    
    /// <summary>
    /// Executes a query and returns a dataset
    /// </summary>
    public static DataSet ExecuteQueryReturnDataSet(string query, params SqlParameter[] parameters)
    {
        try
        {
            //implement the parameter logging here as in the above code sample as well
    
            log.Debug("Executing ExecuteQueryReturnDataSet() calling query " + query);
            using (var ctx = ConnectionManager<SqlConnection>.GetManager(ConnectionProfile.ConnectionName))
            {
                using (SqlCommand command = new SqlCommand(query, ctx.Connection))
                {
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandTimeout = 1000;
                    foreach (SqlParameter parameter in parameters)
                    {
                        command.Parameters.Add(parameter);
                    }
                    using (SqlDataAdapter adapter = new SqlDataAdapter(command))
                    {
                        DataSet dataSet = new DataSet();
                        adapter.Fill(dataSet);
                        return dataSet;
                    }
                }
            }
        }
        catch (Exception ex)
        {
            log.Error(ex);
            throw;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While developing and ASP.NET application in C# or VB using Visual Studio 2005/2008/2010 (Not
I have been working in Visual Studio 2010, in asp.net, i am using Jquery
I'm using Visual Studio 2010 and ASP.NET 4.0 to render a Menu control as
i am using asp.net 4.0 iis 7.5 microsoft visual studio 2010 what i want
I have a Microsoft Access 2010 database(*). Now, using Visual Studio 2010, I want
I am developing an MVC3 application using Visual Studio 2010. I have an aspx
I am using Visual Studio 2010. I have read that in C++ it is
While i was writing a piece of code in C# using ASP.NET i needed
I'm using Visual Studio 2010. When I change the code in my source file,
I'm having problem from a while (since I'm using visual studio 2010 I think).

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.