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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:32:37+00:00 2026-05-13T05:32:37+00:00

I am writing a small framework in C# for importing data to SQL Server.

  • 0

I am writing a small framework in C# for importing data to SQL Server.

I have noticed that if you try to use the ? placeholder for parameters, they do not work if you use the System.Data.SqlClient namespace.

However, if you use the System.Data.OleDb namespace for working with the database, they work just fine. (you just have to add Provider=SQLOLEDB in your connect string)

So I have a few questions, because the ? syntax is required by my solution:

  1. Is there an alternative to using named parameters with System.Data.SqlClient? I want to use ordered parameters.
  2. Is there any performance impact to using one namespace (ado provider) over the other?
  3. Is there any other reason I should prefer one namespace over the other?

To elaborate on what I’m trying to do, my framework is going to take a class decorated with some custom attributes and generate SQL like so:

INSERT INTO myTable (col1, col2, ...) VALUES (?, ?, ...)

This string will be created with one IDbCommand and several IDataParameters and for each ExecuteNonQuery it will merely set the values on the IDataParameters.

Any thoughts?

Edit: I tried using named parameters as p0, p1, etc. as an answerer mentioned and it is working pretty well on SqlClient. However if I use Oledb, it errors saying:

"Must declare the scalar variable @p0."

My parameter is created like so:

new OleDbParameter("p" + index, GetType(attribute)); 
//GetType does work to get the correct SqlDbType

What is wrong? I also tried adding and removing the @ symbol in the parameter name to no avail.

FINAL EDIT: I just made Oledb use ? and SqlClient use named parameters. I can change back and forth for new providers.

  • 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-13T05:32:37+00:00Added an answer on May 13, 2026 at 5:32 am

    Thats the behaviour of those classes. OleDb uses ?, SqlClient named parameter.

    Perfomance: I have no benchmarks, but I think the SqlClient should perform better with an Sql Server than OleDB. SqlClient is explicit for Sql Server, OleDB for any kind of Datasource (even Excel). But pls. try it out.

    With SqlClient you can also have “ordered parameter”. Just call you parameter @Param1, @Param2, @Param3….

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

Sidebar

Ask A Question

Stats

  • Questions 306k
  • Answers 306k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You have to put this line: list: .word 3, 2,… May 13, 2026 at 9:13 pm
  • Editorial Team
    Editorial Team added an answer Heap is the most common way to implement dymanic memory… May 13, 2026 at 9:13 pm
  • Editorial Team
    Editorial Team added an answer There are probably plenty of more concise ways of doing… May 13, 2026 at 9:13 pm

Related Questions

I actually have two questions regarding the same problem but I think it is
I am writing a number of small, simple applications which share a common structure
My intend is to create a simple easily debuggable console application which will be
I am writing a small C++ program for fun and for extending my C++
I am writing a small C# app to disable a device (my laptop touchpad)

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.