Database connection string

xiaoxiao2021-03-06  97

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.

?????????????????? SQL Server ????? · ODBC ????? o standard connection (STANDARD Security): ????? "driver = {SQL Server }; Server = aron1; database = pubs; uid = sa; pwd = asdasd; "????? 1) When the server is local when Server can use (local); ?????" driver = {SQL Server} Server = (local); database = pubs; uid = sa; pwd = asdasd; "????? 2) When connecting the remote server, you need to specify the address, port number, and network library ?????" Driver = {SQL Server}; server = 130.120.110.001; address = 130.120.110.001, 1052; network = dbmssocn; database = pubs; uid = sa; pwd = asdasd; "????? Note: The Address parameter must be an IP address, And must include a Trusted Connection: (Microsoft Windows NT integrates security) ????? "Driver = {SQL Server}; server = aron1; database = public; trusted_connection = YES; "????? or ?????" driver = {SQL Server}; server = aron1; database = pubs; uid =; pwd =; "????? o Connect input username and password Dialog: ????? conn.properties ("prompt") = adpromptalways ????? conn.open "driver = {SQL Server}; server = aron1; data, = public;" ?????? ole DB, OLEDBCONNECTION (.NET) ????? o standard connection (STANDARD Security): ????? "proviker = SQLOLEDB; DATA SOURCE = aron1; initial catalog = public; user ID = sa; password = asdasd;" ????? o Trust connection (Trusted Connecti ): ????? "proviker = 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 the SQLServer2000), for example: "Provider = sqloledb; Data Source = myServerName / MyInstanceName; Initial Catalog = MyDatabaseName; User Id = MyUsername; Password = MyPassword;" pop-up input is connected ????? o Username and Password dialog: ????? conn.provider = "

SQLOLEDB "????? conn.properties (" prompt ") = adpromptalways ????? conn.open" data source = aron1; initial catalog = public; "????? 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 of Data Source is the port number (default 1433)) ????? · SqlConnection (.NET) ????? o Standard connection (STANDARD Security): ????? "DATA Source = aron1; initial catalog = public; "????? or ?????" server = aron1; database = pubs; user ID = sa; password = asdasd; trusted_connection = False "????? (the same result of these two connection strings) ????? o Trusted connection: ?????" Data Source = aron1; initial catalog = public; integrated security = SSPI "" ????? or ????? "" "server = aron1; database = pubs; trusted_connection = true;" ????? (the result of these two connection strings is the same) ????? ServerName / InstanceName replaces the Data Source, takes a specific SQLServer instance, but only for SQLServer2000) ????? o through the IP address: ????? "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 number required to use (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 provike = sqloledb; data source = aron1; initial catalog = Pubs; user ID = sa; password = asdasd; "????? · More ????? o How to define which protocol used ????? § Example: ?????" proviker = SQLOLOLEDB; DATA Source = 190.190.200.100, 1433; network library = dbmssocn; initial catalog = pubs; user ID = sa; password = asdasd; "????? name network protocol library ????? DBNMPNTW WIN32 named Pipes ???? DBMSSOCN WIN32 WINSOCK TCP / IP ????? DBMSSPXN WIN32 SPX / IPX ????? dbmsvinn Win32 Banyan Vines ????? DBMSRPCN WIN32 MULTI-Protocol (Windows RPC) ????? § Important Tip ?? ??? Use the following syntax when connecting through the SQLOLEDB provider: ????? NetWork library = dbmsoCN ????? But use the following syntax when connecting through the MSDASQL provider: ????? NetWork = dbmsSSOCN? ???? o All SQLCONNECTION connection string properties ????? § The following table shows all the connection string properties of the ADO.NET SQLConnection object. Most of the properties are also used in ADO. All properties and descriptions come from MSDN. ????? Name Default Value Description ????? Application Name application name or when the application is not provided, the .NET SQLCLIENT data provider ????? attachdbfilename or main file name of the Initial File Name Name, 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 server connection before generating an error ????? connection lifetime 0 When a connection returns to the connection pool, current time and connection Creating a difference in time, if the time period exceeds the specified connection time, this connection 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 determined whether 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 Name ???????????????????????????????????????????????????????????????????????????????????????????. When the connection pool automatically lists the connections in the current transaction context of the thread. ????? INTIAL CATALOG or DATABASE Database Name ????? Integrated Security or Trusted_Connection 'false' is connected to the trust connection.

Its value is 'True', 'false' and 'sspi' (equal to 'TRUE'). ?????? Max Pool Size 100 Connect the maximum connection allowed in the pool ????? min pool size 0 connection pool The minimum connection number allowed ????? NetWork Library or NET '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 partial server (for example, ","), you will use the shared memory ????? packet size 8192 network package word with an instance of SQL Server Size ????? Password- or PWD SQL Server account login password ????? Persist security info 'false' set to 'false', sensitivity security information when the connection has been turned on or in an open state ( If a password is not returned to a part of the connection as a connection. ????? Pooling 'true' For true, remove the SQLConnection object from the appropriate connection pool, or create a SqlConnection object if necessary and increase it into the appropriate connection pool. ????? User ID SQL Server Login User ????? Workstation ID The Local Computer Name Connected to SQL Server Workstation Name ????? § Note: ????? Use a semicolon to separate each attribute? ???? If a name is more than twice, the value in the last occurrence of the connection string will be used. ????? If you build a connection string by the value entered by the user in the app, you must ensure that the user will change the connection string by inserting another attribute through another value in the user value.

????? access ????? · ODBC ????? o standard connection (STANDARD Security): ????? "driver = {Microsoft Access Driver (* .mdb)}; DBQ = C: / MyDatabase.mdb; uid = admin; pwd =; "" ????? O group (system database): ????? Two methods are: in the connection string or in the open data set, specify the username and Password ????? "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 exclusive: ?? ??? "" driver = {Microsoft Access Driver (* .mdb)}; dbq = c: /mydatabase.mdb; exclusive = 1; uid = admin; pwd = "????? · OLE DB, OLEDBCONNECTION (.NET ) ????? o 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.ol EDB.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;" ????? "DRIVER = {Microsoft Odbc Driver for Oracle}; connectString = ORACLESERVER.WORLD; UID = myusername; pwd = mypassword; "

????? · OLE DB, OLEDBCONNECTION (.NET) ????? o Standard security): ????? "proviker = msdaora; data source = myoracledb; user id = username; password = asdasd "????? This is the format of Microsoft, below is Oracle's format (provider) ?????" provike = oraoledb.oracle; data source = myoracledb; user ID = username; password = asdasd; " ????? Note: "Data Source =" must be set to NET8 name according to the corresponding naming method.

For example, for local naming, it is the alias in tnsnames.ora, for oracle named, is a net8 network service name ????? o Trusted connection: ????? "provider = oraoledb.oracle; data Source = myoracledb; osauthent = 1; "????? or set the user ID" / "?????" provider = oraoledb.oracle; data source = myoracledb; user ID = /; password =; "?? ?? ??? · OracleConnection (.NET) ?????? o standard connection: ????? "data source = oracle8i; integrated security = yes"; ????? This is only for Oracle 8i Release 3 or higher Version effective ????? o OracleConnection declaration: ????? c #: ????? using system.data.OracleConnection OracleConn = new oracleConnection (); ????? OracleConn. Connectionstring = "my connectionstring"; ????? oracleconn.open (); ????? ????? 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 source = msdara; 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 use localhost as 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 The meaning of the value of the value ????? 1 The client cannot handle the case where the MyODBC returns a column of true width ????? 2 The client cannot handle the true value of the row of mysql returns Set this flag, MySQL returns 'Found Rows'. MySQL 3.21.14 or update version can take effect ????? 4 generate a debug log in C: /Myodbc.log.

This is the setting mysql_debug = d: t: o, C :: / myodbc.log in `o, C :: / myodbc.log ????? 8 Do not set any package limit for the results and parameters ????? 16 Drive pops up the problem ????? 32 use or remove dynamic cursor support. This is not allowed in myodbc 2.50 ????? 64 ignoring the use of the database name in 'Database.table.Column' ????? 128 forced using the ODBC manager cursor ????? 256 removes the expansion Value (FETCH) ????? 512 full of char fields full length ????? 1024 SQLDESCRIBECOL () function returns a column name that completely meets the condition ????? 2048 Using compressed server / client protocol ?? ??? 4096 Tell the server after the function and '(' Powerbuilder needs) before the function (PowerBuilder needs). This will generate all function name keywords ????? 8192 use the named pipe connection to run the mysqld server on NT ???? 16384 Change the longlong column to an INTL column (some applications can't handle the longlong column) ????? 32768 Return 'user' from SQLTables as Table_Qualifier and Table_owner ????? 66536 from the client reading parameters, 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 is the name of the MySQL database, you can also use server = localhost; db = test ????? · mysqlconnection (.NET) ????? o einfodesigns.dbProvider: ????? "Data Source = server; database = mydb; user ID = username; password = pwd; command logging = false "????? only for EinfoDesigns DBProvider, attached to .NET ????? o mysqlConnection: ???? ? 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 calculation Machine: ????? "driver = {easysoft IB6 {EasySoft IB6 ODBC}; server = computername; Database = computername: c: /mydatabase.gdb; uid = username; pwd = password" ????? · ODBC, INTERSOLV ?? ??? o Local computer: ????? "driver = {INTERSOLV Interbase ODBC Driver (* .GDB)}; server = localhost; database = localhost: c: /mydatabase.gdb; uid = username; pwd = password ????? o Remote computer: ????? "driver = {INTERSOLV Interbase odbc driver (* .gdb)}; server = computername; database = computename: c: /mydatabase.gdb; uid = username; PWD = PASSWORD "

????? This drive is now available by DataDirect Technologies (provided by INTERSOLV) ????? · OLE DB, SIBPROVIDER ????? o standard connection: ????? "provider = sibprovider; location = Localhost:; Data Source = C: /Databases/gdbs/mygdb.gdb; user ID = sysdba; password = masterkey "????? o Specified 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: /database/gdbs/mygdb.gdb; user ID = sysdba; password = masterkey; role = digitadores "????? · Need to link to Interbase 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 = DB2OLEDB; 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: ?????" proviker = db2oledb; appc local Lu alias = myalias; appc remote lu alias = myre Mote; Initial catalog = myctlg; package collection = mypkgcol; default schema = schema; user ID = myuse; password = mypw "????? as400 ????? · odbc ?????" driver = {Client Access ODBC Driver (32-bit)}; system = myaS400; uid = myusername; pwd = mypassword "????? · OLE DB, OLEDBCONNECTION (.NET) ?????" provike = 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 INTERSOLV 3.10: ????? "driver = {INTERSOLV 3.10 32-bit sybase}; SRVR = aron1; uid = username; pwd = password;" ????? o Sybase SQL Anywhere (former WATCOM SQL ODBC Driver): ?? ??? "odbc; driver = sybase sql anywhere 5.0; defaultdir = c: / dbfaulter /; dbf = c: /mydatabase.db; uid = username; pwd = password; dsn =" "" "????? Note: For dual quotes (VB syntax) referenced at the end, you must change the reference symbol syntax specified by the language you are using. DSN parameters are actually very important, if not included Result in a 7778 error.

????? · OLE DB ????? o Adaptive Server Anywhere (ASA): ????? "provider = asaprov; data source = myasa" ????? o Adaptive Server Enterprise (ASE) Data source is .IDS file): ????? "provider = Sybase ASE OLE DB Provider; Data Source = Myase" ????? Note You must use Data Manager to create a data source .ids file. These. The IDS file is similar to ODBC DSNS. ????? Visual FoxPro (DBASE) ????? · ODBC ????? o dbase: ????? "driver = {Microsoft DBase Driver (* .dbf)} DRIVERID = 277; DBQ = C: // DatabasePath "????? Must specify the file name (such as" SELECT NAME, Address from Clients.dbf "when writing SQL statements. ????? o Visual FoxPro (Has a database container): ????? "driver = {Microsoft Visual FoxPro driver}; uid =; sourceType = DBC; SourceDb = C: //DatabasePath/MyDatabase.dbc; Exclusive = no" ????? o Visual FoxPro (no data library container): ????? "driver = {Microsoft Visual FoxPro Driver}; uid =; sourceType = DBF; SourceDb = C: //DatabasePath/MyDatabase.dbc; Exclusive = no" ?? ??? · OLE DB, OLEDBCONNECTION (.NET) ????? o Standard connection: ????? "proviker = vfpoledb; data source = c: //DatabasePath/MyDatabase.dbc;" ???? • EXCEL ????? · ODBC ????? o Standard connection (STANDARD Security): ????? "driver = {Microsoft Excel Driv Er (* .xls)}; driverid = 790; dbq = c: //databasepath//dbspreadsheet.xls; defaultdir = c: // DatabasePath; "????? · OLE DB Provider for Microsoft Jet ???? • Standard security: ????? "proviker = microsoft.jet.oledb.4.0; data source = c: //databasepath//dbspreadsheet.xls; extended proties = /" / "Excel 8.0; HDR = YES; / ";;" ????? Note: If "HDR = YES", the provider does not include the first line of the selected, if, then the provider will include the unit range in the record set (Or have a name) first line ????? 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 uses Tab as a separator, you must create a schema.ini file, you must use the format = tabdelimited option in the connection string. ????? Note: You must specify the file name in the SQL statement (such as "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 Properties = /" / "text;" HDR = YES; FMT = DELIMITED; / "/"; "????? Note You must specify the file name (such as" SELECT NAME, Address from Clients.txt "). ????? odbc DSN ?????" DSN = MYDSN UID = myusername; pwd = mypassword; "????? ole db provider for odbc data ????? Connect 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 = MyDatabaseName; Uid = MyUsername; Pwd = MyPassword; "????? connect using 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 = myolapdatabaseename; "????? passed HTTP: ????? This feature allows The client application specifies a URL in the Data Source parameter of the client application connection string and connects to an analytical server using IIS. This connection method allows the PivotTable service to connect to the analysis server via a firewall or proxy server. A special ASP page MSOLAP.ASP is connected via IIS. When connected to the server, this file must be in this directory and as part of the URL (eg http://www.myserver.com/myolap/).

转载请注明原文地址:https://www.9cbs.com/read-123929.html

New Post(0)