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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:37:02+00:00 2026-06-18T01:37:02+00:00

I am using ADO.NET interfaces to create a database independent program. The factory takes

  • 0

I am using ADO.NET interfaces to create a database independent program. The factory takes in a provider name and returns vendor specific objects which implement the ADO interface. This is great.

But I can’t find a factory for the flag which identifies a parameter.

string paramName = "@foo"; //flag "@" for sql server

string paramName = ":foo"; //flag ":" for oracle

Question: Does ADO.NET provide a factory method to obtain the flag?
I could roll my own separate factory for this, but it would limit me to a predefined list of providers; defeating much of the benefit of the provider factory.

  • 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-18T01:37:04+00:00Added an answer on June 18, 2026 at 1:37 am

    Unfortunately, the DbProviderFactory mechanism is very poorly designed IMHO.
    The mechanism itself is not extensible, all the interesting classes are sealed (SqlClientFactory, etc.), the configuration in the .config file is not extensible either.

    One simple solution is to build an extension class, like this:

    public static class DbProviderFactoryExtensions
    {
        public static DbParameter CreateParameter(this DbProviderFactory factory, string name)
        {
            DbParameter parameter = factory.CreateParameter();
            if (factory.GetType().FullName.IndexOf("sqlclient", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                name = "@" + name;
            }
            else if (factory.GetType().FullName.IndexOf("oracle", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                name = ":" + name;
            } // etc...
            parameter.ParameterName = name;
            return parameter;
        }
    }
    

    It’s not very smart, but you can do this in your code:

        DbProviderFactory factory = DbProviderFactories.GetFactory("MyDb");
        DbParameter parameter = factory.CreateParameter("myParam");
        // parameter.ParameterName will be @myParam if SQL, etc.
    

    Or you could also recreate your own system. It’s not very complicated, and can be worth it if you need other variable items per type of database.

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

Sidebar

Related Questions

I create a database using ADO.NET SQL queries like this: create database mydatabase create
using ado.net tipically we need to define a connectionstring to create a sqlconnection object,
i'm using ADO.NET to get some information from the database on a server, so
Using ADO.NET , what is the fastest way to retrieve data from the database
I was trying to use SQLite database using ADO.NET Entity Framework 5 and I
I have some existing code that retrieves data from a database using ADO.NET that
I'm using ADO.NET Appender of log4net for logging errors and other info. to database.
how can I by using Ado.net rename existing column in a table and changing
I am using ADO.NET (.NET 1.1) in a legacy app. I know that DataAdapter.Fill()
I'm building a data model using ADO.NET Entity Framework 3.5 in Visual Studio 2008

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.