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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:17:43+00:00 2026-05-18T20:17:43+00:00

I implemented a custom DbProviderFactory which returned the SqlX types except I added the

  • 0

I implemented a custom DbProviderFactory which returned the SqlX types except I added the following logic to CreateCommand

public override DbCommand CreateCommand()
{
    var cmd = new SqlCommand();
    if (CommandCreated != null)
        CommandCreated(cmd, EventArgs.Empty);
    cmd.StatementCompleted += cmd_StatementCompleted;
    return cmd;
}

void cmd_StatementCompleted(object sender, StatementCompletedEventArgs e)
{
    if (StatementCompleted != null)
        StatementCompleted(sender, e);
}

I did this so I could track whenever a SqlDataSource created a command and then when it finished to log all SqlCalls (without needing Sql Profiler up). This worked, however after I implemented this I got an exception with the following SqlDataSource

<asp:SqlDataSource ProviderName="MyProvider" ID="SqlDataSource1" 
    runat="server" ConnectionString="<%$ ConnectionStrings:default %>"
    SelectCommandType="StoredProcedure"
    SelectCommand="dbo.GetX" 
    OnSelecting="SqlDataSource1_Selecting">
    <SelectParameters>
      <asp:Parameter Name="x_id" Type="Byte"/>
    </SelectParameters>
</asp:SqlDataSource>

and this in the code behind.

protected void SqlDataSource1_Selecting(object sender, SqlDataSourceCommandEventArgs e)
{
    e.Command.Parameters["@x_id"].Value = "something else";
}

The error being thrown was that the SqlParameter “@x_id” doesn’t exist, even though this worked with the standard SqlClientFactory. When using the debugger it showed that there was 1 parameter in the collection x_id when using MyProvider, and @x_id when using the default provider.

Is there some reason for this and is there some way I can get the @’s added automatically or should I just make sure the code-behind and the SqlDataSource agree on whether there is an @ or not.
The Stored Procedure still works without the ‘@’ sign and luckily I don’t do this direct manipulation of the Parameters collection much but I would like to know why this happens in the first place.

Thanks for the help.

  • 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-18T20:17:44+00:00Added an answer on May 18, 2026 at 8:17 pm

    After digging more I found the following in the Source of SqlDataSourceView

    protected virtual string ParameterPrefix
    {
      get
      {
        if (!string.IsNullOrEmpty(this._owner.ProviderName) && !string.Equals(this._owner.ProviderName, "System.Data.SqlClient", StringComparison.OrdinalIgnoreCase))
        {
          return string.Empty;
        }
        return "@";
      }
    }
    

    and so when using your own Provider it doesn’t match the expected Provider name and so it just returns string.Empty. If you need to do this then you will have to subclass SqlDataSource and SqlDataSourceView

    public class MySqlDataSource : SqlDataSource
    {
        protected override SqlDataSourceView CreateDataSourceView(string viewName)
        {
            return new MySqlDataSourceView(this, viewName, this.Context);
        }
    }
    
    public class MySqlDataSourceView : SqlDataSourceView
    {
        private MySqlDataSource _owner;
        public MySqlDataSourceView(IPSqlDataSource owner, string name, System.Web.HttpContext context)
            : base(owner, name, context)
        {
            _owner = owner;
        }
    
        protected override string ParameterPrefix
        {
            get
            {
                if (!string.IsNullOrEmpty(this._owner.ProviderName) && !string.Equals(this._owner.ProviderName, "MyProvider", StringComparison.OrdinalIgnoreCase))
                {
                    return base.ParameterPrefix;
                }
                return "@";
            }
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have successfully implemented a custom SimpleCursorAdapter for an AutoCompleteTextView, which suggests entries from
I have implemented a set of ASP.NET web custom controls and added these to
I have a site on .NET 3.5 platform with implemented custom authentication for site
I've implemented a custom annotation derived from MKAnnotation called ContainerAnnotation and a custom annotation
I've implemented a custom role provider, and configured it in my web.config file like
I have implemented a custom UINavigationbar using this code (placed in the top of
I have implemented a custom table view cell. I can get the cell to
I have own control implemented in CommonControls assembly (the same namespace). It us 'Custom
I'm trying out this nice way of customizing grouped UITableViewCell backgrounds: http://code.coneybeare.net/how-to-make-custom-drawn-gradient-backgrounds I've implemented
I have a custom object that I am trying to bind to a control.

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.