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 8740737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:10:59+00:00 2026-06-13T11:10:59+00:00

Im reading the code for Microsoft.ApplicationBlocks.Data ( code is here ) But I’ve notice

  • 0

Im reading the code for Microsoft.ApplicationBlocks.Data ( code is here )

But I’ve notice something strange :

in one of the function ( executeNonQuery) he tries to read Sp’s param from cache and if not exists , he put them into the cache ( not asp.net cache – but an internal HashSet)

public static int ExecuteNonQuery(string connectionString, string spName, params SqlParameter[] parameterValues)
    {
        if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");
        if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");
        // If we receive parameter values, we need to figure out where they go
        if ((parameterValues != null) && (parameterValues.Length > 0))
        {
            // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
            //------------------------------------

            SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);

           //------------------------------------
            // Assign the provided values to these parameters based on parameter order
            AssignParameterValues(commandParameters, parameterValues);
            // Call the overload that takes an array of SqlParameters
            return ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName, commandParameters);
        }
        else
        {
            // Otherwise we can just call the SP without params
            return ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName);
        }
    }

Please look at the isolated line.

Why did they do that? How does it help me if I have the params in Cache ? Im gonna send the params anyway from my dal …( and I must send my params to a SP)…

What am I missing ?

  • 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-13T11:11:00+00:00Added an answer on June 13, 2026 at 11:11 am

    Without the caching, they’d end up calling SqlCommandBuilder.DeriveParameters for each call to ExecuteNonQuery, for which MSDN states:

    DeriveParameters requires an additional call to the database to obtain the information. If the parameter information is known in advance, it is more efficient to populate the parameters collection by setting the information explicitly.

    So it makes sense to cache the retrieved parameter information to avoid these extra calls.

    UPDATE:

    Im gonna send the params anyway from my dal …( and I must send my params to a SP)…

    Note the int ExecuteNonQuery(string connectionString, string spName, params object[] parameterValues) overload — you may or may not send the parameters.

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

Sidebar

Related Questions

My code was quite sufficient for reading xls file in C# (using Microsoft.Jet.Oledb.4.0) but
I'm reading code from GraphServer . And there is this function that has weird
I`m reading the code of some open source project. I see that in one
Can some one please tell me the problem with this code. I am reading
While reading Microsoft documentation, I stumbled on such an interesting code sample: interface ISomeInterface
I am reading someone Else's javascript code which is listed below window.onload = function(){
I am reading Excel worksheet data using C# and Microsoft.Office.Interop. The sheet contains some
I was reading a block of code, which reads an Microsoft access database schema.
Error while reading Excel sheet from C#: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source
Is there any way of reading and writing the data from a Microsoft Project

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.