some clarifications about adonet and access database

  • Thread starter Thread starter Mr. x
  • Start date Start date
M

Mr. x

Hello,
I am using .NET technology and access database.
to connect to the database I use :
....
dim conn
.....
conn = new oleDBConnection("provider = microsoft.jet.oledb.4.0; data source
= " & server.mappath("mydb.mdb"))
....
Is it true that the above is good for ado.net, and it only provides by a
specific driver (oledb) that I can connect to the database.

For sql-server I will use another command (sqlConnection), and it still
could be for ado.net development.

(What I am saying that there is not specific command for connecting and
working with database in ado.net - in access is one thing - oledbconnection,
and in sql-server is another thing - sqlconnection, but still there is no
connection between the command for connecting to the database, and whether
the connection is used by ado.net or not).

So what I understand is that ADO.NET conclude some elements such as
asp:repeater, etc, and use the old standard way to connect to the database,
by any driver.

Am I right ?

Thanks :)
 
I'm not totally sure I understand your question, but if you want to use a
generic provider and then instantiate a specific one...this should work.

The connectionstring is going to be differenent for any Client/Server DB vs
a Desktop DB. All provider specific connections implement
IDBCOnnection...so you can declare conn as IDBConnection.

You can create an enumeration lile

Public Enum Connectoer
SqlServer
Oledb
ODBC
End Enum

Then, use a function and based on the Enum Value

Public Sub CreateConnection(ByVal ConnectString as String, ByVal en as
Connector)

Select Case en
Case SqlServer:
conn = New SqlConnections(ConnectString)
Case Oledb:
conn = new OledbConnection(ConnectString)
Case ODBC:
conn = new ODBCConnection(ConnectString)


End Case

End Sub
 
Back
Top