数据库连接字符串大全
ACCESS | |
ODBC | |
标准安全 | "Driver={Microsoft Access Driver (*.mdb)}; Dbq=C:/mydatabase.mdb; Uid=Admin; Pwd=; " |
工作组 | "Driver={Microsoft Access Driver (*.mdb)}; Dbq=C:/mydatabase.mdb; SystemDB=C:/mydatabase.mdw; " |
独占 | "Driver={Microsoft Access Driver (*.mdb)}; Dbq=C:/mydatabase.mdb; Exclusive=1; Uid=admin; Pwd=" |
OLE DB, OleDbConnection (.NET) | |
标准安全 | "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=/somepath/mydb.mdb; User Id=admin; Password=; " |
工作组 (system database) | "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=/somepath/mydb.mdb; Jet OLEDB:System Database=system.mdw; " |
使用密码 | "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=/somepath/mydb.mdb; Jet OLEDB:Database Password=MyDbPassword; " |
Oracle | |
ODBC | |
新版本 | "Driver={Microsoft ODBC for Oracle}; Server=OracleServer.world; Uid=Username; Pwd=asdasd; " |
旧版本 | "Driver={Microsoft ODBC Driver for Oracle}; ConnectString=OracleServer.world; Uid=myUsername; Pwd=myPassword; " |
OLE DB, OleDbConnection (.NET) | |
标准安全 | "Provider=msdaora; Data Source=MyOracleDB; User Id=UserName; Password=asdasd; " |
This one's from Microsoft, the following are from Oracle | |
标准安全 | "Provider=OraOLEDB.Oracle; Data Source=MyOracleDB; User Id=Username; Password=asdasd; " |
信任的连接 | "Provider=OraOLEDB.Oracle; Data Source=MyOracleDB; OSAuthent=1; " |
OracleConnection (.NET) | |
标准 | "Data Source=MyOracleDB; Integrated Security=yes; " |
This one works only with Oracle 8i release 3 or later | |
指定用户名和密码 | "Data Source=MyOracleDB; User Id=username; Password=passwd; Integrated Security=no; " |
This one works only with Oracle 8i release 3 or later | |
定义OracleConnection对象 | C#: |
using System.Data.OracleClient; | |
OracleConnection oOracleConn = new OracleConnection(); | |
oOracleConn.ConnectionString = "my connection string"; | |
oOracleConn.Open(); | |
VB.NET: | |
Imports System.Data.OracleClient | |
Dim oOracleConn As OracleConnection = New OracleConnection() | |
oOracleConn.ConnectionString = "my connection string" | |
oOracleConn.Open() | |
Core Labs OraDirect (.NET) | |
标准 | "User ID=scott; Password=tiger; Host=ora; Pooling=true; Min Pool Size=0; Max Pool Size=100; Connection Lifetime=0" |
Data Shape | |
微软数据模型 | "Provider=MSDataShape.1; Persist Security Info=False; Data Provider=MSDAORA; Data Source=orac; user id=username; password=mypw" |
MySQL | |
MyODBC | |
MyODBC 2.50 本地数据库 | "Driver={mySQL}; Server=localhost; Option=16834; Database=mydatabase; " |
MyODBC 2.50 远程数据库: | "Driver={mySQL}; Server=data.domain.com; Port=3306; Option=131072; Stmt=; Database=my-database; Uid=username; Pwd=password; " |
MyODBC 3.51 本地数据库 | "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=myDatabase; USER=myUsername; PASSWORD=myPassword; OPTION=3; " |
MyODBC 3.51 远程数据库 | "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=data.domain.com; PORT=3306; DATABASE=myDatabase; USER=myUsername; PASSWORD=myPassword; OPTION=3; " |
OLE DB, OleDbConnection (.NET) |