none
what is the meaning of Provider in c#? RRS feed

  • Question

  • hi guys,
    When we want to connect to MS SQL Server 2005 we just write the following connection string:
    "Server=.;Database=Building;Integrated security=true"

    but want to work with Access we should write something like below:

    "Provider=Ms....;DataSource=foo.mdb;.."
    I want to know 
    1.could we write datasource instead of database?
    2.what is actually a provider?


    Monday, April 21, 2008 5:11 AM

Answers

  • Hi,

     

    1.could we write datasource instead of database?

     
    Yes. The connection string below connects to Access 2007
     
    Code Snippet
    Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Mydb.accdb;Persist Security Info=False;

     

     

     

    2.what is actually a provider?
     
    A Data Provider is a collection of classes to access a data source like a database using Managed code. There are various providers like the
     
    .NET Framework Data Provider for ODBC, OLEDB, Oracle, and SQL Server.

     

     

    HTH,
    Suprotim Agarwal

    Monday, April 21, 2008 5:30 AM
  • Hi simosi,

    Suprotim gave you the answer you were looking for? The connection string given is what is used for accessing an Access database?

    A Data Provider, again is just as Suprotim said, they are a collection of specialised classes for working with different data sources. They comprise of DataAdapters (for managing table concurrency), Connection (for managing the connection to the data source), DataReaders (for forward-only, read-only access to data) and Command (for processing commands against the DBMS).

    Now, there are different versions for different DBMS systems, you can access these in the System.Data namespace, then there are namespaces within there for each type (SQL, OLEDB etc).

    You should always use the managed provider if possible, in your case, you want to use the OLEDbProvider. Note MS Access IS NOT MS SQL. When using the managed providers, you do not need to specify the "Provider" element of the connection string.
    Monday, April 21, 2008 7:01 AM

All replies

  • Hi,

     

    1.could we write datasource instead of database?

     
    Yes. The connection string below connects to Access 2007
     
    Code Snippet
    Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Mydb.accdb;Persist Security Info=False;

     

     

     

    2.what is actually a provider?
     
    A Data Provider is a collection of classes to access a data source like a database using Managed code. There are various providers like the
     
    .NET Framework Data Provider for ODBC, OLEDB, Oracle, and SQL Server.

     

     

    HTH,
    Suprotim Agarwal

    Monday, April 21, 2008 5:30 AM
  • thanks Suprotim,

    Code Snippet
    Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Mydb.accdb;Persist Security Info=False;

     

    I want to know that can i write DataBase="C:\Mydb... instead of Data Source.


    and do you mean a Data Provider is set of classes to how to access a datasource and database.if so then why dont we write data provider when want to access to MS SQL.What is the reason.

    Monday, April 21, 2008 6:05 AM
  • Hi simosi,

    Suprotim gave you the answer you were looking for? The connection string given is what is used for accessing an Access database?

    A Data Provider, again is just as Suprotim said, they are a collection of specialised classes for working with different data sources. They comprise of DataAdapters (for managing table concurrency), Connection (for managing the connection to the data source), DataReaders (for forward-only, read-only access to data) and Command (for processing commands against the DBMS).

    Now, there are different versions for different DBMS systems, you can access these in the System.Data namespace, then there are namespaces within there for each type (SQL, OLEDB etc).

    You should always use the managed provider if possible, in your case, you want to use the OLEDbProvider. Note MS Access IS NOT MS SQL. When using the managed providers, you do not need to specify the "Provider" element of the connection string.
    Monday, April 21, 2008 7:01 AM