Database Engine | ConnectionString |
DBASE (using ODBC) | Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=C:/path/to/database |
Excel (using ODBC) | Driver={Microsoft Excel Driver (*.xls)};DriverID=790;Dbq=C:/path/to/spreadsheet;DefaultDir=C:/path/to/defaultdir |
Excel (using OLE DB) | Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Path/To/sheet.xls; |
Access (using ODBC) | Driver={Microsoft Access Driver (*.mdb)};Dbq=C:/path/to/database.mdb;Uid=username;Pwd=password You can also pass additional options -- for example Exclusive=1; sets it to be opened in exclusive mode. |
Access (using OLE DB) | Using standard security Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/path/to/database.mdb;User Id=username;Password=somepassword; Using Workgroup security str="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=database.mdb;JET OLEDB:System Database=mysystem.mdw;" oConn.Open(str, "my_user_name", "my_password") |
Firebird | Remote Database Provider='LCPI.IBProvider';Data Source='remotehost:C:/path/to/database.fdb';User ID='username';Password='pwd';Auto Commit=true; The above is reported to work for a Firebird database by Edward Diamond (ediamond at water dot ca dot gov). I would presume that it could work on a local Firebird server, simply by removing "remotehost" from the string above. Edward reports that even simple queries don't work without the "Auto Commit" part in the connection string. |
MySQL (using ODBC) | Local Database Driver={MySQL ODBC 3.51 Driver};Server=localhost;User=username;Password=mypassword;Database=mydatabase; Remote Database Driver={MySQL ODBC 3.51 Driver};Server=192.168.1.100;Port=3306;User=username;Password=mypassword;Database=mydatabase; There are more parameters that can be set (for example, Option, which controls several connection properties such as logging, packet size limits etc.) See section 3.3 (Connection Parameters) of the MyODBC manual for more information. |
MySQL (using OLE DB) | Provider=MySQLProv;Server=192.168.1.100;Port=3306;User=username;Password=mypassword;Database=mydatabase; If you have the datasource already set up: Provider=MySQLProv;Data Source=name_of_datasource; You will need to download and install MyOleDB first. Last time I checked MyOLEDB was no longer maintained. |
Oracle (using ODBC) | Driver={Microsoft ODBC for Oracle};Server=MyOracleServer;Uid=username;Pwd=password See the MSDN library for additional options. |
Oracle (using OLE DB) | Using OLE DB provider from Microsoft Provider=MSDAORA;Data Source=MyOracleDB;User Id=username;Password=password See the MSDN library for additional options. Using OLE DB provider from Oracle Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=username;Password=password |
SQL Server (using ODBC) | Standard Security Driver={SQL Server};Server=192.168.1.100;Uid=username;Pwd=password;Database=dbname; Trusted Connection Simply add Trusted_Connection=yes to the above string. See MSDN Library for more options. |
SQL Server (using OLE DB) | Provider=SQLOLEDB.1;Data Source=192.168.1.100;Uid=username;Pwd=password;Database=dbname; See MSDN Library for more options. |
DataBase ConnectionString (good)
最新推荐文章于 2020-04-07 15:40:21 发布