Database connection string

xiaoxiao2021-03-06  42

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 ("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 "PROVIDE R = 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 = mydatabaseename; user ID = myusername; password = mypassword; "O connection When you pop up, enter your username and password dialog box: conn.provider ="

sqloledb "Conn.Properties (" Prompt ") = adPromptAlways Conn.Open" Data Source = Aron1; Initial Catalog = pubs; "o connected by IP address:" 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 number required to use (default 1433)) · SqlConnection (.NET) o Standard security: "data source = aron1; initial catalog = public; user ID = sa; password = asdasd;" or "server = aron1; database = public; user ID = sa; password = asdasd; trusted_connection = "Data Source = aron1; initial catalog = sag;" or "server = aron1; database = pubs; trusted_connection = public = aron1; database = public_connection = purus; trusted_connection = true "(The result of these two connection strings) (can be used with serverName / InstanceName instead of Data Source, with a specific SQL Server instance, but only for SQLServer2000) O via the IP address:" Data Source = 190.190.200.100 , 1433; Network library = dbmsoccoCn; 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)) o SqlConnection connection: C #: use 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): Two methods are: in the connection string or specify the username and password "Driver = {Microsoft Access Driver (* .mdb)}; dbq = c: /mydatabase.mdb; systemdb = C: / MyDatabase . MDW; ",", ",",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, "," "" "" "" "" "" ") {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 connection (SAMEPATH):" 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 data = system. MDW; "", "admin", "" ORP: "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}; connectionString = ORACLESERVER.WORLD; uid = myusername; pwd = mypassword; "

· OLE DB, OLEDBCONNECTION (.NET) O Standard Security): "Provider = MSDara; Data Source = Myoracledb; user ID = Username; Password = asdasd;" This is Microsoft's format, below is Oracle format (provided Different) "provider = oraoledb.racle; 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 Trusted connection: "provider = oraoledb.oracle; data source = myoracledb; osfehent = 1;" or Set the User ID to "/" "" "" "" "" "Data Source = Oracle8i; Integrated Security = YES"; "Data Source = ORACLE8I; Integrated Security = YES"; only for Oracle 8i release 3 or later 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 = msdara; data source = orac; user ID = username; password = mypw "· mysql · odbc o Local Database: "driver = {mysql}; server = mysrvname; option = 16834; Database = mydatabase;" Sever parameter can also use localhost as its value O remote database: "driver = {mysql}; server = data.domain. COM; port = 3306; option = 131072; stmt =; data = my-database; uid = username; pwd = password; "Option value of value 1 Client Cannot handle myodbc Returns a column of true width 2 Client can't If this flag is set, mysql returns 'Found Rows' if this flag is set, and MySQL returns. 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 the `autoexec.bat 'in` Autoexec.bat'. . This is not allowed in MyodBC 2.50, which is not allowed in 'database.table.column', using 128 forced database name 128 forced using ODBC Manager Cursor 256 Removing Extension Value (Fetch) 512 full of char fields full length 1024 SQLDESCRIBECOL ) Function Returns the column name 2048 using compressed server / client protocol 4096 tells the server after the function and '(' ignore the space before ". This will generate all function names Keywords 8192 using named pipe connection Mysqld server 16384 on NT converts the LONGLONG column to an INTL column (some applications cannot 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 groups 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, or use server = localhost; db = test · MySqlConnection (.NET) o eInfoDesigns.dbProvider: "Data Source = server; Database = mydb; User ID = username; Password = pwd; Command Logging = false" applies only to eInfoDesigns dbProvider, appended to the statement of .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 computer: "Driver = {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 = computername: 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 specify the character set:" provider = sibprovider; location = localhost:; data source = c: /databases/gdbs/mygdb.gdb; user id = SYSDBA; password = masterkey; character set = ISO8859_1 "o Specify role: "provider = sibprovider; location = localhost:; data source = c: /databases/gdbs/mygdb.gdb; user ID = sysdba; password = masterkey; role = digitadores" • Need to get more please link to Interbase The following 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; i nitial 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 connector : "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; "o Sybase SQL Anywhere": odbc; driver = Sybase SQL Anywhere 5.0; defaultdir = c: / dbfolder /; 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 symbol specified in compliance with the language you use The .dsn parameter is actually very important, if not included, will cause a 7778 error.

· OLE DB O Adaptive Server Anywhere (ASA): "Provider = asaprov; data source = myasa" o Adaptive Server Enterprise (ASE): "Provider = Sybase ASE OLE DB Provider; data source = "Note You must use the Data Manager to create a data source. IDS file. These .ids files are similar to ODBC DSNS. Visual FoxPro (DBase) · ODBC O DBASE:" Driver = {Microsoft DBase Driver (* .dbf)} DRIVERID = 277; DBQ = C: // DatabasePath "Note You must specify the file name (such as" Select Name, Address from Clom Clients.dbf "). O Visual FoxPro (Database Passer):" Driver = { Microsoft Visual Foxpro Driver}; UID =; SourceType = DBC; SourceDB = C: //DatabasePath//MyDatabase.dbc; Exclusive = no "o Visual Foxpro (no database containers):" Driver = {Microsoft Visual Foxpro Driver}; UID =; SourceType = DBF; Sourcedb = C: //DatabasePath/MyDatabase.dbc; Exclusive = no "· OLE DB, OLEDBCONNECTION (.NET) O Standard connection:" provider = vfpoledb; data source = c: // DatabasePath / /MyDatabase.dbc; "" 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.OLDB.4.0; Data Source = C: //DatabasePath//dbspreadsheet.xls; Extended Properties = / "/" Excel 8.0; HDR = YES; / "/"; "If" HDR = YES ", then The provider does not include the first line of the selected selection in the record set, if, the provider will connect to the first line of the recordset including the unit range (or have named the range).

STANDARD Security): "Driver = {Microsoft Text Driver (* .txt; * .csv)}; dbq = c: // DatabasePath //; extensions = ASC, CSV, Tab, TXT;" If text file uses Tab as separate Valong, you must create a schema.ini file, you must use the format = tabdelimited option in the connection string. Note: You must specify a file name in the SQL statement (such as "SELECT NAME, ADDRESS.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 when writing SQL statements (eg "SELECT NAME , Address From Clients.txt ") ODBC DSN." DSN = MyDSN; Uid = MyUsername; Pwd = MyPassword; "OLE DB Provider for ODBC Databases connection Access:" Provider = MSDASQL; Driver = {Microsoft Access Driver (* .mdb) }; Dbq = c: //DatabasePath//MyDatabase.mdb; Uid = MyUsername; Pwd = MyPassword; "connected to SQL Server:" Provider = MSDASQL; Driver = {SQL Server}; Server = myServerName; Database = MyDatabaseName; Uid = MyUsername; Pwd = MyPassword; "using DSN connection:" Provider = MSDASQL; PersistSecurityInfo = False; Trusted_Connection = Yes; Data Source = MyDSN; catalog = MyDatabase; "OLE DB Provider for OLAP" Provider = MSOLAP; Data Source = MyOLAPServerName; Initial catalog = myolapdatabase; "" Connection via 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-55077.html

New Post(0)