.NET in various database connectivity

zhaozj2021-02-16  69

Source: http://www.connectionstrings.com/

· SQL Server

ODBC

Standard Security:

"Driver = {SQL Server}; server = aron1; data = pubs; uid = sa; pwd = asdasd;"

Trusted Connection:

"Driver = {SQL Server}; server = aron1; database = pubs; trusted_connection = yes;"

Prompt for username and password:

Oconn.properties ("prompt") = adpromptalwaysoconn.open "driver = {SQL Server}; server = aron1; database = public;"

OLE DB, OLEDBCONNECTION (.NET)

Standard Security:

"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;

(Use Servername / InstanceName As Data Source To Use An Specifik Sqlserver Instance, "ONLY SQLSERVER2000)

Prompt for username and password:

Oconn.Provider = "sqloledb" = adpromptalwaysoconn.open "data source = aron1; initial catalog = public;"

Connect Via An 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, AT THE End of The Data Source Is The Port To Use (1433 Is The Default))

SqlConnection (.NET)

Standard Security:

"Data Source = Aron1; Initial Catalog = pubs; User Id = sa; Password = asdasd;" - or - "Server = Aron1; Database = pubs; User ID = sa; Password = asdasd; Trusted_Connection = False" (booth connection strings Products the Same Result

Trusted Connection:

"Data Source = Aron1; Initial Catalog = pubs; Integrated Security = SSPI;" - or - "Server = Aron1; Database = pubs; Trusted_Connection = True;" (booth connection strings produces the same result) (use serverName / instanceName as Data Source to use an specifik sqlserver instance, only sqlserver2000)

Connect Via An IP Address:

"Data Source = 190.190.200.100, 1433; network library = dbmsoCN; Initial catalog = pubs; user ID = sa; password = asdasd;"

(DBMSSOCN = TCP / IP INSTEAD OF NAMED PIPES, AT THE End of The Data Source Is The Port To Use (1433 Is The Default))

Declare the SqlConnection:

C #: use system.data.sqlclient; sqlconnection osqlconn = new sqlconnection (); osqlconn.connectionstring = "my connectionstring"; osqlconn ();

VB.Net:imports system.data.sqlclientdim osqlconn as sqlconnection = new sqlconnection () osqlconn.connectionstring = "my connectionstring" osqlconn.open ()

Data Shape

MS Data Shape "Province = MSDataShape; Data Provider = Sqloledb; Data Source = aron1; initial catalog = pubs; user ID = sa; password = asdasd;"

Want to Learn Data Shaping? Check Out 4Guyffromrolla's Great Article About Data Shaping >>

Read more

How To Define Wich Network Protocol To Use

Example: "provider = SQLOLEDB; DATA SOURCE = 190.190.200.100, 1433; network library = dbmssocn; initial catalog = pubs; user ID = sa; password = asdasd;"

Name

NetWork 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 note! When connecting through the SQLOLEDB provider use the syntax Network Library = dbmssocnand when connecting through MSDASQL provider use the syntax Network = dbmssocnAll SqlConnection connectionstring properties

This Table Shows All Connectionstring Properties for the ado.net sqlConnection Object. Most of the Properties Area ALSO Used in ado. All Properties and descriptions is from msdn.

Name

DEFAULT

Description

Application Name

The name of the application, or '.NET SQLCLIENT DATA Provider' if no application name is provided.

AttachdbFileName-OR-Extended Properties-OR-Initial File Name

The name of the primary file, inclished the full path name. The database name must be specified with the keyword 'data'.

Connect Timeout-OR-Connection Timeout

15

.................... ..

Connection Lifetime

0

When a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span (in seconds) exceeds the value specified by connection lifetime. Useful in clustered configurations to force load balancing between a Running Server and a Server Just Brought On-line.

Connection RESET

'True'

Determines whether the database connection is reset when being removed from the pool. Setting to 'false' avoids making an additional server round-trip when obtaining a connection, but the programmer must be aware that the connection state is not being reset.

Current Language

The SQL Server Language Record Name.

Data Source-or-Server-or-address-or-addr-not-network address

The name or network address of the instance of sql server to which to connect.enlist

'True'

.

Initial Catalog-OR-DATABASE

The name of the database.

Integrated Security-OR-TRUSTED_CONNECTION

'False'

WHETHER THE CONNECTION IS TO BE A Secure Connection or Not. Recognized Values ​​Are 'True', 'False', and 'SSPI', Which IS Equivalent To 'True'.

Max pool size

100

The Maximum Number of Connections Allowed in the pool.

MIN Pool Size

0

The Minimum Number of Connections Allowed in the pool.

NetWork Library-OR-NET

'DBMSSOCN'

The network library used to establish a connection to an instance of SQL Server. Supported values ​​include dbnmpntw (Named Pipes), dbmsrpcn (Multiprotocol), dbmsadsn (Apple Talk), dbmsgnet (VIA), dbmsipcn (Shared Memory) and dbmsspxn (IPX / SPX), and DBMSSOCN (TCP / IP). The Corresponding Network DLL Must Be Installed on The System To Which You Connect. If You Do Not Specify A Network and You Use A Local Server (for Example "." OR "(LOCAL ) "), Shared Memory is used.

Packet size

8192

.

Password-OR-PWD

The Password for the SQL Server Account Logging ON.

Persist security info

'False'

When set to 'false', security-sensitive information, such as the password, is not returned as part of the connection if the connection is open or has ever been in an open state. Resetting the connection string resets all connection string values ​​including the Password.

Pooling

'True'

When True, The SqlConnection Object Is Drawn from the appropriate pool, or if Necessary, is create and added to the appropriate pool.user ID

The SQL Server Login Account.

Workstation ID

The Local Computer Name

The name of the workstation connecting to SQL Server.

Note Use; to separate each property.If a name occurs more than once, the value from the last one in the connectionstring will be used.If you are building your connectionstring in your app using values ​​from user input fields, make sure the user can 'T Change The Connectionstring by Inserting An Additional Property with Another Value Withnin the user value.

· Access

ODBC

Standard Security:

"Driver = {Microsoft Access Driver (* .mdb)}; dbq = c: /mydatabase.mdb; uid = admin; pwd =;"

Workgroup:

"Driver = {Microsoft Access Driver (* .mdb)}; dbq = c: /mydatabase.mdb; systemdb = c: /mydatabase.mdw;"

Exclusive:

"Driver = {Microsoft Access Driver (* .mdb)}; dbq = c: /mydatabase.mdb; Exclusive = 1; UID = admin; pwd ="

OLE DB, OLEDBCONNECTION (.NET)

Standard Security:

"Provider = microsoft.jet.Oledb.4.0; data source = / somepath / mydb.mdb; user ID = admin; password =;"

Workgroup (System Database):

"Provider = microsoft.jet.Oledb.4.0; data source = / somepath / mydb.mdb; Jet OLEDB: System Database = system.mdw;"

WITH Password:

"Provider = microsoft.jet.Oledb.4.0; data source = / somepath / mydb.mdb; jet oledb: Database password = mydbpassword;"

· Oracle

ODBC

New Version:

"Driver = {microsoft odbc for oracle}; server = oracleserver.world; uid = username; pwd = asdasd;"

Old Version:

"Driver = {microsoft odbc driver for oracle}; connectString = oracleserver.world; uid = myusername; pwd = mypassword;" OLE DB, OLEDBCONNECTION (.NET)

Standard Security:

"Provider = msdaora; data source = myoracledb; user id = username; password = asdasd;"

This One's from Microsoft, The Following Are from Oracle, THE FLLOWING ARE

Standard Security:

"Provider = oraoledb.oracle; data source = myoracledb; user ID = username; password = asdasd;"

Trusted Connection:

"Provider = oraoledb.racle; data source = myoracledb; osauthent = 1;"

OracleConnection (.NET)

STANDARD:

"Data Source = Oracle8i; Integrated Security = YES;"

This One Works Only with Oracle 8i Release 3 or Later

Specifying Username and Password:

"Data Source = Oracle8i; user ID = username; password = passwd; integrated security = no;"

This One Works Only with Oracle 8i Release 3 or Later

Declare the OracleConnection:

C #: use system.data.racleClient; OracleConnection OracleConn = New OracleConnection (); oracleconn.connectionstring = "my connectionstring"; oracleconn.open ();

VB.NET: IIMPORTS System.Data.OracleClientDim Oracleconn As OracleConnection = New OracleConnection () Oracleconn.Connectionstring = "My Connectionstring" oracleconn.open ()

Core Labs ORADIRECT (.NET)

Standard: "User ID = Scott; PASSWORD = Tiger; Host = ORA; POOLING = true; min pool size = 0; Max pool size = 100; connection lifetime = 0"

Read more at core lab and the product page.

Data Shape

MS Data Shape: "Provider = MSDataShape.1; Persist Security Info = False; Data Provider = MSDara; Data Source = ORAC; User ID = UserName; Password = MYPW"

Want to Learn Data Shaping? Check Out 4Guyffromrolla's Great Article About Data Shaping >> · MySQL

ODBC

Local Database:

"Driver = {mysql}; server = mysrvname; option = 16834; Database = mydatabase;"

Remote Database:

"Driver = {mysql}; server = data.domain.com; port = 3306; option = 131072; stmt =; dataBase = my-data; uid = username; pwd = password;"

OLE DB, OLEDBCONNECTION (.NET)

STANDARD:

"Provider = mysqlprov; data source = mydb; user id = username; password = asdasd;"

MySQLConnection (.NET)

EINFODESIGNS.DBPROVIDER:

"Data Source = Server; Database = MYDB; User ID = Username; Password = PWD; Command logging = false"

This One is used with einfodesigns dbprovider, an add-on to .net

Declare the mysqlconnection:

C #: use einfodesigns.dbprovider.mysqlclient; mysqlconnection omysqlconn = new mysqlconnection (); omysqlconn.connectionstring = "my connectionstring"; omysqlconn.open ();

VB.Net:imports einfodesigns.dbprovider.mysqlclientdim omysqlconn as mysqlconnection = new mysqlconnection () omysqlconn.connectionstring = "my connectionString" omysqlconn.open ()

SevenObjects mysqlclient (.NET)

STANDARD:

"Host = server; username = myusername; password = mypassword; database = mydb;"

This is a freeware ado.net data provider from SevenObjects

Core labs mysqldirect (.NET)

STANDARD:

"User ID = root; password = pwd; host = localhost; port = 3306; dataBase = test; Direct = true; protocol = tcp; compress = false; pooling = true; min pool size = 0; max pool size = 100; Connection Lifetime = 0 "

Read more at core lab and the product page.

· Interbase

ODBC, EasySoft

Local Computer: "driver = {easysoft IB6 odbc}; server = localhost; database = localhost: c: /mydatabase.gdb; uid = username; pwd = password

Remote Computer:

"Driver = {easysoft IB6 odbc}; server = computername; database = computername: c: /mydatabase.gdb; uid = username; pwd = password

Read more About this Driver: EasySoft ODBC-InterBase Driver >>

ODBC, INTERSOLV

Local Computer:

"Driver = {INTERSOLV Interbase ODBC Driver (* .GDB)}; server = localhost; database = localhost: c: /mydatabase.gdb; uid = username; pwd = password

Remote Computer:

"Driver = {INTERSOLV InterBase ODBC Driver (* .GDB)}; server = computername; Database = computename: c: /mydatabase.gdb; uid = username; pwd = password

This Driver Are Provided by DataDirect Technology >> (Formerly Intersolv)

OLE DB, SIBPROVIDER

STANDARD:

"provider = sibprovider; location = localhost:; data source = c: /Databases/gdbs/mygdb.gdb; user ID = sysdba; password = masterkey

Specifying Character SET:

"provider = sibprovider; location = localhost:; data source = c: /Databases/gdbs/mygdb.gdb; user ID = sysdba; password = masterkey; character set = iso8859_1

Specifying role:

"provider = sibprovider; location = localhost:; data source = c: /databases/gdbs/mygdb.gdb; user ID = sysdba; password = masterkey; role = digitadores

Read more About SibProvider >>

Read More About Connecting to Interbase In this Borland Developer Network Article http://community.borland.com/Article/0,1410,27152,00.html

· IBM DB2

OLE DB, OLEDBCONNECTION (.NET) from MS

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" 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"

ODBC

STANDARD:

"driver = {IBM DB2 ODBC Driver}; Database = mydbname; hostname = myservername; port = myportnum; protocol = tcpip; uid = myusername; pwd = mypwd"

· Sybase

ODBC

Standard Sybase System 12 (or 12.5) Enterprise Open Client:

"Driver = {Sybase ASE ODBC Driver}; SRVR = aron1; uid = username; pwd = password"

Standard Sybase System 11:

"Driver = {Sybase System 11}; SRVR = aron1; uid = username; pwd = password;"

Do you know a Userguide for Sybase System 11, 12, 12.5? E-mail the url to connectionstrings.com now !! >>

INTERSOLV 3.10:

"Driver = {INTERSOLV 3.10 32-bit Sybase}; SRVR = aron1; uid = username; pwd = password;"

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! The two double quota following the DSN parameter at the end are escaped quotas (VB syntax), you may have to change this to your language specific escape syntax. The empty DSN parameter is indeed critical as not including it will result in error 7778 .

Read more in the Sybase SQL Anywhere User Guide >>

OLE DB

Adaptive Server Anywhere (ASA):

"Provider = asaprov; data source = myasa" Read more in the asa user guide >>

Adaptive Server Enterprise (ASE) with data source .ids file:

"Provider = Sybase ASE OLE DB Provider; Data Source = Myase"

Note this.

Adaptive Server Enterprise (ASE):

"Provider = Sybase.ASEOLEDBProvider; Srvr = myASEserver, 5000; Catalog = myDBname; User Id = username; Password = password" - some reports on problem using the above one, try the following as an alternative - "Provider = Sybase.ASEOLEDBProvider; Server name = myaseser, 5000; initial catalog = mydbname; user id = username; password = password

This One Works Only from Open Client 12.5 WHERE The Server Port Number Feature Works, Ambig Llowing Fully Qualified Connection Strings To Be Used without Defining Ny .ids Data Source Files.

AseConnection (.NET)

STANDARD:

"Data Source = 'MyaseServer'; port = 5000; database = 'mydbname'; uid = 'username'; pwd = 'password';"

Declare the aseconnection:

C #: use sybase.data.Aseclient; agent ;; aseconnection (); Ocon.ConnectionString = "My connection string"; Ocon.Open ();

VB.NET: IIMPORTS System.Data.aseclientdim Ocon As Aseconnection = New AseConnection () Ocon.Connectionstring = "My Connection String" Ocon.Open ()

Informix

ODBC

Informix 3.30:

"DSN = ''; driver = {informix 3.30 32 bit}; host = hostname; service = myserver; service = service-name; protocol = ilSoctcp; database = mydb; uid = username; pwd = mypwd

Informix-CLI 2.5:

"Driver = {INFORMIX-CLI 2.5 (32 bit)}; server = myserver; database = mydb; uid = username; pwd = mypwd" OLE DB

IBM Informix Ole DB Provider:

"Provider = ifxoledbc.2; password = mypw; user ID = myuser; data source = dbname @ ServerName; persist security info = true"

INGRES

ODBC

DSN-Less

"Provider = MSDASQL.1; DRIVER = Ingres; SRVR = xxxxx; DB = xxxxx; Persist Security Info = False; uid = xxxx; pwd = xxxxx; SELECTLOOPS = N; Extended Properties =" "" SERVER = xxxxx; DATABASE = xxxxx Servertype = INGRES ""

· MIMER SQL

ODBC

Standard Security:

"Driver = {mimer}; database = mydb; uid = myuser; pwd = mypw;"

Prompt for username and password:

"Driver = {mimer}; Database = mydb;"

PostgreSQL

Core Labs PostgreSqldirect (.NET)

STANDARD:

"User ID = root; password = pwd; host = localhost; port = 5432; dataBase = testdb; pooling = true; min pool size = 0; max pool size = 100; connection lifetime = 0"

Read more at core lab and the product page.

· DSN

ODBC

DSN:

"DSN = MYDSN; UID = Username; PWD =;"

File DSN:

"FileDSN = c: /mydata.dsn; uid = username; pwd =;"

· Excel

ODBC

STANDARD:

"Driver = {Microsoft Excel Driver (* .xls)}; driverid = 790; dbq = c: /myexcel.xls; defaultdir = c: / mypath;"

OLE DB

STANDARD:

"Provider = microsoft.jet.Oledb.4.0; data source = c: /myexcel.xls; extended proties =" "Excel 8.0; HDR = YES; IMEX = 1" ""

"HDR = yes;" INDICES That The First Row Contains ColumnNames, Not Data

"IMEX = 1;" TELLS The Driver to Always Read "Intermixed" Data Columns As Text

Tip! SQL SYNTAX: "SELECT *" "- I. Worksheet name Followed by a" $ "and wrapped in" [""] "Brackets. · Text

ODBC

STANDARD:

"Driver = {Microsoft text driver (* .txt; * .csv)}; dbq = c: / txtFilesfolder /; extensions = ASC, CSV, Tab, TXT;

OLE DB

STANDARD:

"Provider = microsoft.jet.Oledb.4.0; data source = c: / txtfilesfolder /; extended proties =" "text; hdr = yes; fmt = delimited" ""

"HDR = yes;" INDICES That The First Row Contains ColumnNames, Not Data

· DBF / FoxPro

ODBC

STANDARD:

"Driver = {Microsoft DBase Driver (* .dbf)}; driverid = 277; dbq = c: / mydbpath;"

OLE DB, OLEDBCONNECTION (.NET)

STANDARD:

"Provider = microsoft.jet.Oledb.4.0; data source = c: / folder; extended Properties = dbase iv; user ID = admin; password ="

· Visual FoxPro

OLE DB, OLEDBCONNECTION (.NET)

Database container (.dbc):

"Provider = vfpoledb.1; data source = c: /mydbfolder/mydbcontainer.dbc; password = mypassword; collating sequence = machine"

Free Table Directory:

"Provider = vfpoledb.1; data source = c: / mydatadirectory /; password = mypassword; collating sequence = general"

Read more (Microsoft MSDN >>

ODBC

Database container (.dbc):

"Driver = {Microsoft Visual FoxPro Driver}; SourceType = DBC; SourceDb = C: /MyVFPDB.DBC; Exclusive = NO; Collate = Machine;"

Free Table Directory:

"Driver = {Microsoft Visual FoxPro Driver}; SourceType = DBF; SourceDb = C: / MyVfpdbFolder; Exclusive = NO; Collate = Machine;"

"Collate = Machine" is the default setting, for other settings check the list of supported collating sequences >>

Microsoft Visual FoxPro Site: http://msdn.microsoft.com/vfoxpro on Pervasive

ODBC

STANDARD:

"Driver = {Pervasive ODBC Client Interface}; servername = srvname; dbq = @ dbname"

Pervasive ODBC INFO >>

OLE DB

STANDARD:

"Provider = pervasiveoledb; data source = c: / path"

Pervasive OLE DB INFO >>

· UDL

UDL:

"File name = c: /mydataLink.ud;"

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

New Post(0)