Teson
Teson

Reputation: 6736

asp.net: Is sqlConnection ADO?

Upvotes: 0

Views: 212

Answers (3)

Amit Kumawat
Amit Kumawat

Reputation: 602

Yes it is part of ADO.NET. If you use SqlConnection, actually it is a part of ADO.NET to make a connection between your application and database.

Upvotes: 0

pseudocoder
pseudocoder

Reputation: 4402

1) The SqlConnection Class is part of the System.Data.SqlClient namespace, and is considered part of ADO.NET.

2) OleDbConnection is for connecting to OLE databases. If you're talking about building a platform-agnostic data access layer, you should use System.Data.Common.DbProviderFactories to create generic DbConnection, DbCommand, etc, objects as in the following code example:

    Dim objFactory As DbProviderFactory = DbProviderFactories.GetFactory(ConfigurationManager.AppSettings("DbType"))

    Dim objConnection As DbConnection = objFactory.CreateConnection
    objConnection.ConnectionString = strConnectionString

In this example, you'd keep the name of the actual provider you're using in your Application Settings.

Note that the generic DB objects only support lowest-common-denominator methods so if you're looking for something platform-specific, you're out of luck. Also of course you will have to specify a valid DBtype to the provider factory, which means you'll have to use either one of the built in providers (ODBC, MS SQL, Oracle, OLEDB) or a third party one. I think you could get away with ODBC if you have a ODBC driver for your platform, but I don't know much about that one.

For information on the different connection objects included in ADO.NET: MSDN-Connecting to Data Sources

Upvotes: 1

Mike Marshall
Mike Marshall

Reputation: 7850

SqlConnection is part of the ".NET Data Provider for SQL Server", so it is ADO.NET, not to be confused with the old COM-based ADO.

Also, yes I believe OleDBConnection is preferred for Access. I do not believe there is an out-of-the box native data provider for MS Access.

Upvotes: 6

Related Questions