- Connection String
Normally,A connection string is a string which can be used to easily store connection
information within your application or to pass it between applications. Without
using a connection string, you need to store or pass a complex array of structures
to access data. suppose you are accessing OLE DB directly, using IDataInitialize,
the connection string is passed as a parameter to create an OLE DB data source.
- DSN Less Connection
-
-
the following examaple demonstrates the ODBC Driver with the SQL Server for
Standard Security
- sqlCon = _T("Driver={SQL Server};Server=ServerName;" "Trusted_Connection=no;"
"Database=DBName;Uid=usrName;Pwd=urpwd;");
the following examaple demonstrates the ODBC Driver for the SQL Server
with Trusted Connection
- sqlCon = _T("Driver={SQL Server};Server=ServerName;" "Database=DBName;Uid=;Pwd=;");
the following examaple demonstrates the ODBC Driver for the SQL Server
with Trusted Connection that indicates windows authentication mode
- sqlCon = _T("Driver={SQL Server};Server=ServerName;" "Database=DBName;Trusted_Connection=yes;");
-
- If you planned to connect with a remote SQL Server,then you must provide the address,
the port, and the Network which are all referred to as the parameter: The Address
parameter must be an IP address with the port. The Network parameter can be one
of the following:
- dbnmpntw Win32 Named Pipes
- dbmssocn Win32 Winsock TCP/IP
- dbmsspxn Win32 SPX/IPX
- dbmsvinn Win32 Banyan Vines
- dbmsrpcn Win32 Multi-Protocol
- sqlCon = _T("Driver={SQL Server};Server=130.120.110.001;" "Address=130.120.110.001,1052;Network=dbmssocn;Database=DBName;"
"Uid=usrName;Pwd=pwd;");
the following examaple demonstrates the ODBC Driver for the DBase
- sqlCon = _T("Driver={Microsoft dBASE Driver (*.dbf)};DriverID=320;"
"Dbq=c:\\DBPath;");
here, you must specify the filename in sql query as:
- sqlQuery = _T("Select * From txtFileName.dbf");
-
-
the following examaple demonstrates the ODBC Driver for Excel
- sqlCon = _T("Driver={Microsoft Excel Driver (*.xls)};DriverId=420;"
bq=C:\\DBPath\\DBExcelSheet.xls;DefaultDir=c:\\databasepath;");
-
-
the following examaple demonstrates the ODBC Driver for Text File
- sqlCon = _T("Driver={Microsoft Text Driver (*.txt; *.csv)};"
"Dbq=C:\\DBPath\\;Extensions=asc,csv,tab,txt;");
here, you must specify the filename in sql query as:
- sqlQuery = _T("Select * From txtFileName.csv");
-
-
the following examaple demonstrates the ODBC Driver for Visual Foxpro with
database container
- sqlCon = _T("Driver={Microsoft Visual Foxpro Driver};UID=;"
SourceType=DBC;SourceDB=C:\\DBPath\\DB1.dbc;Exclusive=No");
-
-
the following examaple demonstrates the ODBC Driver for Visual Foxpro without
database container
- sqlCon = _T("Driver={Microsoft Visual Foxpro Driver};UID=;"
"SourceType=DBF;SourceDB=C:\\DBPath\\DB1.dbc;Exclusive=No");
-
-
the following examaple demonstrates the ODBC Driver for Access
- sqlCon = _T("Driver={Microsoft Access Driver (*.mdb)};" "Dbq=c:\\DBPath\\DB1.mdb;Uid=;Pwd=;");
-
-
the following examaple demonstrates the ODBC Driver for Oracle for current
version
- sqlCon = _T("Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;"
"Uid=usrName;Pwd=pwd;");
-
-
the following examaple demonstrates the ODBC Driver for Oracle for old version
- sqlCon = _T("Driver={Microsoft ODBC Driver for Oracle};Server=OracleServer.world;"
"Uid=usrName;Pwd=pwd;");
-
-
the following examaple demonstrates the ODBC Driver for MySQL for localhost
- sqlCon = _T("Driver={MySQL ODBC 3.51 Driver};Server=localhost;"
"Database=DBName;User=usrName;Password=pwd;Option=4;");
-
-
the following examaple demonstrates the ODBC Driver for MySQL for Remote
Connection
- sqlCon = _T("Driver={mySQL ODBC 3.51 Driver};Server=rmtServer;"
"Port=2032;Option=4;Database=DBName;Uid=usrName;Pwd=pwd;");
-
For more information about the Option, go to
MyODBC Reference Manual
-
-
the following examaple demonstrates the ODBC Driver for AS400
- sqlCon = _T("Driver={Client Access ODBC Driver (32-bit)};System=smplAS400;"
"Uid=usrName;Pwd=pwd;");
-
-
the following examaple demonstrates the ODBC Driver for SyBase
- sqlCon = _T("Driver={Sybase System 10};Srvr=servrName;Uid=usrName;"
"Pwd=pwd;");
-
- DSN Connection
-
-
the following examaple demonstrates the ODBC DSN
- sqlCon = _T("DSN=urDSN;Uid=usrName;Pwd=pwd;");
-
- OLE DB Provider
-
-
the following examaple demonstrates the OLE DB Provider for SQL Server with
Standard Security
- sqlCon = _T("Provider=sqloledb;Data Source=srvrName;" "Initial
Catalog=DBName1;" "User Id=usrName;Password=pwd;");
-
-
the following examaple demonstrates the OLE DB Provider for SQL Server with
Trusted Connection
- sqlCon = _T("Provider=sqloledb;Data Source=srvrName;" "Initial
Catalog=DBName1;" "Integrated Security=SSPI;");
-
-
the following examaple demonstrates the OLE DB Provider for SQL Server 2000
with Named Instance
- sqlCon = _T("Provider=sqloledb;Data Source=srvrName\insName;"
"Initial Catalog=DBName1;User Id=usrName;Password=pwd;");
-
-
the following examaple demonstrates the OLE DB Provider for SQL Server with
Remote computer
- sqlCon = _T("Provider=sqloledb;Network Library=DBMSSOCN;" "Data
Source=130.120.110.001,1433;" "Initial Catalog=DBName1;User ID=usrName;" "Password=pwd;");
-
-
the following examaple demonstrates the OLE DB Provider for SQL Server with
Remote computer
- sqlCon = _T("Provider=sqloledb;Network Library=DBMSSOCN;" "Data
Source=130.120.110.001,1433;" "Initial Catalog=DBName1;User ID=usrName;" "Password=pwd;");
-
-
the following examaple demonstrates the OLE DB Provider for MySQL
- sqlCon = _T("Provider=MySQLProv;Data Source=DBName");
-
-
the following examaple demonstrates the OLE DB Provider for AS400
- sqlCon = _T("Provider=IBMDA400;Data source=smplAS400;User Id=usrName;"
"Password=pwd;");
-
-
the following examaple demonstrates the OLE DB Provider for Active Directory
- sqlCon = _T("Provider=ADSDSOObject;User Id=usrName;Password=pwd;");
-
-
the following examaple demonstrates the OLE DB Provider for DB2 with TCP/IP
connection
- sqlCon = _T("Provider=DB2OLEDB;Network Transport Library=TCPIP;"
"Network Address=130.120.110.001;" "Initial Catalog=DBName1;Package Collection=PackageCollection1;"
"Default Schema=Schema1;User ID=usrName;Password=pwd;");
-
-
the following examaple demonstrates the OLE DB Provider for DB2 with APPC
connection
- sqlCon = _T("Provider=DB2OLEDB;APPC Local LU Alias=LocalLUAlias1;"
"APPC Remote LU Alias=RemoteLUAlias1;Initial Catalog=DBName1;" "Package Collection=PackageCollection1;Default
Schema=Schema1;" "User ID=usrName;Password=pwd;");
-
-
the following examaple demonstrates the OLE DB Provider for Microsoft Jet Access
Filewith Standard Security
- sqlCon = _T("Provider=Microsoft.Jet.OLEDB.4.0;" "Data Source=C:\\DBPath\\DB1.mdb;"
"User Id=usrName;Password=pwd;");
-
-
the following examaple demonstrates the OLE DB Provider for Microsoft Jet Access
Filewith workgroup
- sqlCon = _T("Provider=Microsoft.Jet.OLEDB.4.0;" "Data Source=C:\\DBPath\\DB1.mdb;"
"Jet OLEDB:System Database=sys.mdw;"); pRs.Open(strConnect, "usrName", "pwd");
-
-
the following examaple demonstrates the OLE DB Provider for Microsoft Jet Excel File
- sqlCon = _T("Provider=Microsoft.Jet.OLEDB.4.0;" "Data Source=C:\\DBPath\\DB1.xls;"
"Extended Properties=\"\"Excel 8.0;HDR=Yes;\"\";");
-
-
the following examaple demonstrates the OLE DB Provider for Microsoft Jet Text File
- sqlCon = _T("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\DBPath\\;"
"Extended Properties=\"\"text;" "HDR=Yes;FMT=Delimited;\"\";");
-
here, you Must provide the filename in SQL Query as:
- sqlQuery = _T("Select * From FileName.txt");
-
-
the following examaple demonstrates the OLE DB Provider for Microsoft Jet Outlook
2000 personal mail box
- sqlCon = _T("Provider=Microsoft.Jet.OLEDB.4.0;Outlook 9.0;"
"MAPILEVEL=;DATABASE=C:\\DBPath\\;")
-
-
the following examaple demonstrates the OLE DB Provider for Microsoft Jet Exchange
mail box
- sqlCon = _T("Provider=Microsoft.Jet.OLEDB.4.0;Exchange 4.0;"
"MAPILEVEL=Mailbox - Pat Smith|;DATABASE=C:\\DBPath\\;")
-
-
the following examaple demonstrates the OLE DB Provider for ODBC Databases
with Access
- sqlCon = _T("Provider=MSDASQL;Driver={Microsoft Access Driver
(*.mdb)};" "Dbq=c:\\DBPath\\DB1.mdb;Uid=usrName;Pwd=pwd;");
-
-
the following examaple demonstrates the OLE DB Provider for ODBC Databases
with SQL Server
- sqlCon = _T("Provider=MSDASQL;Driver={SQL Server};Server=srvrName;"
"Database=DBName1;Uid=usrName;Pwd=pwd;");
-
-
the following examaple demonstrates the OLE DB Provider for ODBC Databases
with DSN
- sqlCon = _T("Provider=MSDASQL;PersistSecurityInfo=False;" "Trusted_Connection=Yes;"
"Data Source=DSN1;catalog=DB1;");
-
-
the following examaple demonstrates the OLE DB Provider for ODBC Databases
with DSN
- sqlCon = _T("Provider=MSOLAP;Data Source=OLAPServerName1;"
"Initial Catalog=OLAPDatabaseName1;");
-
- HTTP Connection
-
-
the following examaple demonstrates the Connection with URL
- sqlCon = _T("Provider=MSOLAP;Data Source=http://www.sample.com/;"
"Initial Catalog=OLAPDatabaseName1;");
-
-
the following examaple demonstrates the Connection with SSL
- sqlCon = _T("Provider=MSOLAP;Data Source=https://www.sample.com/;"
"Initial Catalog=OLAPDatabaseName1;");
-
-
the following examaple demonstrates the OLE DB Provider for Oracle from Microsoft
- sqlCon = _T("Provider=MSDAORA;Data Source=OracleDB1;User Id=usrName;"
"Password=pwd;");
-
-
the following examaple demonstrates the OLE DB Provider for Oracle from Oracle
with standard security
- sqlCon = _T("Provider=OraOLEDB.Oracle;Data Source=OracleDB1;"
"User Id=usrName;Password=pwd;");
-
-
the following examaple demonstrates the OLE DB Provider for Oracle from Oracle
with Trusted Connection
- sqlCon = _T("Provider=OraOLEDB.Oracle;Data Source=OracleDB1;"
"User Id=/;Password=;");
-
-
the following examaple demonstrates the OLE DB Provider for Oracle from Oracle
with Trusted Connection by OSAuthent
- sqlCon = _T("Provider=OraOLEDB.Oracle;Data Source=OracleDB1;OSAuthent=1;")
-
-
the following examaple demonstrates the OLE DB Provider for Visual Foxpro
- sqlCon = _T("Provider=vfpoledb;" "Data Source=C:\\DBPath\\db1.dbc;");
-
-
the following examaple demonstrates the OLE DB Provider for Index Server
- sqlCon = _T("provider=msidxs;Data Source=Catalog1;");
-
- OLE DB Data Link Connections
-
- sqlCon = _T("File Name=c:\\DBPath\\db1.udl;");