.NET in various database connectivity
SQL Server ODBC
Standard Security: "driver = {SQL Server}; server = aron1; database = pubs; uid = sa; pwd = asdasd;"
Trusted Connection: "driver = {SQL Server}; server = aron1; database = public = yes;"
Prompt for username and password: Oconn.properties ("prompt") = adpromptalwaysoconn.open "driver = {SQL Server}; server = aron1; database = public;"
OLEDB, 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" Oconn.properties ("prompt") = 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;"
Trusted Connection: "Data Source = Aron1; Initial Catalog = pubs; Integrated Security = SSPI;" (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 = 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 DEFAULT) DECLARE The SqlConnection: C #: use system.data.sqlclient; sqlconnection osqlconn = new sqlconnection (); osqlconn.connectionstring = "my connectionstring"; osqlconn.open ();
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;"
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 CONNECTINGH MSDASQL Provider Use The Syntax Network = DBMSSOCN
All 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, including the full path name , of an attachable database. The database name must be specified with the keyword 'database'. Connect Timeout-or-Connection Timeout 15 The length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error. 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 'TRUE' DETERMINES WHENER TRUE 'DETERMINES WHENER 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-or-Network address The name or network address of the instance of SQL Server to which to connect. Enlist 'true' When true, the pooler automatically enlists the connection in the creation thread's current transaction context. 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 Size in bytes of the network packets used to communicate with an instance of SQL Server. 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 ..................... ..