eff33be82587e54c6b018fc46f3eb878.png
 

如果你是用 ADO 來連線資料庫的話,這些應該會常用到!要記起來!

 
  • ODBC Driver for dBASE
    "Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=c:\DatabasePath;"
     
    查詢使用:
    Select Name, Address From Clients.dbf
  • ODBC Driver for Excel
    "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;bq=C:\DatabasePath\DBSpreadSheet.xls;DefaultDir=c:\databasepath;"
     
    ODBC Driver for Text
    "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=C:\DatabasePath\;Extensions=asc,csv,tab,txt;"
     
    查詢使用:
    Select Name, Address From Clients.csv
  • Visual FoxPro
    "Driver={Microsoft Visual Foxpro Driver};UID=;SourceType=DBC;SourceDB=C:\DatabasePath\MyDatabase.dbc;Exclusive=No"
     
    如果沒有使用 .DBC (Database container) 的話則是:
    "Driver={Microsoft Visual Foxpro Driver};UID=;SourceType=DBF;SourceDB=C:\DatabasePath\MyDatabase.dbc;Exclusive=No"
  • ODBC Driver for Access
    "Driver={Microsoft Access Driver (*.mdb)};Dbq=c:\DatabasePath\dbaccess.mdb;Uid=;Pwd=;"
    "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\VC Projects\ADO\Samples\AdoTest\dbTestSecurity.mdb;SystemDB=C:\Program Files\Microsoft Office\Office\SYSTEM.mdw;Uid=Carlos Antollini;Pwd=carlos"
    獨佔模式:
    "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\VC Projects\ADO\Samples\AdoTest\dbTestSecurity.mdb;SystemDB=C:\Program Files\Microsoft Office\Office\SYSTEM.mdw;Uid=Carlos Antollini;Pwd=carlos"
  • ODBC Driver for SQL Server
    標準模式:
    "Driver={SQL Server};Server=MyServerName;Trusted_Connection=no;Database=MyDatabaseName;Uid=MyUserName;Pwd=MyPassword;"
    信任模式:
    "Driver={SQL Server};Server=MyServerName;Database=myDatabaseName;Uid=;Pwd=;"
    "Driver={SQL Server};Server=MyServerName;Database=MyDatabaseName;Trusted_Connection=yes;"
    若為本機執行
    "Driver={SQL Server};Server=(local);Database=MyDatabaseName;Uid=MyUserName;Pwd=MyPassword;"
    遠端主機可以這樣:
    "Driver={SQL Server};Server=130.120.110.001;Address=130.120.110.001,1052;Network=dbmssocn;Database=MyDatabaseName;Uid=myUsername;Pwd=myPassword;"
  • ODBC Driver for Oracle
    "Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=MyUsername;Pwd=MyPassword;"
    舊版的 Oracle Driver:
    "Driver={Microsoft ODBC Driver for Oracle};ConnectString=OracleServer.world;Uid=myUsername;Pwd=myPassword;"
  • ODBC DSN
    這應該是最簡單的!
    "DSN=MyDSN;Uid=MyUsername;Pwd=MyPassword;"
    若是有使用 OLE DB 的話

    OLE DB Provider for SQL Server
    "Provider=sqloledb;Data Source=MyServerName;Initial Catalog=MyDatabaseName;User Id=MyUsername;Password=MyPassword;"
    信任連線:
    "Provider=sqloledb;Data Source=MyServerName;Initial Catalog=MyDatabaseName;Integrated Security=SSPI;"
    不同的 Named instance:
    "Provider=sqloledb;Data Source=MyServerName\MyInstanceName;Initial Catalog=MyDatabaseName;User Id=MyUsername;Password=MyPassword;"
    本機連線
    "Provider=sqloledb;Data Source=(local);Initial Catalog=myDatabaseName;User ID=myUsername;Password=myPassword;"
    遠端主機
    "Provider=sqloledb;Network Library=DBMSSOCN;Data Source=130.120.110.001,1433;Initial Catalog=MyDatabaseName;User ID=MyUsername;Password=MyPassword;"
    OLE DB Provider for MySQL
    "Provider=MySQLProv;Data Source=test"
    OLE DB Provider for AS400
    "Provider=IBMDA400;Data source=myAS400;User Id=myUsername;Password=myPassword;
    OLE DB Provider for Active Directory
    "Provider=ADSDSOObject;User Id=myUsername;Password=myPassword;"
    OLE DB Provider for DB2
    "Provider=DB2OLEDB;Network Transport Library=TCPIP;Network Address=130.120.110.001;Initial Catalog=MyCatalog;Package Collection=MyPackageCollection;Default Schema=MySchema;User ID=MyUsername;Password=MyPassword;"
    使用 APPC 連線:
    "Provider=DB2OLEDB;APPC Local LU Alias=MyLocalLUAlias;APPC Remote LU Alias=MyRemoteLUAlias;Initial Catalog=MyCatalog;Package Collection=MyPackageCollection;Default Schema=MySchema;User ID=MyUsername;Password=MyPassword;"
    OLE DB Provider for Microsoft Jet - Access
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DatabasePath\MmDatabase.mdb;User Id=admin;Password=;"
    如果使用 Workgroup:
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DataBasePath\mydb.mdb;Jet OLEDB:System Database=MySystem.mdw;"
    OLE DB Provider for Microsoft Jet - Excel
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\DatabasePath\\DBSpreadSheet.xls;Extended Properties="Excel 8.0;HDR=Yes;"
    OLE DB Provider for Microsoft Jet - Text File
    Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DatabasePath\;Extended Properties="text";HDR=Yes;FMT=Delimited;
    OLE DB Provider for Microsoft Jet - Outlook
    "Provider=Microsoft.Jet.OLEDB.4.0;Outlook 9.0;MAPILEVEL=;DATABASE=C:\Temp\;"
    OLE DB Provider for Microsoft Jet - Exchange
    "Provider=Microsoft.Jet.OLEDB.4.0;Exchange 4.0;MAPILEVEL=Mailbox - Pat Smith|;DATABASE=C:\Temp\;"
    OLE DB Provider for ODBC Databases - Access
    "Provider=MSDASQL;Driver={Microsoft Access Driver (*.mdb)};Dbq=c:\DatabasePath\MyDatabase.mdb;Uid=MyUsername;Pwd=MyPassword;"
    OLE DB Provider for ODBC Databases - SQL Server
    "Provider=MSDASQL;Driver={SQL Server};Server=MyServerName;Database=MyDatabaseName;Uid=MyUsername;Pwd=MyPassword;"
    使用 DSN:
    "Provider=MSDASQL;PersistSecurityInfo=False;Trusted_Connection=Yes;Data Source=MyDSN;catalog=MyDatabase;"
    OLE DB Provider for OLAP
    "Provider=MSOLAP;Data Source=MyOLAPServerName;Initial Catalog=MyOLAPDatabaseName;"
    使用 HTTP 連線:
    "Provider=MSOLAP;Data Source=http://MyOLAPServerName/;Initial Catalog=MyOLAPDatabaseName;"
    SSL:
    "Provider=MSOLAP;Data Source=https://MyOLAPServerName/;Initial Catalog=MyOLAPDatabaseName;"
    OLE DB Provider for Oracle (Micorsoft)
    "Provider=MSDAORA;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;"
    OLE DB Provider for Oracle (Oracle)
    "Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;"
    信任連線:
    "Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=/;Password=;"
    以 OSAuthent 認證:
    "Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;OSAuthent=1;"
    OLE DB Provider for Visual FoxPro
    "Provider=vfpoledb;Data Source=C:\DatabasePath\MyDatabase.dbc;"

     
  • 其他較少用到的

    ODBC Driver for AS400
    "Driver={Client Access ODBC Driver (32-bit)};System=myAS400;Uid=myUsername;Pwd=myPassword;"
    ODBC Driver for SyBase
    "Driver={Sybase System 10};Srvr=MyServerName;Uid=MyUsername;Pwd=myPassword;"
    ODBC Driver for Sybase SQL AnyWhere
    ODBC;Driver=Sybase SQL Anywhere 5.0;DefaultDir=C:\DatabasePath\;Dbf=C:\SqlAnyWhere50\MyDatabase.db;Uid=MyUsername;Pwd=MyPassword;Dsn="";
Facebook 討論區載入中...