Database connection strings In various application development of the database, the connection database is the first step in database application development, and it is also the most important step. For different databases, their connection modes are different, and the corresponding connection strings are different. Programmers may have such experiences, sometimes I don't know how to write or write the connection string to the database, causing the database. Of course, many programming tools can directly generate the correct connection string through visual interface, but the specific meaning of each parameter in the string is not clear, often confused.
This article lists the connection string required for different connection methods for most common databases, so that the programmer reference! SQL Server · ODBC O standard connection ("driver = {sql server}; server = aron1; database = pubs; uid = sa; pwd = asdasd;" 1) When the server is local, Server can use (local) "Driver = {SQL Server}; server = (local); database = pubs; uid = sa; pwd = asdasd;" 2) When connecting to a remote server, you need to specify an address, port number and a network library "Driver = {SQL Server}; server = 130.120.110.001; address = 130.120.110.001, 1052; network = dbmsocn; database = pubs; uid = sa; pwd = asdasd; "Note: The address parameter must be an IP address, and must include port number O trust Trusted Connection: (Microsoft Windows NT Integrate Security) "Driver = {SQL Server}; server = aron1; database = pubs; trusted_connection = yes;" or "driver = {SQL Server}; server = aron1; database = PUBS; UID =; PWD =; "O connection When I popup input username and password dialog box: conn.properties (" prompt ") = adpromptalways conn.open" driver = {sql server}; server = aron1; database = pubs; "· OLE DB, OLEDBCONNECTION (.NET) O Standard Connection:" Provider = Sqloledb; Data Source = Aron1; Initial Catalog = Pubs; user ID = sa; password = asdasd; "TRUSTED Connection : "Provider = sqloledb; data source = aron1; initial catalog = pubs; integrated security = sspi;" (If you connect a specific named SQLServer instance, use data source = servere name / instance name; but only for SQLServer2000), for example: "Provider = sqloledb; data source = myservername / myinstancename; initial catalog = myDatabaseName; user ID = myusername; password = mypassword;
"O" O conneter "pops up input username and password dialog box: conn.provider =" sqloledb "conn.properties (" prompt ") = admptalways conn.open" Data Source = aron1; initial catalog = pubs; "OtTial Catalog = PUBS;" O "Provider = sqloledb; Data Source = 190.190.200.100,1433; Network Library = DBMSSOCN; Initial Catalog = pubs; User ID = sa; Password = asdasd;" (DBMSSOCN = TCP / IP instead of Named Pipes, the end is required Data Source The port number (default 1433)) · SQLConnection (.NET) O standard connection (data source = aron1; initial catalog = pubs; user ID = sa; password = askASD; "or" server = Aron1; Database = PUBS; User ID = sa; password = asdasd; trusted_connection = false "O Trusted connection:" data source = aron1; initial catalog = public; integrated security = SSPI; "or" server = aron1; database = public_connection = true; "(the result of these two connection strings) (can be used with servername / instanceename instead of Data Source, with a specific SQLServer instance, but only Suitable for SQLServer2000) O via an IP address: "Data Source = 190.190.200.100, 1433; Network library = dbms SoCn; init IAL catalog = public; paramed = sa; password = sa; "(DBMSSOCN = TCP / IP instead of NAMED PIPES, the end of Data Source is required to use the port number (default 1433)) o SqlConnection connection: C #: using System.Data.SqlClient; SqlConnection sQLConn = new SqlConnection (); SQLConn.ConnectionString = "my connectionstring"; SQLConn.Open (); VB.NET: Imports System.Data.SqlClient Dim sQLConn As SqlConnection = New SqlConnection () sQLConn .Connectionstring = "my connectionstring"
Sqlconn.open () · Data Shape O MS Data Shape "provike = msdatashape; data source = sqloledb; data source = aron1; initial catalog = pubs; user ID = sa; password = askASD;" · More o How to define which agreement § For example: "Provider = sqloledb; Data Source = 190.190.200.100,1433; network library = dBMSSOCN; Initial Catalog = pubs; User ID = sa; Password = asdasd;" name of the network protocol library dbnmpntw Win32 Named Pipes dbmssocn Win32 Winsock TCP / IP DBMSSPXN WIN32 SPX / IPX DBMSRPCN WIN32 BANYAN VINES DBMSRPCN WIN32 MULTI-Protocol (Windows RPC) § Important Use the following syntax when connecting through the SQLOLEDB provider: Network library = dbmssocn but uses the following syntax when connecting through the MSDasql provider : Network = DBMSSOCN O All SQLConnection Connection Series Properties § The following table shows all connection string properties of the ADO.NET SQLConnection object. Most of these properties are also used in ADO. All attributes and descriptions come from MSDN. Name Default Description Application Name application name or when the application is not provided for an application for the .NET SQLCLIENT data provider AttachDbFileName or the name of the main file name, including the associated database, including the full path to the associated database. The database name must be specified by keyword 'database'. Connect Timeout or Connection Timeout 15 In the abort connection request, wait for the time (in seconds) of the error before the error is generated (in seconds) Connection Lifetime 0 When a connection returns to the connection pool, the current time and the connection creation time, if the time period exceeds The specified connection survival time is destroyed. It is used to force load balancing between running servers and ready-to-line servers in aggregate settings. Connection Reset 'True' When the connection is removed from the connection pool, it is decided to reset the database connection. When set to 'false', it is used to avoid the additional server to get a connection. CURRENT LANGUAGE SQL Server Language Record Data Source or Server or Address or Addr or Network Address's name or network address enlist 'true' is true, the connection pool automatically lists the current transaction context of creating threads. connection. Initial Catalog or Database Database Name Integrated Security or Trusted_Connection 'false' connection is a trust connection.
It takes the value of 'True', 'false' and 'SSPI' (equal to 'TRUE'). Max Pool Size 100 Connecting the maximum number of connections allowed in the pool MIN POOL SIZE 0 connection pool The minimum connection number NetWork Library or Net The 'DBMSSOCN' network library is used to establish a connection with a SQL Server instance. The value includes DBNMPNTW, DBMSRPCN (Multi-Protocol), DBMsadSn (Apple Talk), DBMSGNET (VIA), DBMSIPCN (Shared Memory), and DBMSSPXN (IPX / SPX), and DBMSSOCN (TCP / IP). The corresponding dynamic link library must be installed. If you don't specify a network, when you use a local server (for example, ","), you will use the shared memory packet size 8192 network packet byte size password-or from an instance of SQL Server The PWD SQL Server Account Login password Persist security info 'false' is set to 'false', when the connection has been turned on or in an open state, the sensitivity security information (such as password) does not return a part of the connection. Pool 'true' is true, remove the SqlConnection object from the appropriate connection pool, or create a SQLConnection object if necessary and increase it to the appropriate connection pool. User ID SQL Server Login User WorkStation ID The Local Computer Name Connecting to SQL Server Workstation Name § Note: Separating the Section Separation Every Attribute If a name is more than twice, the last occurrence of the last appearance in the connection string will be use. If you build a connection string by entering the value of the field in the app, you must ensure that the user does not insert an additional attribute through another value in the user value to change the connection string.
Access · ODBC O
Standard connection (
Standard Security
)
: "Driver = {Microsoft Access Driver (* .mdb)}; dbq = c: /mydatabase.mdb; uid = admin; pwd =;" O
Group (system database) connection
(
Workgroup
)
:
The two methods are: specify the username and password in the connection string or in the open data set.
"Driver = {Microsoft Access Driver (* .mdb)}; dbq = c: /mydatabase.mdb; systemdb = c: /mydatabase.mdw;", "admin", ""
or
IF (PDB.Open ("Driver = {Microsoft Access Driver (* .mdb)}; dbq = c: /mydatabase.mdb; systemdb = c: /mydatabase.mdw;", "", "databaseuser", "databasepass" )) {Dosomething (); pdb.close ();} O
Excovered mode (
Exclusive
)
: "Driver = {Microsoft Access Driver (* .mdb)}; DBQ = C: /MyDatabase.mdb; Exclusive = 1; UID = admin; pwd =" · OLE DB, OLEDBCONNECTION (.NET) O Standard connection (
Standard Security
)
: "Provider = microsoft.jet.Oledb.4.0; data source = / somepath / mydb.mdb; user ID = admin; password =;" O
Group connection
(System database)
"Provider = microsoft.jet.Oledb.4.0; data source = / somepath / mydb.mdb; Jet OLEDB: system Database = system.mdw;", "admin", "" O "
With the connection
: "Provider = microsoft.jet.OLEDb.4.0; data source = / somepath / mydb.mdb; jet oledb: Database password = mydbpassword;", "admin", "" Oracle · ODBC O
new version
: "Driver = {Microsoft Odbc for oracle}; server = oracleserver.world; uid = username; pwd = asdasd;" O
old version
: "Driver = {Microsoft Odbc Driver for Oracle}; connectString = ORASERNAME; PWD = mypassword;" OLE DB, OLEDBCONNECTION (.NET) O
Standard connection (
Standard Security
)
: "Provider = msdara; data source = myoracledb; user ID = username; password = asdasd;"
this is
Microsoft
Format
,
Below is
Oracle
Format (different suppliers)
"Provider = oraoledb.oracle; data source = myoracledb; user ID = username; password = asdasd;"
note:
"Data Source ="
Must be set to be set according to the corresponding naming method
Net8
name. For example, for local naming, it is
Tnsnames.ora
Alias, for
Oracle
Name, it is
Net8
Network service name
o
Trust connection
Trusted Connection
)
: "Provider = oraoledb.oracle; data source = myoracledb; osauthent = 1;"
Set up
User ID
for
"/" "Provider = oraoledb.racle; data source = myoracledb; user ID = /; password =;" · OracleConnection (.NET) O standard connection
: "Data Source = Oracle8i; Integrated Security = YES";
This is only right
Oracle 8i Release 3
Or higher version is effective
o OracleConnection
statement
: C #: using System.Data.OracleClient; OracleConnection OracleConn = new OracleConnection (); OracleConn.ConnectionString = "my connectionstring"; OracleConn.Open (); VB.NET: Imports System.Data.OracleClient Dim OracleConn As OracleConnection = New OracleConnection () OracleConn.ConnectionString = "my connectionstring" OracleConn.Open () · Data Shape o MS Data Shape: "Provider = MSDataShape.1; Persist Security Info = False; Data Provider = MSDAORA; Data Source = orac; user id = username Password = mypw "· MySQL · ODBC O
Local database
: "Driver = {mysql}; server = mysrvname; option = 16834; Database = mydatabase;" Sever
Parameters can also be used
Localhost
Its value
o
Remote database
: "Driver = {mysql}; server = data.domain.com; port = 3306; option = 131072; stmt =; database = my-data; uid = username; pwd = password;" Option
value
Value meaning
1
Client can not be processed
Myodbc
Returns a real width
2
Client can not be processed
Mysql
If this flag is set, it is set.
Mysql
return'
Found Rows
'.
Mysql
3.21.14
Or update version to take effect
4
in
C: /myodbc.log
Generate a debug log. This with
`Autoexec.bat '
Setting
Mysql_debug = d: t: o, c :: / myodbc.log
the same
8
No packages are set for results and parameters
16
Do not bring the drive to the problem
32
Use or remove dynamic cursor support. This
Myodbc 2.50
Medium is not allowed
64
in
'Database.table.column'
Lires the use of the database name
128
Fork
ODBC
Manager cursor
256
Remove the extension value (
Fetch
)usage of
512
full
charr
Field full length
1024 SQLDESCRIBECOL ()
Function Returns the column name that fully meets the conditions
2048
Using a compressed server
/
Client protocol
4096
Tell the server after the function
'
Neglect space
(PowerBuilder
need
)
. This will produce all function name keywords
8192
Run using the named pipe connection
NT
Up
Mysqld
server
16384
will
Longlong
Change to
Intl
Column (some applications can not be processed
Longlong
Column)
32768
From
SQLTables
Return '
User
'
Table_qualifier
with
Table_OWNER 66536
Read the parameters from the client, from
`my.cnf '
read
ODBC
group
131072
Add some additional security check
If you need a lot of options, you should add the above flags.
· OLE DB, OLEDBCONNECTION (.NET) O
Standard connection
: "Provider = mysqlprov; data source = mydb; user id = username; password = asdasd;" Data Source
Yes
Mysql
The name of the database can also be used
Server = localhost; db = test · mysqlConnection (.NET) o Einfodesigns.dbProvider: "Data Source = Server; Database = MyDB; user ID = username; password = pwd; command logging = false"
only apply to
Einfodesigns dbProvider,
Append
.NET O mysqlconnection
statement of
: C #: using eInfoDesigns.dbProvider.MySqlClient; MySqlConnection MySqlConn = new MySqlConnection (); MySqlConn.ConnectionString = "my connectionstring"; MySqlConn.Open (); VB.NET: Imports eInfoDesigns.dbProvider.MySqlClient Dim MySqlConn As MySqlConnection = New MySqlConnection () Mysqlconn.connectionstring = "my connectionString" mysqlconn.open () · Interbase · ODBC, EasySoft O
Local computer
: "Driver = {EasySoft IB6 ODBC}; server = localhost; database = localhost: c: /mydatabase.gdb; uid = username; pwd = password" O
Remote computer
: "Driver = {easysoft IB6 odbc}; server = computername; database = computename: c: /mydatabase.gdb; uid = username; pwd = password" · ODBC, Intersolv o Local computer
: "Driver = {INTERSOLV Interbase ODBC Driver (* .GDB)}; server = localhost; data = localhost: c: /mydatabase.gdb; uid = username; pwd = password" O
Remote computer
: "Driver = {INTERSOLV Interbase ODBC Driver (* .GDB)}; server = computername; Database = computername: c: /mydatabase.gdb; uid = username; pwd = password
This drive is now
DataDirect Technologies
Provide
(
Before
INTERSOLV
provide
) · OLE DB, SIBPROVIDER O
Standard connection
: "Provider = sibprovider; location = localhost:; data source = c: /database/gdbs/mygdb.gdb; user ID = sysdba; password = masterkey" O
Specify character set
: "Provider = sibprovider; location = localhost:; data source = c: /databases/gdbs/mygdb.gdb; user ID = sysdba; password = masterkey; character set = ISO8859_1" O
Specified role
: "Provider = sibprovider; location = localhost:; data source = c: /databases/gdbs/mygdb.gdb; user ID = sysdba; password = masterkey; role = digitadores
Need to know more, please
Interbase
As follows
Borland
Developer network article
Http://community.borland.com/Article/0, 1410, 27152, 00.html · IBM DB2 · OLE DB, OLEDBCONNECTION (.NET) from MS O TCP / IP: "Provider = DB2OLDB; Network Transport Library = TCPIP ; Network Address = XXX.XXX.XXX.XXX; Initial Catalog = MyCtlg; Package Collection = MyPkgCol; Default Schema = Schema; User ID = MyUser; Password = myPW "o APPC:" Provider = DB2OLEDB; APPC Local LU Alias = MyAlias ; APPC Remote LU Alias = MyRemote; Initial Catalog = MyCtlg; Package Collection = MyPkgCol; Default Schema = Schema; User ID = MyUser; Password = myPW "AS400 · ODBC" Driver = {Client Access ODBC Driver (32-bit)}; System = myAS400; Uid = myUsername; Pwd = myPassword "· OLE DB, OleDbConnection (.NET)" Provider = IBMDA400; Data source = myAS400; User Id = myUsername; Password = myPassword; "· Sybase · ODBC o Sybase System 12 ( or
12.5) ENTERPRISE OPEN CLIENT
Standard connection
: "Driver = {Sybase ASE ODBC Driver}; SRVR = aron1; uid = username; pwd = password" o Sybase System 11
Standard connection
: "Driver = {Sybase System 11}; SRVR = aron1; uid = username; pwd = password;" o I INTERSOLV 3.10: "Driver = {INTERSOLV 3.10 32-bit Sybase}; SRVR = aron1; uid = username; pwd = password "O Sybase SQL Anywhere
Previously
Watcom SQL ODBC Driver: "ODBC; Driver = Sybase SQL Anywhere 5.0; defaultdir = c: / dbfolder /; dbf = c: /mydatabase.db; uid = username; pwd = password; dsn =" "" "
note:
For the end of the end
DSN
Double quotes referenced by parameters
(VB
grammar
),
You must change the reference symbol syndrome specified by the language you use.
DSN
The parameter is very important to actually, if not including it will cause
7778
error.
· OLE DB O Adaptive Server Anywhere (ASA): "Provider = asaprov; data source = myasa" o Adaptive ServeRPrise
(ASE)
(With data source
.Ids.
file)
: "Provider = Sybase ASE OLE DB Provider; Data Source = Myase"
Note You must use the Data Manager to create a data source
.Ids.
file
.
These ones
.Ids.
File is similar to
ODBC DSNS. Visual FoxPro
(
DBASE
)
· ODBC o DBASE: "Driver = {Microsoft DBase DRIVER (* .dbf)}; driverid = 277; dbq = c: // DatabasePath"
Pay attention to writing
SQL
The file name (such as "must be specified when the statement is
Select Name, Address from Clients.dbf
")
O Visual FoxPro
Database container
: "Driver = {Microsoft Visual FoxPro Driver}; UID =; SourceType = DBC; SourceDb = C: //DatabasePath/MyDatabase.dbc; Exclusive = no" o Visual FoxPro
No agriculture container
: "Driver = {Microsoft Visual FoxPro Driver}; UID =; SourceType = DBF; SourceDb = C: //Database.
Standard connection
: "Provider = vfpoledb; data source = c: //database.com," Excel · ODBC O "Excel · ODBC O" Excel · ODBC O "
Standard connection (
Standard Security
)
: "Driver = {Microsoft Excel Driver (* .xls)}; driverid = 790; dbq = c: //databasepath/dbspreadsheet.xls; defaultdir = c: // DatabasePath;" Ole DB Provider for Microsoft Jet O
Standard connection (
Standard Security
)
: "Provider = microsoft.jet.Oledb.4.0; data source = c: //databasepath//dbspreadsheet.xls; extended proties = /" / "excel 8.0; hdr = yes; /" / ";"
Note: If
"HDR = YES"
Then, the provider will not include the first line of the selection in the record set, if, the provider will include the first line of the unit range (or a name) in the recordset.
TEXT · ODBC O standard connection (
Standard Security
)
: "Driver = {Microsoft Text Driver (* .txt; * .csv)}; dbq = c: // DatabasePath //; Extensions = ASC, CSV, Tab, TXT;"
If the text file is used
Tab
As a separator, you must create
Schema.ini
Document, you must use it in the connection string
Format = tabdelimited
Options.
Note: You must
SQL
Specify the file name in the statement (for example
"Select Name, Address from Clients.csv"
)
· OLE DB Provider for Microsoft Jet O
Standard connection (
Standard Security
)
: "Provider = microsoft.jet.Oledb.4.0; data source = c: // DatabasePath //; extended proties = /" / "text;" HDR = yes; fmt = Delimited; / ";"
Pay attention to writing
SQL
The file name (such as "must be specified when the statement is
Select Name, Address from Clients.txt
")
DSN = MyDSN; UID = myusername; PWD = mypassword; "OLE DB Provider for ODBC Databases
connection
Access: "provider = msdasql; driver = {microsoft access driver (* .mdb)}; dbq = c: //database.mdb; uid = myusername; pwd = mypassword;"
connection
SQL Server: "provider = msdasql; driver = {sql server}; server = myservername; database = mydatabaseename; uid = myusername; pwd = mypassword;"
use
DSN
Connect
: "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;"
by
HTTP
connection
:
This feature allows client applications to connect strings in client applications
Data Source
Specify one in the parameter
URL
Use
IIS
Connect to an analytical server.
This connection method allows
Pivottable
The service is connected to the analysis server via a firewall or proxy server. A special
ASP
page
MSOLAP.ASP
by
IIS
Connect. This file must be in this directory when connecting to the server
URL
a part of
(
E.g
http://www.myserver.com/myolap/).
use
URL
connection
: "Provider = msolap; data source = http: // myolapservername /; initial catalog = myolapdatabaseename;"
use
SSL
connection
: "Provider = MSOLAP; Data Source = https: // MyOLAPServerName /; Initial Catalog = MyOLAPDatabaseName;" OLE DB Provider for Active Directory "Provider = ADSDSOObject; User Id = myUsername; Password = myPassword;" OLE DB Provider for Index Server " provider = msidxs; Data Source = MyCatalog; "OLE DB Data Link Connections" File Name = c: //DataBasePath//DatabaseName.udl; "Outlook 2000 personal mail box" Provider = Microsoft.Jet.OLEDB.4.0; Outlook 9.0; Mapilevel =; Database = C: // Temp //; "
Use any temporary folder instead
C: / Temp
.
This will create a schema file in that folder, when you open it, it displays all the fields that can be obtained. empty
Mapilevel
Indicates the highest level of folder.
Exchange mail box "provider = microsoft.jet.Oledb.4.0; Exchange 4.0; mapilevel = mailbox - pat smith |; Database = C: // Temp //;"
Use any temporary folder instead
C: / Temp.
Note: You can look like a database
Mail Store
Enter query
Example:
"SQL" SELECTS. * From contacts; "