multiple types of connections

  • Thread starter Thread starter Roberto - Ingresso.com
  • Start date Start date
R

Roberto - Ingresso.com

Hey all,
I have a dll written in Vb.Net which has all my application's database
access. I used OdbcConnection in it for legacy compatibility. I want to use
the same dll to access Sql Server 7.0 and higher with SqlClient library when
the database allows its use. I am going to use OdbcConnection for Sql Server
6.5 access still.
What is the best way of using in the same code for two or more data access
libraries?

here is a simple code... Would I have to write one function for each data
access type?

Dim conSala As OdbcConnection
Dim adpSala As OdbcDataAdapter

conSala = New OdbcConnection

conSala.ConnectionString = "DSN=Multi;uid=sasa;pwd=sasa;"

adpSala = New OdbcDataAdapter("SELECT CDPARAM FROM PARAMS ORDER BY
CDPARAM", conSala)

dstSala = New DataSet

Try

adpSala.Fill(dstSala, "Params")

Catch ex As Exception

Return False

Finally

conSala.Close()

conSala = Nothing

adpSala = Nothing

End Try

Return True
 
¤ Hey all,
¤ I have a dll written in Vb.Net which has all my application's database
¤ access. I used OdbcConnection in it for legacy compatibility. I want to use
¤ the same dll to access Sql Server 7.0 and higher with SqlClient library when
¤ the database allows its use. I am going to use OdbcConnection for Sql Server
¤ 6.5 access still.
¤ What is the best way of using in the same code for two or more data access
¤ libraries?
¤
¤ here is a simple code... Would I have to write one function for each data
¤ access type?

Not all databases are the same. For that reason I wouldn't even attempt to write generic ODBC code
for all of your databases. In addition, I can't recommend using the ODBC driver for SQL Server with
the ODBC .NET library. You should get better performance (and functionality) from the native .NET
SQL Server libraries.

You can still put all of your functionality into a single data access component without having to
use the same data access libraries.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top