打印本文 打印本文 关闭窗口 关闭窗口
ADO连接数据库字符串大全
作者:武汉SEO闵涛  文章来源:敏韬网  点击数5768  更新时间:2009/4/23 10:50:20  文章录入:mintao  责任编辑:mintao
eDbConnection.Open()

For more information, see: System.Data.OleDb Namespace and .NET Data Providers
Note: ''''ADO'''' namespace got renamed to ''''OleDb''''


ODBC .NET Managed Provider (System.Data.ODBC)
 
The ODBC .NET Data Provider is an add-on component to the .NET Framework SDK Beta 2.
It provides access to native ODBC drivers the same way the OLE DB .NET Data Provider
provides access to native OLE DB providers.

For SQL Server ODBC Driver:

Dim oODBCConnection As Odbc.OdbcConnection
Dim sConnString As String

'''' Create and open a new ODBC Connection
sConnString = "Driver={SQL Server};" & _
           "Server=MySQLServerName;" & _
           "Database=MyDatabaseName;" & _
           "Uid=MyUsername;" & _
           "Pwd=MyPassword;"

oODBCConnection = New Odbc.OdbcConnection(sConnString)
oODBCConnection.Open()

For Oracle ODBC Driver:

Dim oODBCConnection As Odbc.OdbcConnection
Dim sConnString As String

'''' Create and open a new ODBC Connection
sConnString = "Driver={Microsoft ODBC for Oracle};" & _
          "Server=OracleServer.world;" & _
          "Uid=myUsername;" & _
          "Pwd=myPassword;"

oODBCConnection = New Odbc.OdbcConnection(sConnString)
oODBCConnection.Open()

For Access (JET) ODBC Driver:

Dim oODBCConnection As Odbc.OdbcConnection
Dim sConnString As String

'''' Create and open a new ODBC Connection
sConnString = "Driver={Microsoft Access Driver (*.mdb)};" & _
          "Dbq=c:\somepath\mydb.mdb;" & _
          "Uid=Admin;" & _
          "Pwd=;"

oODBCConnection = New Odbc.OdbcConnection(sConnString)
oODBCConnection.Open()

For all other ODBC Drivers:

Dim oODBCConnection As Odbc.OdbcConnection
Dim sConnString As String

'''' Create and open a new ODBC Connection
sConnString = "Dsn=myDsn;" & _
           "Uid=myUsername;" & _
           "Pwd=myPassword;"

oODBCConnection = New Odbc.OdbcConnection(sConnString)
oODBCConnection.Open()


上一页  [1] [2] [3] [4] 

打印本文 打印本文 关闭窗口 关闭窗口