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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:19:14+00:00 2026-05-24T06:19:14+00:00

I want to generate several SQL statements based on a column list using the

  • 0

I want to generate several SQL statements based on a column list using the column names as parameters.

Edit: C#

var columns = new string[] { "COL1", "COL2" };
var tableName = "TABLE_1";
var prefix = "@"; // TODO get this from the provider factory

string sqlInsert = string.Format(
    "INSERT INTO {0}\n( {1}) VALUES\n({2})",
    tableName,
    string.Join(",  ", columns),
    string.Join(", ", columns.Select(c => prefix + c)));

Generated SQL:

INSERT INTO TABLE_1
( COL1,  COL2) VALUES
(@COL1, @COL2)

This works with the SqlClient. But I’m using the abstract classes in System.Data (DbCommand, DbParameter, etc.) and different data providers such as Oracle, MySQL, Postgres etc based on the connection string settings in the app.config. Thus I need to know which prefix I have to use. For MS-SQL it is the @, Oracle uses the :, the rest I actually don’t know.

Is there a way to get this prefix character from the provider factory?

System.Data.SqlClient.SqlClientFactory.Instancedoesn’t have such an information or at least I couldn’t find it.

Otherwise, can you give me a list for the common databases?

Edit: The target platforms are .NET 2 to .NET 4 and the information should be available through 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-05-24T06:19:15+00:00Added an answer on May 24, 2026 at 6:19 am

    I found the answer, but I cannot reproduce how I found it:

    http://www.codewrecks.com/blog/index.php/2007/09/06/about-parametermarkerformat/

    The DbConnection can provide a schema table that also contains the correct format strings for creating command parameter names, except for SqlClient!!

    DbProviderFactory myFactory = DbProviderFactories.GetFactory(myProviderName);
    
    using (DbConnection myConnection = myFactory.CreateConnection())
    {
        myConnection.ConnectionString = mySettings.ConnectionString;
        myConnection.Open();
    
        string parameterMarker = myConnection
            .GetSchema(DbMetaDataCollectionNames.DataSourceInformation)
            .Rows[0][DbMetaDataColumnNames.ParameterMarkerFormat].ToString();
    
        myConnection.Close();
    }
    

    For SqlCclient parameterMarker is {0} but should be @{0}. I’ll investigate a bit more to find out what is contained in the other schema table columns.

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

Sidebar

Related Questions

I want to pass several parameters to this url and generate the map from
I want to generate some XML in a stored procedure based on data in
I want to generate a list in C#. I am missing python's list comprehensions.
Using ASP.NET to generate several checkboxes. Looking for a JavaScript solution that will test
I'm writing a JUnit test using JUnitPerf. Here, I want to generate some entries
I have several hundred thousand endpoint URLs that I want to generate stats for.
I want to generate a Kerberos ticket using .NET with auth credentials supplied through
Hey.. I've run into a problem using several like in my sql-query (generated with
Let's say I have a class of 30 students and want generate every possible
I want to generate a thumbnail preview of videos in Java. I'm mostly JMF

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.