SQL数据库连接字符串大全
c#连接sqlserver数据库字符串
c#连接sqlserver数据库字符串第⼀种⽅式Data Source=数据库地址;Initial Catalog=数据库名称;User Id=数据库登录名;Password=数据库密码;[Integrated Security=SSPI | true]; Integrated Security参数表⽰采⽤数据库的windows⾝份验证模式,当Integrated Security=true是,设置签名的user id和password参数不起作⽤。
Integrated Security=SSPI相当于Integrated Security=true,该参数可省略。
第⼆种⽅式Server=数据库地址;Database=数据库名称;User ID=数据库登录名;Password=数据库密码;[Trusted_Connection=False | true]; Trusted_Connection参数当值为true时表⽰采⽤数据库的windows⾝份验证模式,值为false或省略时表⽰需要⽤户名密码登录。
在App.config⽂件中插⼊connectionString节<connectionStrings><add name="conn" connectionString="server=LAPTOP-KDEAMB3L;database=MyContact;uid=sa;pwd=123456"/></connectionStrings>此处User ID可简写为uid,Pssword可简写为pwd。
在解决⽅案中新建⼀个控制台应⽤程序,在控制应⽤程序的App.config中加⼊上述连接字符代码,测试连接是否成功 1namespace test22 {3class Program4 {5private static string connstr = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;6static void Main(string[] args)7 {8try9 {10using (SqlConnection conn = new SqlConnection(connstr))11 {12 conn.Open();13if (conn.State.ToString().Contains("Open"))14 {15 Console.WriteLine("数据库连接成功!");16 }17else18 {19 Console.WriteLine("数据库连接失败!");20 }2122 }2324 }25catch (Exception ex)26 {27throw ex;28 }29 }30 }31 }运⾏程序,数据库连接成功。
SQL server 和MySQL的 connectionstring大全
【SQL SERVER】Standard SecurityData Source=myServerAddress;Initial Catalog=myDataBase;UserId=myUsername;Password=myPassword;Standard Security alternative syntaxThis connection string produces the same result as the previous one. The reason to include it is to point out that some connection string keywords have many equivalents.Server=myServerAddress;Database=myDataBase;UserID=myUsername;Password=myPassword;Trusted_Connection=False;Trusted ConnectionData Source=myServerAddress;Initial Catalog=myDataBase;IntegratedSecurity=SSPI;Trusted Connection alternative syntaxThis connection string produce the same result as the previous one. The reason to include it is to point out that some connection string keywords have many equivalents.Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;Use serverName\instanceName as Data Source to use a specific SQL Server instance. Please note that the multiple SQL Server instances feature is available only from SQL Server version 2000 and not in any previous versions.Connecting to an SQL Server instanceThe syntax of specifying the server instance in the value of the server key is the same for all connection strings for SQL Server.Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=T rue;Trusted Connection from a CE deviceOften a Windows CE device is not authenticated and logged in to a domain. To use SSPI or trusted connection / authentication from a CE device, use this connection string.Data Source=myServerAddress;Initial Catalog=myDataBase;IntegratedSecurity=SSPI;User ID=myDomain\myUsername;Password=myPassword;Note that this will only work on a CE device.Read more about connecting to SQL Server from CE devices hereConnect via an IP addressData Source=190.190.200.100,1433;Network Library=DBMSSOCN;InitialCatalog=myDataBase;User ID=myUsername;Password=myPassword;Specifying packet sizeServer=myServerAddress;Database=myDataBase;UserID=myUsername;Password=myPassword;Trusted_Connection=False;Packet Size=4096; By default, the Microsoft .NET Framework Data Provider for SQL Server sets the network packet size to 8192 bytes. This might however not be optimal, try to set this value to 4096 instead.The default value of 8192 might cause errors as well ("Failed to reserve contiguous memory"), check this outMicrosoft OLE DB Provider for SQL Serv erType: OLE DB ProviderUsage:Provider=sqloledbManufacturer: MicrosoftMore info about this provider »Customize stringexample values »Standard SecurityProvider=sqloledb;Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;Trusted connectionProvider=sqloledb;Data Source=myServerAddress;InitialCatalog=myDataBase;Integrated Security=SSPI;Use serverName\instanceName as Data Source to use a specific SQL Server instance. Please note that the multiple SQL Server instances feature is available only from SQL Server version 2000 and not in any previous versions.Connecting to an SQL Server instanceThe syntax of specifying the server instance in the value of the server key is the same for all connection strings for SQL Server.Provider=sqloledb;Data Source=myServerName\theInstanceName;InitialCatalog=myDataBase;Integrated Security=SSPI;Prompt for username and passwordThis one is a bit tricky. First set the connection object's Provider property to "sqloledb". Thereafter set the connection object's Prompt property to adPromptAlways. Then use the connection string to connect to the database.oConn.Provider = "sqloledb"oConn.Properties("Prompt") = adPromptAlwaysData Source=myServerAddress;Initial Catalog=myDataBase;Connect via an IP addressProvider=sqloledb;Data Source=190.190.200.100,1433;NetworkLibrary=DBMSSOCN;Initial Catalog=myDataBase;UserID=myUsername;Password=myPassword;DBMSSOCN=TCP/IP. This is how to use TCP/IP instead of Named Pipes. At the end of the Data Source is the port to use. 1433 is the default port for SQL Server.How to define which network protocol to useDisable connection poolingThis one is usefull when receving errors "sp_setapprole was not invoked correctly." (7.0) or "General network error. Check your network documentation" (2000) when connecting using an application role enabled connection. Application pooling (or OLE DB resource pooling) is on by default. Disabling it can help on this error.Provider=sqloledb;Data Source=myServerAddress;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;OLE DB Services=-2;.NET Framework Data Provider for OLE DBType: .NET Framework Wrapper Class LibraryUsage:System.Data.OleDb.OleDbConnectionManufacturer: MicrosoftMore info about this wrapper class library »Customize stringexample values »Bridging to OLE DB Provider for SQL ServerThis is just one connection string sample for the wrapping OleDbConnection class that calls the underlying OLEDB provider. See respective OLE DB provider for more connection strings to use with this class.Provider=SQLOLEDB;Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername; Password=myPassword;Microsoft SQL Server ODBC DriverType: ODBC DriverUsage:Driver={SQL Server}Manufacturer: MicrosoftCustomize stringexample values »Standard SecurityDriver={SQLServer};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPass word;Trusted connectionDriver={SQLServer};Server=myServerAddress;Database=myDataBase;Trusted_Connection=Yes;Prompt for username and passwordThis one is a bit tricky. First you need to set the connection object's Prompt property to adPromptAlways. Then use the connection string to connect to the database.oConn.Properties("Prompt") = adPromptAlwaysDriver={SQL Server};Server=myServerAddress;Database=myDataBase;SQL Server Native Client 10.0 OLE DB ProviderType: OLE DB ProviderUsage:Provider=SQLNCLI10Manufacturer: MicrosoftMore info about this provider »Customize stringexample values »Standard securityNote that the SQL Server Native Client OLE DB Provider does not support SQL Server 7.0. Provider=SQLNCLI10;Server=myServerAddress;Database=myDataBase;Uid=myUsername; Pwd=myPassword;Trusted connectionProvider=SQLNCLI10;Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;Equivalent key-value pair: "Integrated Security=SSPI" equals "Trusted_Connection=yes"Connecting to an SQL Server instanceThe syntax of specifying the server instance in the value of the server key is the same for all connection strings for SQL Server.Provider=SQLNCLI10;Server=myServerName\theInstanceName;Database=myDataBase; Trusted_Connection=yes;Prompt for username and passwordThis one is a bit tricky. First you need to set the connection object's Prompt property to adPromptAlways. Then use the connection string to connect to the database.oConn.Properties("Prompt") = adPromptAlwaysoConn.Open "Provider=SQLNCLI10;Server=myServerAddress;DataBase=myDataBase;Encrypt data sent over networkProvider=SQLNCLI10;Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;Encrypt=yes;SQL Native Client 9.0 OLE DB providerType: OLE DB ProviderUsage:Provider=SQLNCLIManufacturer: MicrosoftMore info about this provider »Customize stringexample values »Standard securityNote that the SQL Server Native Client OLE DB Provider does not support SQL Server 7.0. Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase;Uid=myUsername; Pwd=myPassword;Trusted connectionProvider=SQLNCLI;Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;Equivalent key-value pair: "Integrated Security=SSPI" equals "Trusted_Connection=yes"Connecting to an SQL Server instanceThe syntax of specifying the server instance in the value of the server key is the same for all connection strings for SQL Server.Provider=SQLNCLI;Server=myServerName\theInstanceName;Database=myDataBase; Trusted_Connection=yes;Prompt for username and passwordThis one is a bit tricky. First you need to set the connection object's Prompt property to adPromptAlways. Then use the connection string to connect to the database.oConn.Properties("Prompt") = adPromptAlwaysoConn.Open "Provider=SQLNCLI;Server=myServerAddress;DataBase=myDataBase;Encrypt data sent over networkProvider=SQLNCLI;Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;Encrypt=yes;SQL Server Native Client 10.0 ODBC DriverType: ODBC DriverUsage:Driver={SQL Server Native Client 10.0}Manufacturer: MicrosoftMore info about this driver »Customize stringexample values »Standard securityDriver={SQL Server Native Client10.0};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPasswo rd;Trusted ConnectionDriver={SQL Server Native Client10.0};Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes; Equivalent key-value pair: "Integrated Security=SSPI" equals "Trusted_Connection=yes"Connecting to an SQL Server instanceThe syntax of specifying the server instance in the value of the server key is the same for all connection strings for SQL Server.Driver={SQL Server Native Client 10.0};Server=myServerName\theInstanceName; Database=myDataBase;Trusted_Connection=yes;Prompt for username and passwordThis one is a bit tricky. First you need to set the connection object's Prompt property to adPromptAlways. Then use the connection string to connect to the database.oConn.Properties("Prompt") = adPromptAlwaysDriver={SQL Server Native Client10.0};Server=myServerAddress;Database=myDataBase;Encrypt data sent over networkDriver={SQL Server Native Client10.0};Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;Encrypt=yes;SQL Native Client 9.0 ODBC DriverType: ODBC DriverUsage:Driver={SQL Native Client}Manufacturer: MicrosoftMore info about this driver »Customize stringexample values »Standard securityDriver={SQL Native Client};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Trusted ConnectionDriver={SQL Native Client};Server=myServerAddress;Database=myDataBase; Trusted_Connection=yes;Equivalent key-value pair: "Integrated Security=SSPI" equals "Trusted_Connection=yes"Connecting to an SQL Server instanceThe syntax of specifying the server instance in the value of the server key is the same for all connection strings for SQL Server.Driver={SQL NativeClient};Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=yes;Prompt for username and passwordThis one is a bit tricky. First you need to set the connection object's Prompt property to adPromptAlways. Then use the connection string to connect to the database.oConn.Properties("Prompt") = adPromptAlwaysDriver={SQL Native Client};Server=myServerAddress;Database=myDataBase;Customize stringexample values »MSDataShapeProvider=MSDataShape;Data Provider=SQLOLEDB;DataSource=myServerAddress;Initial Catalog=myDataBase;UserID=myUsername;Password=myPassword;【MYSQL】StandardServer=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword; Default port is 3306.Specifying portServer=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername;Pwd=myPa ssword;Download the driver at MySQL Developer ZoneNamed pipesServer=myServerAddress;Port=-1;Database=myDataBase;Uid=myUsername;Pwd=myPass word;It is the port value of -1 that tells the driver to use named pipes network protocol. This is available on Windows only. The value is ignored if Unix socket is used.Multiple serversUse this to connect to a server in a replicated server configuration without concern on which server to use.Server=serverAddress1 & serverAddress2 &etc..;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Using encryptionThis one activates SSL encryption for all data sent between the client and server. The server needs to have a certificate installed.Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Enc ryption=true;This option is available from Connector/NET version 5.0.3. In earlier versions, this option has no effect.Using encryption, alternativeSome reported problems with the above one. Try replacing the key "Encryption" with "Encrypt" instead.Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Enc rypt=true;Specifying default command timeoutUse this one to specify a default command timeout for the connection. Please note that the property in the connection string does not supercede the individual command timeout property on an individual command object.Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;def ault command timeout=20;This option is available from Connector/NET version 5.1.4.Specifying connection attempt timeoutUse this one to specify the length in seconds to wait for a server connection before terminating the attempt and receive an error.Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Con nection Timeout=5;Inactivating prepared statementsUse this one to instruct the provider to ignore any command prepare statements and prevent corruption issues with server side prepared statements.Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Ign ore Prepare=true;The option was added in Connector/NET version 5.0.3 and Connector/NET version 1.0.9.Specifying portUse this one to specify what port to use for the connection.Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Por t=3306;The port 3306 is the default MySql port.The value is ignored if Unix socket is used.Specifying network protocolUse this one to specify which network protocol to use for the connection.Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword; Protocol=socket;"socket" is the default value used if the key isn't specified. Value "tcp" is an equivalent for "socket".Manufacturer: MySQLMore info about this driver »Customize stringexample values »Local databaseDriver={MySQL ODBC 3.51 Driver};Server=localhost;Database=myDataBase;User=myUsername;Password=myPassword;Option=3;Remote databaseDriver={MySQL ODBC 3.51Driver};Server=myServerAddress;Database=myDataBase;User=myUsername;Password=myPassword;Option=3;Specifying TCP/IP portDriver={MySQL ODBC 3.51Driver};Server=myServerAddress;Port=3306;Database=myDataBase;User=myUsername; Password=myPassword;Option=3;The driver defaults to port value 3306, if not specified in the connection string, as 3306 is the default port for MySQL.Specifying character setDriver={MySQL ODBC 3.51Driver};Server=myServerAddress;charset=UTF8;Database=myDataBase;User=myUsern ame; Password=myPassword;Option=3;Note that the charset option works from version 3.51.17 of the driver.Specifying socketThis one specifies the Unix socket file or Windows named pipe to connect to. Used only for local client connections.Driver={MySQL ODBC 3.51Driver};Server=myServerAddress;Database=myDataBase;User=myUsername;Password=myPassword;Socket=MySQL;Option=3;On Windows, the socket variable is the name of the named pipe that is used for local client connections. The default value is MySQL.On Unix platforms, the socket variable is the name of the socket file that is used for local client connections. The default is /tmp/mysql.sock.Using SSLDriver={MySQL ODBC 3.51Driver};Server=myServerAddress;Database=myDataBase;User=myUsername;Password=myPassword;sslca=c:\cacert.pem;sslcert=c:\client-cert.pem;sslkey=c: \client-key.pem;sslverify=1;Option=3;SSLCA specifies the path to a file with a list of trust SSL CAsSSLCERT specifies the name of the SSL certificate file to use for establishing a secure connection.SSLKEY specifies the name of the SSL key file to use for establishing a secure connection. MySQL Connector/ODBC 5.1Type: ODBC DriverUsage:Driver={MySQL ODBC 5.1 Driver}Manufacturer: MySQLMore info about this driver »Customize stringexample values »Local databaseDriver={MySQL ODBC 5.1 Driver};Server=localhost;Database=myDataBase;User=myUsername;Password=myPassword;Option=3;Remote databaseDriver={MySQL ODBC 5.1Driver};Server=myServerAddress;Database=myDataBase;User=myUsername;Password=myPassword;Option=3;Specifying TCP/IP portDriver={MySQL ODBC 5.1Driver};Server=myServerAddress;Port=3306;Database=myDataBase;User=myUsername; Password=myPassword;Option=3;The driver defaults to port value 3306, if not specified in the connection string, as 3306 is the default port for MySQL.Specifying character setDriver={MySQL ODBC 5.1Driver};Server=myServerAddress;charset=UTF8;Database=myDataBase;User=myUsern ame; Password=myPassword;Option=3;Specifying socketThis one specifies the Unix socket file or Windows named pipe to connect to. Used only for local client connections.Driver={MySQL ODBC 5.1Driver};Server=myServerAddress;Database=myDataBase;User=myUsername;Password=myPassword;Socket=MySQL;Option=3;On Windows, the socket variable is the name of the named pipe that is used for local client connections. The default value is MySQL.On Unix platforms, the socket variable is the name of the socket file that is used for local client connections. The default is /tmp/mysql.sock.Using SSLDriver={MySQL ODBC 5.1Driver};Server=myServerAddress;Database=myDataBase;User=myUsername;Password=myPassword;sslca=c:\cacert.pem;sslcert=c:\client-cert.pem;sslkey=c: \client-key.pem;sslverify=1;Option=3;SSLCA specifies the path to a file with a list of trust SSL CAsSSLCERT specifies the name of the SSL certificate file to use for establishing a secure connection.SSLKEY specifies the name of the SSL key file to use for establishing a secure connection..NET Framework Data Provider for ODBCType: .NET Framework Wrapper Class LibraryUsage:System.Data.Odbc.OdbcConnectionManufacturer: MicrosoftMore info about this wrapper class library »Customize stringexample values »Bridging to MySQL Connector/ODBC 5.1This is just one connection string sample for the wrapping OdbcConnection class that calls the underlying ODBC Driver. See respective ODBC driver for more connection strings to use with this class.Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=myDataBase;User=myUsername;Password=myPassword;Option=3;。
数据库连接字符串大全
数据库连接字符串大全数据库连接字符串大全--- Access2003服务器篇ODBC标准安全策略Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb;Uid=Admin;Pwd=;工作组Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb;SystemDB=C:\myd atabase.mdw;独占模式Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb;Exclusive=1;Uid=a dmin;Pwd=;管理员模式如果您需要在程序中使用CREATE USER, CREATE GROUP, ADD USER, GRANT, REVOK E 和DEFAULTS等命令,您就需要使用此连接字符串。
Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb;Uid=Admin;Pwd=; ExtendedAnsiSQL=1;OLE DB, OleDbConnection (.NET)标准安全策略Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;User Id=admin;Pas sword=;使用数据库密码如果您的Access数据库设置了密码,您就需要参照如下连接字符串将密码写入后才能够正常使用。
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDB:Databa se Password=MyDbPassword;工作组(系统数据库)Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDB:System Database=system.mdw;工作组(系统数据库)并且制定用户名和密码Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDB:System Database=system.mdw;User ID=myUsername;Password=myPassword;数据库连接字符串大全之Access2007服务器篇ACE OLEDB 12.0标准安全策略Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Persist Security Info=False;使用了密码的数据库如果您的Access 2007数据库设置了密码,您需要特别的在连接字符串中指定它。
sql查询结果集拼接字符串
sql查询结果集拼接字符串1.引言1.1 概述在数据库应用中,经常会遇到需要将查询结果集拼接为一个字符串的场景,这种需求在实际开发中非常常见。
SQL查询结果集拼接字符串的目的是将一个查询结果集中的多行数据合并为一个字符串,以便于在应用程序中进行后续处理或展示。
SQL查询结果集拼接字符串的应用场景非常广泛。
比如,在某些场景下,我们需要将某个表中某个字段的所有取值连接在一起作为一个新的字段进行展示;或者在数据导出功能中,我们需要将查询结果集的某些字段按照一定的格式进行合并,并将结果导出为一个文件。
总的来说,无论是在数据展示、数据导出还是其他业务逻辑中,SQL查询结果集拼接字符串都具有重要的作用。
在本文中,我们将介绍SQL查询结果集拼接字符串的方法和技巧。
首先,我们将学习SQL查询结果集的基本概念,了解结果集是如何组织和表示的。
接着,我们将深入探讨SQL查询结果集拼接字符串的需求和应用场景,分析其实际应用中的意义和价值。
最后,我们将总结各种方法和技巧,给出对SQL查询结果集拼接字符串的优缺点进行分析,帮助读者更好地理解和应用这一技术。
通过本文的学习,读者将掌握SQL查询结果集拼接字符串的核心思想和实现方法,能够在实际开发中灵活应用这一技术解决问题。
无论是在独立开发项目中,还是在团队合作中,这些知识和技巧都将为读者提供宝贵的帮助和指导。
让我们一起开始学习吧!1.2 文章结构文章结构:本文主要分为引言、正文和结论三个部分。
引言部分包括了概述、文章结构和目的三个小节。
在概述中,将介绍SQL查询结果集拼接字符串的问题和应用场景。
在文章结构小节中,将简要介绍本文的内容组织结构。
在目的小节中,将说明本文旨在探讨和总结SQL查询结果集拼接字符串的方法和技巧,以及对其优缺点进行分析。
正文部分将分为多个小节。
其中,2.1节将详细介绍SQL查询结果集的基本概念,包括结果集的定义、结构和使用。
2.2节将重点讨论SQL查询结果集拼接字符串的需求和应用场景,例如在业务逻辑中需要将查询出的多条记录拼接成一个字符串进行展示或存储。
sqlserver2008数据库连接字符串大全
sqlserver2008数据库连接字符串⼤全⼀、.NET Framework Data Provider for SQL Server类型:.NET Framework类库使⽤:System.Data.SqlClient.SqlConnection⼚商:Microsoft1.标准安全连接复制代码代码如下:Data Source = myServerAddress;Initial Catalog = myDataBase;User Id = myUsername;Password = myPassword;使⽤服务器名\实例名作为连接指定SQL Server实例的数据源。
如果你使⽤的是SQL Server 2008 Express版,实例名为SQLEXPRESS。
2.可替代的标准安全连接复制代码代码如下:Server = myServerAddress;Database = myDataBase;User ID = myUsername;Password = myPassword;Trusted_Connection = False;这条连接字符串跟上⼀条效果⼀样。
把这条写出来只是想说,其实很多连接字符串的关键字有多种写法。
3.信任连接复制代码代码如下:Data Source = myServerAddress;Initial Catalog = myDataBase;Integrated Security = SSPI;可替代的信任连接复制代码代码如下:Server = myServerAddress;Database = myDataBase;Trusted_Connection = True;4.连接Windows CE设备的信任连接通常⼀台Windows CE设备在⼀个域⾥是不能被认证和登录的。
为了让⼀台CE设备使⽤SSPI或信任连接和认证,可以使⽤下⾯的连接字符串:复制代码代码如下:Data Source = myServerAddress;Initial Catalog = myDataBase;Integrated Security = SSPI;User ID = myDomain\myUsername;Password = myPassword;说明⼀下,这条语句只能在CE设备上⽤。
sql中拼接字符串的方法
sql中拼接字符串的方法在使用SQL语言进行数据处理和操作时,很常见的一个需求就是将字符串拼接起来,以便于进行一些查询、筛选或展示的任务。
对于如何拼接字符串,SQL提供了多种方法。
一、使用加号“+”号拼接字符串可能比较常见的方法就是使用加号“+”号来拼接字符串。
使用这种方法时,需要注意的是所有的操作数均需要使用字符串类型才能完成拼接。
比如:```SELECT 'Hello ' + 'world'```这个查询语句的结果就是“Hello world”。
二、使用CONCAT函数拼接字符串在SQL中还提供了一个CONCAT函数,可以用来拼接多个字符串。
该函数支持将任意个数的字符串作为参数,最终将它们拼接成一个大字符串。
比如:```SELECT CONCAT('Hello ', 'world')```这个查询语句的结果也是“Hello world”。
三、使用||拼接字符串对于某些数据库来说,可能会支持使用“||”符号来进行字符串的拼接。
比如:```SELECT 'Hello ' || 'world'```这个查询语句的结果也是“Hello world”。
四、使用GROUP_CONCAT函数拼接字符串在某些情况下,我们可能需要将某列的多个值拼接成一个字符串。
这个时候可以使用GROUP_CONCAT函数。
这个函数会将目标列的所有值都拼接成一个大字符串,中间可以使用自定义分隔符进行分割。
比如:```SELECT GROUP_CONCAT(name SEPARATOR ', ') FROM students```这个查询语句的结果就是该表中所有学生的姓名,中间以逗号和空格分隔。
综上所述,SQL提供了多种方式来进行字符串拼接。
在使用时需要根据实际情况选择合适的方法。
无论是使用“+”号拼接、还是使用CONCAT函数、||符号或者GROUP_CONCAT函数,都能够帮助我们轻松实现字符串拼接的需求,提高数据处理和展示的效率。
sql 连接数据库语句
sql 连接数据库语句在使用SQL连接数据库时,可以使用以下语句进行连接:1. 使用MySQL连接数据库:```mysql -h 主机名 -P 端口号 -u 用户名 -p```这里的主机名是指要连接的数据库服务器的主机名,端口号是指数据库服务器的端口号,用户名是指要连接的数据库的用户名,密码是指要连接的数据库的密码。
2. 使用PostgreSQL连接数据库:```psql -h 主机名 -p 端口号 -U 用户名 -W```这里的主机名是指要连接的数据库服务器的主机名,端口号是指数据库服务器的端口号,用户名是指要连接的数据库的用户名,-W 选项表示需要输入密码进行连接。
3. 使用Oracle连接数据库:```sqlplus 用户名/密码@主机名:端口号/服务名```这里的用户名是指要连接的数据库的用户名,密码是指要连接的数据库的密码,主机名是指要连接的数据库服务器的主机名,端口号是指数据库服务器的端口号,服务名是指要连接的数据库的服务名。
4. 使用SQL Server连接数据库:```sqlcmd -S 服务器名 -U 用户名 -P 密码 -d 数据库名```这里的服务器名是指要连接的数据库服务器的服务器名,用户名是指要连接的数据库的用户名,密码是指要连接的数据库的密码,数据库名是指要连接的数据库的数据库名。
5. 使用SQLite连接数据库:```sqlite3 数据库文件名```这里的数据库文件名是指要连接的SQLite数据库文件的文件名。
6. 使用MariaDB连接数据库:```mysql -h 主机名 -P 端口号 -u 用户名 -p```这里的主机名是指要连接的数据库服务器的主机名,端口号是指数据库服务器的端口号,用户名是指要连接的数据库的用户名,密码是指要连接的数据库的密码。
7. 使用DB2连接数据库:```db2 connect to 数据库名 user 用户名 using 密码```这里的数据库名是指要连接的数据库的数据库名,用户名是指要连接的数据库的用户名,密码是指要连接的数据库的密码。
sql server 2008数据库连接字符串大全
一、.NET Framework Data Provider for SQL Server类型:.NET Framework类库使用:System.Data.SqlClient.SqlConnection厂商:Microsoft1.标准安全连接复制代码代码如下:Data Source = myServerAddress;Initial Catalog = myDataBase;User Id = myUsername;Password = myPassword;使用服务器名\实例名作为连接指定SQL Server实例的数据源。
如果你使用的是SQL Server 2008 Express版,实例名为SQLEXPRESS。
2.可替代的标准安全连接复制代码代码如下:Server = myServerAddress;Database = myDataBase;User ID = myUsername;Password = myPassword;Trusted_Connection = False;这条连接字符串跟上一条效果一样。
把这条写出来只是想说,其实很多连接字符串的关键字有多种写法。
3.信任连接复制代码代码如下:Data Source = myServerAddress;Initial Catalog = myDataBase;Integrated Security = SSPI;可替代的信任连接复制代码代码如下:Server = myServerAddress;Database = myDataBase;Trusted_Connection = True;4.连接Windows CE设备的信任连接通常一台Windows CE设备在一个域里是不能被认证和登录的。
为了让一台CE设备使用SSPI或信任连接和认证,可以使用下面的连接字符串:复制代码代码如下:Data Source = myServerAddress;Initial Catalog = myDataBase;Integrated Security = SSPI;User ID = myDomain\myUsername;Password = myPassword;说明一下,这条语句只能在CE设备上用。
sql2005连接字符串
使用附加本地数据库文件的方式连接到本地SQL Server Express实例
Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;
为何要使用Database参数如果同名的数据库已经被附加,那么SQL Server将不会重新附加。
"Integrated Security=SSPI" 与 "Trusted_Connection=yes" 是相同的。
连接到一个SQL Server实例
指定服务器实例的表达式和其他SQL Server的连接字符串相同。
Driver={SQL Native Client};Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=yes;
SQL Native Client OLE DB Provider
标准连接
Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
您是否在使用SQL Server 2005 Express 请在“Server”选项使用连接表达式“主机名称\SQLEXPRESS”。
为何要使用Database参数如果同名的数据库已经被附加,那么SQL Server将不会重新附加。
使用附加本地数据文件夹中的数据库文件的方式连接到本地SQL Server Express实例
Provider=SQLNCLI;Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;
sql数据库连接字符串在APP.config配置文件内的三种写法
sql数据库连接字符串在APP.config配置⽂件内的三种写法第⼀种⽅法写法:<configuration><appSettings><add key="connectionstring" value="server=127.0.0.1;uid=sa;pwd=123456;database=Power"/> </appSettings></configuration>调⽤:string rode= ConfigurationManager.AppSettings["connectionstring"];第⼆种⽅法写法:<connectionStrings><add name="CONNECTIONS" connectionString="Server=10.10.10.1;Database=MyDBTest;Uid=sa;Pwd=sa" /></connectionStrings>调⽤:string connectionstr =ConfigurationManager.ConnectionStrings["CONNECTIONS"].ConnectionString;还有⼀个情况,如果你使⽤的是entity fromwork的codefirst模式,连接字符串还可以这样写<add name="MovieDBContext" providerName="System.Data.SqlClient" connectionString="Server=KTY;Database=shuyunquan;Uid=sa;Pwd=123456"/>只不过是⽐第⼆种情况多了⼀个providerName⽽已,⽽且这个不需要调⽤~~,这种情况详见我的推荐的写法上⾯两种写法,很明显,我的账号密码都明⽂写出来了,有⼏个问题1.查看配置⽂件的⼈很容易就知道了账号密码,不安全2.如果我修改了密码,那么配置⽂件⾥⾯也要跟着修改,很⿇烦所以采⽤下⾯这个推荐的写法<connectionStrings><add name="DefaultDBString" connectionString="Data source=localhost,1877;Initial Catalog=VaeDB;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/> </connectionStrings>可以看到,我采⽤了localhost,端⼝是1877,然后我连接VaeDB使⽤的⽅式是SSPI,也就是本地连接,这种⽅式⾮常好,避免了以上两个问题。
连接SQL数据库的方法
连接SQL数据库的方法:(一)、在Web.Config中创建连接字符串:1、不需手动输入,只需采用vs2010的服务器资源管理器进行数据库的连接,选中连接查看属性中的“连接字符串”,复制里面的内容即可。
此方法不需要通过SSME附加数据库。
<add name="ConnectionString" connectionString="DataSource=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\grade.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />2、混合模式<add name="sampleConnectionString" connectionString="server=.\SQLEXPRESS;database=sample;uid=sa;pwd=123456;" providerName="System.Data.SqlClient"/>3、window身份<add name ="testConnectionString" connectionString ="Data Source=.\SQLEXPRESS;InitialCatalog=sample;Integrated Security=True;Persist Security Info=True;User ID=sa;Password=123456" providerName ="System.Data.SqlClient"/>(二)、在aspx.cs中获取连接字符串:1、string strCon =System.Configuration.ConfigurationManager.ConnectionStrings["sampleConnectionString"].ConnectionString;2、string strCon =System.Configuration.ConfigurationManager.ConnectionStrings["sampleConnectionString"].ToString();3、string strCon =System.Configuration.ConfigurationManager.ConnectionStrings["testConnectionString"].ToString();(三)、将连接字符串直接写到页面里1、string strCon = "DataSource=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\grade.mdf;Integrated Security=True;User Instance=True";2、string strCon = "Data Source=.\\SQLEXPRESS;Initial Catalog=sample;Integrated Security=True;Persist Security Info=True;User ID=sa;Password=123456";3、string strCon = "server=.\\SQLEXPRESS;database=sample;uid=sa;pwd=123456";。
SQL数据库连接字符串的几种写法整理
SQL数据库连接字符串的⼏种写法整理⼀、远程连接1.sql server ⾝份验证连接字符串:private string ConnstrSqlServer = "server=服务器名称;uid=登录名称;pwd=登录密码;database=数据库名称";2.windows ⾝份验证连接字符串:private string ConnstrWindows = "server=服务器名称;database=数据库名称;Trusted_Connection=SSPI";⼆、本地连接. 在 C# 代码中⽤SqlClient的⽅式访问 SQL Server 2008-2014 数据库 Framework Data Provider for SQL Server 标准写法 Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;2. .NET Framework Data Provider for SQL Server 另⼀种标准写法 Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False; Framework Data Provider for SQL Server 信任连接写法 Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI; Framework Data Provider for SQL Server 信任连接另⼀种写法 Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;。
SQL Server连接字符串
连接字符串中常用的声明有:服务器声明Data Source、Server和Addr等。
数据库声明Initial Catalog和DataBase等。
集成Windows账号的安全性声明Integrated Security和Trusted_Connection等。
使用数据库账号的安全性声明User ID和Password等。
对于访问数据库的账号来说,通常我们在一些参考资料上看到的字符串连接往往有如下写法:复制代码代码如下:string ConnStr = "server = localhost;user id = sa; password = xxx; database = northwind";对于集成Windows安全性的账号来说,其连接字符串写法一般如下:复制代码代码如下:string ConnStr = "server = localhost;integrated security = sspi; database = northwind";或string ConnStr = "server = localhost;trusted_connection = yes; database = northwind";使用Windows集成的安全性验证在访问数据库时具有很多优势:安全性更高、访问速度更快、减少重新设计安全架构的工作、可以硬编码连接字符串等,还是很值得使用的。
SQL Native Client ODBC Driver标准安全连接复制代码代码如下:Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;您是否在使用SQL Server 2005 Express?请在“Server”选项使用连接表达式“主机名称\SQLEXPRESS”。
数据库连接符大全
数据库连接符大全关键词:ADO 数据库连接符在数据库的各种应用程序开发中,连接数据库是数据库应用程序开发的第一步,同时也是最重要的一步。
而对于不同的数据库他们的连接模式各有不同,对应的连接串也不同。
程序员可能都有这样的经历,有时不知道连接数据库所需要的连接串究竟如何写或者经常写错而导致不能正确访问数据库。
当然很多编程工具能够通过可视化的界面直接产生正确的连接字符串,但字符串中各个参数的具体含义也不清楚,经常混淆。
本文就针对大部分常用数据库列举出不同连接方法所需要的连接字符串并加以说明,以便程序员参考!Sql Server· ODBCo 标准连接(Standard Security):"Driver={SQL Server};Server=Aron1;Database=pubs;Uid=sa;Pwd=asdasd;"1)当服务器为本地时Server可以使用(local);"Driver={SQL Server};Server=(local);Database=pubs;Uid=sa;Pwd=asdasd;"2)当连接远程服务器时,需指定地址、端口号和网络库"Driver={SQLServer};Server=130.120.110.001;Address=130.120.110.001,1052;Network=dbmssocn;Database=pubs;Uid=sa;P wd=asdasd;"注:Address参数必须为IP地址,而且必须包括端口号o 信任连接(Trusted connection): (Microsoft Windows NT 集成了安全性)"Driver={SQL Server};Server=Aron1;Database=pubs;Trusted_Connection=yes;"或者"Driver={SQL Server};Server=Aron1;Database=pubs; Uid=;Pwd=;"o 连接时弹出输入用户名和口令对话框:Conn.Properties("Prompt") = adPromptAlwaysConn.Open "Driver={SQL Server};Server=Aron1;DataBase=pubs;"· OLE DB, OleDbConnection (.NET)o 标准连接(Standard Security):"Provider=sqloledb;Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd;"o 信任连接(Trusted connection):"Provider=sqloledb;Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;"(如果连接一个具体的已命名SQLServer实例,使用Data Source=Servere Name\Instance Name;但仅适用于SQLServer2000)例如:”Provider=sqloledb;Data Source=MyServerName\MyInstanceName;InitialCatalog=MyDatabaseName;User Id=MyUsername;Password=MyPassword;”o 连接时弹出输入用户名和口令对话框:Conn.Provider = "sqloledb"Conn.Properties("Prompt") = adPromptAlwaysConn.Open "Data Source=Aron1;Initial Catalog=pubs;"o 通过IP地址连接:"Provider=sqloledb;Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;InitialCatalog=pubs;User ID=sa;Password=asdasd;"(DBMSSOCN=TCP/IP代替Named Pipes, Data Source的末尾是需要使用的端口号(缺省为1433))· SqlConnection (.NET)o 标准连接(Standard Security):"Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd;"或者"Server=Aron1;Database=pubs;User ID=sa;Password=asdasd;Trusted_Connection=False"(这两个连接串的结果相同)o 信任连接(Trusted connection):"Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;"或者"Server=Aron1;Database=pubs;Trusted_Connection=True;"(这两个连接串的结果相同)(可以用serverName\instanceName代替Data Source,取值为一个具体的SQLServer实例,但仅适用于SQLServer2000)o 通过IP地址连接:"Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=pubs;UserID=sa;Password=asdasd;"(DBMSSOCN=TCP/IP代替Named Pipes, Data Source的末尾是需要使用的端口号(缺省为1433)) o SqlConnection连接的声明:C#:using System.Data.SqlClient;SqlConnection SQLConn = new SqlConnection();SQLConn.ConnectionString="my connectionstring";SQLConn.Open();:Imports System.Data.SqlClientDim SQLConn As SqlConnection = New SqlConnection()SQLConn.ConnectionString="my connectionstring"SQLConn.Open()· Data Shapeo MS Data Shape"Provider=MSDataShape;Data Provider=SQLOLEDB;Data Source=Aron1;Initial Catalog=pubs;User ID=sa;Password=asdasd;"·更多o 如何定义使用哪个协议§举例:"Provider=sqloledb;Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd;"名称网络协议库dbnmpntw Win32 Named Pipesdbmssocn Win32 Winsock TCP/IPdbmsspxn Win32 SPX/IPXdbmsvinn Win32 Banyan Vinesdbmsrpcn Win32 Multi-Protocol (Windows RPC)§重要提示当通过SQLOLEDB提供者进行连接时使用以下语法:Network Library=dbmssocn但通过MSDASQL提供者进行连接时使用以下语法:Network=dbmssocno 所有SqlConnection连接串属性§下表显示了 SqlConnection对象的所有连接串属性. 其中大多数的属性也在ADO中使用.所有属性和描述来自于msdn.名称缺省值描述Application Name 应用程序名称或者当没有提供应用程序时为.Net SqlClient数据提供者AttachDBFilename或者extended properties或者Initial File Name 主要文件的名字,包括相关联数据库的全路径。
select语句中用来连接字符串的符号
select语句中用来连接字符串的符号
"连接即是力量:在组合Constituents时,SELECT是最强大的利器"
在SQL中,使用SELECT语句来连接字符串,下面介绍一些常用的连接符:
1. Plus Sign ( + ):使用加号来连接多个字符串时,不同的字符串之间会添加空格。
2. Vertical Bar or Pipe ( | ):在LINUX中,管道符号(|)是一种更简洁的方法来实现字符串连接,可以将字符串追加到一行。
3. Double Ampersand ( && ):双符号(&&)也是用于连接字符串的一种标准语法,它向字符串添加空格。
4. Single Quotation Mark ( ' ):单引号提供了一种标准的语法来使用SQL中的变量,它引用变量。
5. Comma ( , ):使用逗号对字符串进行分隔,确保所有的字符串被连接
到单个字符串,以便在SELECT语句中使用结果。
6. Full Stop or Period ( . ):使用一个句点来连接来自不同的表的所有的字符串,有时也用于将字符串连接至变量中。
以上就是SQL SELECT语句中用来连接字符串的常用符号。
pgsql数据库连接串写法
pgsql数据库连接串写法在使用PostgreSQL数据库时,可以使用以下几种方式来编写数据库连接串:1. 基本格式:host=<hostname> port=<port> dbname=<database>user=<username> password=<password>。
其中,`<hostname>`是数据库服务器的主机名或IP地址,`<port>`是数据库服务器监听的端口号(默认为5432),`<database>`是要连接的数据库名称,`<username>`和`<password>`是登录数据库所需的用户名和密码。
2. 使用连接字符串:postgresql://<username>:<password>@<hostname>:<port>/<datab ase>。
这是一种常见的连接字符串格式,其中`<username>`、`<password>`、`<hostname>`、`<port>`和`<database>`分别代表用户名、密码、主机名(或IP地址)、端口号和数据库名称。
3. 使用环境变量:export PGHOST=<hostname>。
export PGPORT=<port>。
export PGDATABASE=<database>。
export PGUSER=<username>。
export PGPASSWORD=<password>。
这种方式通过设置环境变量来指定连接参数,然后使用默认的连接串来连接数据库。
4. 高级选项:host=<hostname> port=<port> dbname=<database>user=<username> password=<password> sslmode=<mode>。
C# 连接SQL数据库 常用连接字符串
一:C# 连接SQL数据库Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;Server=myServerAddress;Database=myDataBase;UserID=myUsername;Password=myPassword;Trusted_Connection=False;Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=True;Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;1:Integrated Security参数当设置Integrated Security为True 的时候,连接语句前面的UserID, PW 是不起作用的,即采用windows身份验证模式。
只有设置为False 或省略该项的时候,才按照UserID, PW 来连接。
Integrated Security 还可以设置为:sspi ,相当于True,建议用这个代替True。
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=true;Data Source=myServerAddress;Initial Catalog=myDataBase;;User ID=myUsername;Password=myPasswordIntegrated Security=false;2:参数Trusted_ConnectionTrusted_Connection=true,将使用当前的Windows 帐户凭据进行身份验证Trusted_Connection=false;将不采用信任连接方式(也即不采用Windows验证方式),而改由SQL Server 2000验证方式Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=false;Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;3:Initial Catalog是你要连接的数据库的名字4:WINCE连接Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;User ID=myDomain\myUsername;Password=myPassword;二:可以利用SqlConnectionStringBuilder,这样不必去记住名称。
SQL拼接字符串(字符串中有变量)转载的
SQL拼接字符串(字符串中有变量)转载的/sikaiyuan2008/article/details/7848926 SQL SERVER拼接字符串(字符串中有变量)总是忘记规律,转载过来以帮助记忆。
⼀、拼接字符串(整个字符串不分割)步骤:⾸先在字符串的前后加单引号;字符串中的变量以在字符串中表⽰;若在执⾏时存在类型转换错误,则应⽤相应的类型转换函数,对变量进⾏类型转换(如cast()函数)。
⽰例均采⽤northwind数据库。
⽰例⼀:包含SQL拼接字符串的存储过程:Create Procedure Test@TestID intAsDeclare @s nvarchar(800)Set @s='Select * From dbo.Categories where CategoryID='''+cast(@TestID as varchar)+''''print @sexec(@s)执⾏:exec Test @TestID=1执⾏结果:⼆、拼接字符串(字符串分割)步骤:将不包含变量的字符串前后⽤单引号括起来,不含变量的字符串与变量⽤+进⾏拼接变量⽤进⾏表⽰(@para为变量名);若执⾏存储过程时出现类型转换错误,则采⽤相应的类型转换函数进⾏转换。
⽰例采⽤northwind数据库。
⽰例⼆:包含SQL 字符串的存储过程:Create Procedure Test@TestID intAsDeclare @s nvarchar(800)Set @s='Select * From dbo.Categories where CategoryID='+''''+cast(@TestID as varchar)+''''print @sexec(@s)执⾏:exec Test @TestID=1执⾏结果:。
SQL中字符串拼接
SQL中字符串拼接•1. 概述•2. 数字 + 字符串•3. 数字 + 数字•4.字符串 + 字符串•5. 使用CAST和CONVERT函数进行类型转换1. 概述在SQL语句中经常需要进行字符串拼接,以sqlserver,oracle,mysql三种数据库为例,因为这三种数据库具有代表性。
sqlserver:select '123'+'456';oracle:select '123'||'456' from dual;或select concat('123','456') from dual;mysql:select concat('123','456');注意:SQL Server中没有concat函数(SQL Server 2012已新增concat函数)。
oracle和mysql中虽然都有concat,但是oracle 中只能拼接2个字符串,所以建议用||的方式;mysql中的concat则可以拼接多个字符串。
在SQL Server中的“+”号除了能够进行字符串拼接外,还可以进行数字运算,在进行字符串拼接时要小心使用。
下面以“Users”表为例,进行详细分析:2. 数字 + 字符串2.1 int + varcharSELECT id + place FROM Users WHERE id = 1; //提示错误“在将 varchar 值 'bzz' 转换成数据类型 int 时失败”SELECT id + place FROM Users WHERE id = 5; //提示错误“在将 varchar 值 '102.34' 转换成数据类型 int 时失败”SELECT id + place FROM Users WHERE id = 4;//返回int “105”2.2 decimal + varcharSELECT *, id + cost FROM Users WHERE id = 4 OR id = 5;//返回decimal “102.98”和“104.30”SELECT *, place + cost FROM Users WHERE id = 1;//提示错误“从数据类型 varchar 转换为 numeric 时出错。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
SQL ServerODBCStandard Security:"Driver={SQL Server};Server=Aron1;Database=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=pubs;"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"oConn.Properties("Prompt") = adPromptAlwaysoConn.Open "Data Source=Aron1;Initial Catalog=pubs;"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"(both connection strings produces the same result)Trusted Connection:"Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;"- or -"Server=Aron1;Database=pubs;Trusted_Connection=True;"(both 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=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))Declare the SqlConnection:C#:using System.Data.SqlClient;SqlConnection oSQLConn = new SqlConnection();oSQLConn.ConnectionString="my connection string";oSQLConn.Open();:Imports System.Data.SqlClientDim oSQLConn As SqlConnection = New SqlConnection()oSQLConn.ConnectionString="my connection string"oSQLConn.Open()Data ShapeMS Data Shape"Provider=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 moreHow to define which network protocol to useExample:"Provider=sqloledb;Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd;"Name Network librarydbnmpntw Win32 Named Pipesdbmssocn Win32 Winsock TCP/IPdbmsspxn Win32 SPX/IPXdbmsvinn Win32 Banyan Vinesdbmsrpcn Win32 Multi-Protocol (Windows RPC)Important note!When connecting through the SQLOLEDB provider use the syntax Network Library=dbmssocn and when connecting through MSDASQL provider use the syntax Network=dbmssocnAll SqlConnection connection string propertiesThis table shows all connection string properties for the SqlConnection object. Most of the properties are also used in ADO. All properties and descriptions is from msdn.Name Default Descriptionapplication 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 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-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, is created 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.NoteUse ; to separate each property.If a name occurs more than once, the value from the last one in the connection string will be used. If you are building your connection string in your app using values from user input fields, make sure the user can't change the connection string by inserting an additional property with another value within the user value.SQL Server 2005SQL Native Client ODBC DriverStandard security:"Driver={SQL Native Client};Server=Aron1;Database=pubs;UID=sa;PWD=asdasd;"Trusted connection:"Driver={SQL Native Client};Server=Aron1;Database=pubs;Trusted_Connection=yes;" EquivalentsIntegrated Security=SSPI equals Trusted_Connection=yesPrompt for username and password:oConn.Properties("Prompt") = adPromptAlwaysoConn.Open "Driver={SQL Native Client};Server=Aron1;DataBase=pubs;"Enabling MARS (multiple active result sets):"Driver={SQL Native Client};Server=Aron1;Database=pubs;Trusted_Connection=yes;MARS_Connection=yes" EquivalentsMultipleActiveResultSets=true equals MARS_Connection=yesUsing MARS with SQL Native Client, by Chris Lee >>Encrypt data sent over network:"Driver={SQL Native Client};Server=Aron1;Database=pubs;Trusted_Connection=yes;Encrypt=yes"Attach a database file on connect to a local SQL Server Express instance:"Driver={SQL Native Client};Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname;Tr usted_Connection=Yes;"- or -"Driver={SQL Native Client};Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;Database=dbnam e;Trusted_Connection=Yes;"(use |DataDirectory| when your database file resides in the data directory)Why is the "Database" parameter needed? Answer: If the database was previously attached, SQL Server does not reattach it (it uses the attached database as the default for the connection). Download the SQL Native Client here >> (the package contains booth the ODBC driver and the OLE DB provider)Using SQL Server 2005 Express? Don't miss the server name syntax: SERVERNAME\SQLEXPRESS (Substitute "SERVERNAME" with the name of the computer) SQL Native Client OLE DB ProviderStandard security:"Provider=SQLNCLI;Server=Aron1;Database=pubs;UID=sa;PWD=asdasd;"Trusted connection:"Provider=SQLNCLI;Server=Aron1;Database=pubs;Trusted_Connection=yes;"EquivalentsIntegrated Security=SSPI equals Trusted_Connection=yesPrompt for username and password:oConn.Properties("Prompt") = adPromptAlwaysoConn.Open "Provider=SQLNCLI;Server=Aron1;DataBase=pubs;"Enabling MARS (multiple active result sets):"Provider=SQLNCLI;Server=Aron1;Database=pubs;Trusted_Connection=yes;MarsConn=yes" EquivalentsMarsConn=yes equals MultipleActiveResultSets=true equals MARS_Connection=yesUsing MARS with SQL Native Client, by Chris Lee >>Encrypt data sent over network:"Provider=SQLNCLI;Server=Aron1;Database=pubs;Trusted_Connection=yes;Encrypt=yes"Attach a database file on connect to a local SQL Server Express instance:"Provider=SQLNCLI;Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Databa se=dbname;Trusted_Connection=Yes;"- or -"Provider=SQLNCLI;Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;Dat abase=dbname;Trusted_Connection=Yes;"(use |DataDirectory| when your database file resides in the data directory)Why is the "Database" parameter needed? Answer: If the database was previously attached, SQL Server does not reattach it (it uses the attached database as the default for the connection). Download the SQL Native Client here >> (the package contains booth the ODBC driver and the OLE DB provider)Using SQL Server 2005 Express? Don't miss the server name syntax: SERVERNAME\SQLEXPRESS (Substitute "SERVERNAME" with the name of the computer) 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"(both connection strings produces the same result)Trusted Connection:"Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;"- or -"Server=Aron1;Database=pubs;Trusted_Connection=True;"(both connection strings produces the same result)(use serverName\instanceName as Data Source to use an specifik SQLServer instance)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 the default))Enabling MARS (multiple active result sets):"Server=Aron1;Database=pubs;Trusted_Connection=True;MultipleActiveResultSets=true"Note! Use 2.0 for MARS functionality. MARS is not supported in 1.0 nor 1.1Streamline your Data Connections by Moving to MARS, by Laurence Moroney, >> Attach a database file on connect to a local SQL Server Express instance:"Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname;Database =dbname;Trusted_Connection=Yes;"- or -"Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;Database=dbname;Trust ed_Connection=Yes;"(use |DataDirectory| when your database file resides in the data directory)Why is the "Database" parameter needed? Answer: If the database was previously attached, SQL Server does not reattach it (it uses the attached database as the default for the connection).Using "User Instance" on a local SQL Server Express instance:"Data Source=.\SQLExpress;integrated security=true;attachdbfilename=|DataDirectory|\mydb.mdf;user instance=true;"The "User Instance" functionality creates a new SQL Server instance on the fly during connect. This works only on a local SQL Server 2005 instance and only when connecting using windows authentication over local named pipes. The purpose is to be able to create a full rights SQL Server instance to a user with limited administrative rights on the computer. To enable the functionality: sp_configure 'user instances enabled','1' (0 to disable)Using SQL Server 2005 Express? Don't miss the server name syntax: SERVERNAME\SQLEXPRESS (Substitute "SERVERNAME" with the name of the computer) Context Connection - connecting to "self" from within your CLR stored prodedure/functionC#:using(SqlConnection connection = new SqlConnection("context connection=true")){connection.Open();// Use the connection}Visual Basic:Using connection as new SqlConnection("context connection=true")connection.Open()' Use the connectionEnd UsingThe context connection lets you execute Transact-SQL statements in the same context (connection) that your code was invoked in the first place.Read moreWhen to use SQL Native Client?.Net applicationsDo not use the SQL Native Client. Use the .NET Framework Data Provider for SQL Server(SqlConnection).COM applications, all other then .Net applicationsUse the SQL Native Client if you are accessing an SQL Server 2005 and need the new features of SQL Server 2005 such as MARS, encryption, xml data type etc. Continue use your current provider (OLE DB / ODBC through the MDAC package) if you are not connecting to an SQL Server 2005 (that's quite obvious eh..) or if you are connecting to an SQL Server 2005 but are not using any of the new SQL Server 2005 features.For more details on the differences between MDAC and SQL Native Client, read this msdn article >>AccessODBCStandard 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;"OracleODBCNew 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 OracleStandard Security:"Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=Username;Password=asdasd;"Trusted Connection:"Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;OSAuthent=1;" OracleConnection (.NET)Standard:"Data Source=MyOracleDB;Integrated Security=yes;"This one works only with Oracle 8i release 3 or laterSpecifying username and password:"Data Source=MyOracleDB;User Id=username;Password=passwd;Integrated Security=no;"This one works only with Oracle 8i release 3 or laterDeclare the OracleConnection:C#:using System.Data.OracleClient;OracleConnection oOracleConn = new OracleConnection();oOracleConn.ConnectionString = "my connection string";oOracleConn.Open();:Imports System.Data.OracleClientDim oOracleConn As OracleConnection = New OracleConnection()oOracleConn.ConnectionString = "my connection string"oOracleConn.Open()Missing the System.Data.OracleClient namespace? Download .NET Managed Provider for Oracle >>Great article! "Features of Oracle Data Provider for .NET" by Rama Mohan G. at C# Corner 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 ShapeMS Data Shape:"Provider=MSDataShape.1;Persist Security Info=False;Data Provider=MSDAORA;Data Source=orac;user id=username;password=mypw"Want to learn data shaping? Check out 4GuyfFromRolla's great article about Data Shaping >> MySQLMyODBCMyODBC 2.50 Local database:"Driver={mySQL};Server=localhost;Option=16834;Database=mydatabase;"MyODBC 2.50 Remote database:"Driver={mySQL};Server=;Port=3306;Option=131072;Stmt=;Database=my-dat abase;Uid=username;Pwd=password;"MyODBC 3.51 Local database:"DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DA TABASE=myDatabase;USER=myUsername;PASSWORD=myPa ssword;OPTION=3;"MyODBC 3.51 Remote database:"DRIVER={MySQL ODBC 3.51 Driver};SERVER=;PORT=3306;DA TABASE=myDatabase;USER=myUsername;PASSWORD=myPassword;OPTION=3;"OLE DB, OleDbConnection (.NET)Standard:"Provider=MySQLProv;Data Source=mydb;User Id=UserName;Password=asdasd;"Connector/Net 1.0 (.NET)Standard:"Server=Server;Database=Test;Uid=UserName;Pwd=asdasd;"Download the driver at MySQL Developer Zone.Specifying port:"Server=Server;Port=1234;Database=Test;Uid=UserName;Pwd=asdasd;"Default port is 3306. Enter value -1 to use a named pipe connection.Declare the MySqlClient connection:C#:using MySql.Data.MySqlClient;MySqlConnection oMySqlConn = new MySqlConnection();oMySqlConn.ConnectionString = "Server=Server;Database=Test;Uid=UserName;Pwd=asdasd;"; oMySqlConn.Open();:Imports MySql.Data.MySqlClientDim oMySqlConn As MySqlConnection = New MySqlConnection()oMySqlConn.ConnectionString = "Server=Server;Database=Test;Uid=UserName;Pwd=asdasd;" oMySqlConn.Open()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 .NETDeclare the MySqlConnection:C#:using eInfoDesigns.dbProvider.MySqlClient;MySqlConnection oMySqlConn = new MySqlConnection();oMySqlConn.ConnectionString = "my connection string";oMySqlConn.Open();:Imports eInfoDesigns.dbProvider.MySqlClientDim oMySqlConn As MySqlConnection = New MySqlConnection()oMySqlConn.ConnectionString = "my connection string"oMySqlConn.Open()SevenObjects MySqlClient (.NET)Standard:"Host=server; UserName=myusername; Password=mypassword;Database=mydb;"This is a freeware data provider from SevenObjectsCore 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.InterbaseODBC, EasysoftLocal 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;P wd=password"Read more about this driver: Easysoft ODBC-Interbase driver >>ODBC, IntersolvLocal 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=ComputerName:C:\mydatabase.gdb;Uid=username;P wd=password"This driver are provided by DataDirect Technologies >> (formerly Intersolv)OLE DB, SIBPROviderStandard:"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 /article/0,1410,27152,00.htmlIBM DB2OLE DB, OleDbConnection (.NET) from msTCP/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"IBM's OLE DB Provider (shipped with IBM DB2 UDB v7 or above)TCP/IP:Provider=IBMDADB2;Database=sample;HOSTNAME=db2host;PROTOCOL=TCPIP;PORT=50 000;uid=myUserName;pwd=myPwd;ODBCStandard:"driver={IBM DB2 ODBC DRIVER};Database=myDbName;hostname=myServerName;port=myPortNum;protocol=TCPIP; uid=myUserName; pwd=myPwd"SybaseODBCStandard 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;Database=mydb" For more information check out the Adaptive Server Enterprise Document SetsIntersolv 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:\dbfolder\;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 (see part 3, chapter 13) >>OLE DBAdaptive Server Anywhere (ASA):"Provider=ASAProv;Data source=myASA"Read more in the ASA User Guide (part 1, chapter 2) >>Adaptive Server Enterprise (ASE) with Data Source .IDS file:"Provider=Sybase ASE OLE DB Provider; Data source=myASE"Note that you must create a Data Source .IDS file using the Sybase Data Administrator. These .IDS files resemble ODBC DSNs.Adaptive Server Enterprise (ASE):"Provider=Sybase.ASEOLEDBProvider;Srvr=myASEserver,5000;Catalog=myDBname;UserId=username;Password=password"- some reports on problem using the above one, try the following as an alternative -"Provider=Sybase.ASEOLEDBProvider;Server Name=myASEserver,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,?allowing fully qualified connection strings to be used without defining?any .IDS Data Source files. AseConnection (.NET)Standard:"DataSource='myASEserver';Port=5000;Database='myDBname';UID='username';PWD='password';"Declare the AseConnection:C#:using Sybase.Data.AseClient;AseConnection oCon = new AseConnection();oCon.ConnectionString="my connection string";oCon.Open();:Imports System.Data.AseClientDim oCon As AseConnection = New AseConnection()oCon.ConnectionString="my connection string"oCon.Open()Read more! Adaptive Server Enterprise Data Provider Documentation >>InformixODBCInformix 3.30:"Dsn='';Driver={INFORMIX 3.30 32 BIT};Host=hostname;Server=myserver;Service=service-name;Protocol=olsoctcp;Database=mydb ;UID=username;PWD=myPwdInformix-CLI 2.5:"Driver={Informix-CLI 2.5 (32 Bit)};Server=myserver;Database=mydb;Uid=username;Pwd=myPwd"OLE DBIBM Informix OLE DB Provider:"Provider=Ifxoledbc.2;password=myPw;User ID=myUser;Data Source=dbName@serverName;Persist Security Info=true"IngresODBCDSN-less"Provider=MSDASQL.1;DRIVER=Ingres;SRVR=xxxxx;DB=xxxxx;Persist Security Info=False;uid=xxxx;pwd=xxxxx;SELECTLOOPS=N;ExtendedProperties="""SERVER=xxxxx;DATABASE=xxxxx;SERVERTYPE=INGRES""Mimer SQLODBCStandard Security:"Driver={MIMER};Database=mydb;Uid=myuser;Pwd=mypw;"Prompt for username and password:"Driver={MIMER};Database=mydb;"LightbaseStandardStandard:"user=USERLOGIN;password=PASSWORD;UDB=USERBASE;server=SERVERNAME"PostgreSQLCore 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.PostgreSQL driverStandard:"DRIVER={PostgreSQL};SERVER=ipaddress;port=5432;DATABASE=dbname;UID=username; PWD=password;"Npgsql by pgFoundry (.NET)SSL activated:"Server=127.0.0.1;Port=5432;Userid=myuserid;password=mypw;Protocol=3;SSL=true;Pooling=t rue;MinPoolSize=3;MaxPoolSize=20;Encoding=UNICODE;Timeout=20;SslMode=Require"Without SSL:"Server=127.0.0.1;Port=5432;Userid=myuserid;password=mypw;Protocol=3;SSL=false;Pooling= true;MinPoolSize=1;MaxPoolSize=20;Encoding=UNICODE;Timeout=15;SslMode=Disable" Read more in the Npgsql: User's Manual and on the pgFoundry website.ParadoxODBC5.X:Driver={Microsoft Paradox Driver (*.db )};DriverID=538;Fil=Paradox 5.X;DefaultDir=c:\pathToDb\;Dbq=c:\pathToDb\;CollatingSequence=ASCII"7.X:"Provider=MSDASQL.1;Persist Security Info=False;Mode=Read;Extended Properties='DSN=Paradox;DBQ=C:\myDb;DefaultDir=C:\myDb;DriverId=538;FIL=Paradox7.X;MaxBufferSize=2048;PageTimeout=600;';Initial Catalog=C:\myDb"OleDbConnection (.NET)Standard"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\myDb;Extended Properties=Paradox 5.x;" MS kb-article: How to use Paradox data with Access and Jet >>DSN。