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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:33:27+00:00 2026-05-16T23:33:27+00:00

My application needs to do a certain query against a user-specified connectionstring. The query

  • 0

My application needs to do a certain query against a user-specified connectionstring. The query will need some parameters, so I was thinking of using the DbProviderFactory , in combination with myConnection.GetSchema("DataSourceInformation").Rows[0]["ParameterMarkerFormat"] to find out if I need to use :(Oracle), @(Sql) or ?(OleDb) to send in the parameters to the database.

To use the DbProviderFactory I need to find out what Provider is needed for a connectionstring. Is there a good way to do this, or do I need to use some sort of if(conStr.indexOf("oledb") != -1) { type = DbTypes.OleDB; } logic? (Or is there a better way to connect to an “unknown” database type?)

Note: The DbProviderFactory expects the provider to be in the form of System.Data.SqlClient, not the SQLNCLI.1 that is in the actual connectionstring.

  • 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-16T23:33:28+00:00Added an answer on May 16, 2026 at 11:33 pm

    The thing is that a connection string has meaning only in the context of the provider and not the other way around. In other words there’s no standard for identifying the provider based on the string. That said, you can generally infer the provider from the string as you’ve demonstrated with using IndexOf.

    You can get a list of installed providers using the static method DbProviderFactories.GetFactoryClasses(). This will return a DataTable with a row for each provider. The row will have the column “InvariantName” that will give you the correct value to pass to DbProviderFactories.GetFactory. If your application design allows, you can expose the list of available providers at the same time you get the connection string so your users can specify which provider they intend to make the connection. The “Name” column is intended for that very purpose.

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

Sidebar

Related Questions

I need a method to disable user interaction with the application for certain calls
I have an application that needs branding when downloaded in certain continents. When installed
I am working on ASP.net Webform application where i need to block certain dates
I have an application where I need to fire a notification on certain days
I need to save images in certain folder of my application: string path=E:\AJAXEnabledWebSite1\images\gallery I
I need to schedule a console application to run daily at a certain time
I need to get the Handler to the child Window of a certain application
I'm using SQLAlchemy as the ORM within an application i've been building for some
I'm developing an application that will need to communicate with itself running on different
I'm creating an SL4 app that needs to query certain data via a webservice

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.