ADO.NET连接字符串-阿里云开发者社区

开发者社区> 像教授> 正文

ADO.NET连接字符串

简介:
+关注继续查看
2008-04-15 12:49
名称
ADO.NET连接字符串
说明 ADO.NET连接字符串:SQL Server,SQL Server 2005,ACCESS,Oracle,MySQL,Interbase,IBM DB2,Sybase,Informix,Ingres,Mimer SQL,Lightbase,PostgreSQL,Paradox,DNS,Firebird,Excel ,Text,DBF / FoxPro,AS/400 (iSeries),Exchange,Visual FoxPro,Pervasive,UDL。

1 - SQL Server
2 - SQL Server 2005
3 - ACCESS, Oracle
4 - MySQL, Interbase, IBM DB2
5 - Sybase, Informix, Ingres, Mimer SQL, Lightbase, PostgreSQL, Paradox, DNS
6 - Firebird, Excel , Text, DBF / FoxPro, AS/400 (iSeries), Exchange, Visual FoxPro, Pervasive, UDL
1
SQL Server
ODBC
标准安全 " Driver={SQL Server}; Server=Aron1; Database=pubs; Uid=sa; Pwd=asdasd; "
信任的连接 " Driver={SQL Server}; Server=Aron1; Database=pubs; Trusted_Connection=yes; "
提示输入用户名和密码 oConn.Properties(" Prompt" ) = adPromptAlways
oConn.Open " Driver={SQL Server}; Server=Aron1; DataBase=pubs; "
OLE DB, OleDbConnection (.NET)
标准安全 " Provider=sqloledb; Data Source=Aron1; Initial Catalog=pubs; User Id=sa; Password=asdasd; "
信任的连接 " 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)
提示输入用户名和密码 oConn.Provider = " sqloledb"
oConn.Properties(" Prompt" ) = adPromptAlways
oConn.Open " Data Source=Aron1; Initial Catalog=pubs; "
IP地址连接管道 " 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)
标准安全 " 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)
信任的连接 " 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)
IP地址连接管道 " 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对象 C#:
using System.Data.SqlClient;
SqlConnection oSQLConn = new SqlConnection();
oSQLConn.ConnectionString=" my connection string" ;
oSQLConn.Open();
VB.NET:
Imports System.Data.SqlClient
Dim oSQLConn As SqlConnection = New SqlConnection()
oSQLConn.ConnectionString=" my connection string"
oSQLConn.Open()
Data Shape
MS Data Shape " Provider=MSDataShape; Data Provider=SQLOLEDB; Data Source=Aron1; Initial Catalog=pubs; User ID=sa; Password=asdasd; "
2
SQL Server 2005
SQL Native Client ODBC Driver
标准安全 " Driver={SQL Native Client}; Server=Aron1; Database=pubs; UID=sa; PWD=asdasd; "
信任的连接 " Driver={SQL Native Client}; Server=Aron1; Database=pubs; Trusted_Connection=yes; "
Equivalents
Integrated Security=SSPI equals Trusted_Connection=yes
提示输入用户名和密码 oConn.Properties(" Prompt" ) = adPromptAlways
oConn.Open " Driver={SQL Native Client}; Server=Aron1; DataBase=pubs; "
授权的MARS(多重活动结果集) " Driver={SQL Native Client}; Server=Aron1; Database=pubs; Trusted_Connection=yes; MARS_Connection=yes"
Equivalents
MultipleActiveResultSets=true equals MARS_Connection=yes
加密数据网络传输 " Driver={SQL Native Client}; Server=Aron1; Database=pubs; Trusted_Connection=yes; Encrypt=yes"
在本地SQL服务器实例附加数据库文件 " Driver={SQL Native Client}; Server=.\SQLExpress; AttachDbFilename=c:\asd\qwe\mydbfile.mdf; Database=dbname; Trusted_Connection=Yes; "
- or -
" Driver={SQL Native Client}; Server=.\SQLExpress; AttachDbFilename=|DataDirectory|mydbfile.mdf; Database=dbname; Trusted_Connection=Yes; "
(use |DataDirectory| when your database file resides in the data directory)
SQL Native Client OLE DB Provider
标准安全 " Provider=SQLNCLI; Server=Aron1; Database=pubs; UID=sa; PWD=asdasd; "
信任的连接 " Provider=SQLNCLI; Server=Aron1; Database=pubs; Trusted_Connection=yes; "
Equivalents
Integrated Security=SSPI equals Trusted_Connection=yes
提示输入用户名和密码 oConn.Properties(" Prompt" ) = adPromptAlways
oConn.Open " Provider=SQLNCLI; Server=Aron1; DataBase=pubs; "
授权的MARS(多重活动结果集) " Provider=SQLNCLI; Server=Aron1; Database=pubs; Trusted_Connection=yes; MarsConn=yes"
Equivalents
MarsConn=yes equals MultipleActiveResultSets=true equals MARS_Connection=yes
加密数据网络传输 " Provider=SQLNCLI; Server=Aron1; Database=pubs; Trusted_Connection=yes; Encrypt=yes"
在本地SQL服务器实例附加数据库文件 " Provider=SQLNCLI; Server=.\SQLExpress; AttachDbFilename=c:\asd\qwe\mydbfile.mdf; Database=dbname; Trusted_Connection=Yes; "
- or -
" Provider=SQLNCLI; Server=.\SQLExpress; AttachDbFilename=|DataDirectory|mydbfile.mdf; Database=dbname; Trusted_Connection=Yes; "
(use |DataDirectory| when your database file resides in the data directory)
SqlConnection (.NET)
标准安全 " 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)
信任的连接 " Data Source=Aron1; Initial Catalog=pubs; Integrated Security=SSPI; "
- or -
" Server=Aron1; Database=pubs; Trusted_Connection=True; "
(both connection strings produces the same result)
IP地址连接管道 " 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))
授权的MARS(多重活动结果集) " Server=Aron1; Database=pubs; Trusted_Connection=True; MultipleActiveResultSets=true"
Note! Use ADO.NET 2.0 for MARS functionality. MARS is not supported in ADO.NET 1.0 nor ADO.NET 1.1
在本地SQL服务器实例附加数据库文件 " Server=.\SQLExpress; AttachDbFilename=c:\asd\qwe\mydbfile.mdf; Database=dbname; Database=dbname; Trusted_Connection=Yes; "
- or -
" Server=.\SQLExpress; AttachDbFilename=|DataDirectory|mydbfile.mdf; Database=dbname; Trusted_Connection=Yes; "
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/function
Context Connection - connecting to " self" from within your CLR stored prodedure/function
C# 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 connection
End Using
Read more
When to use SQL Native Client? .Net applications
Do not use the SQL Native Client. Use the .NET Framework Data Provider for SQL Server (SqlConnection).
COM applications, all other then .Net applications
COM applications, all other then .Net applications
Use 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.



本文转自 xhinkerx 51CTO博客,原文链接:http://blog.51cto.com/xhinker/131935,如需转载请自行联系原作者

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
用字符串连接SQL语句并用EXEC执行时,出现名称 '‘不是有效的标识符
原文:用字符串连接SQL语句并用EXEC执行时,出现名称 '‘不是有效的标识符  用字符串连接SQL语句并用EXEC执行时,出现名称 '这里是字符串连接的一条SQL语句‘不是有效的标识符  才发现,在写exec @sql 时,忘了在@sql加(),这样写 exec (@sql) 就不会出错了!
593 0
获取SQLSERVER2005 的连接字符串的另类方法
获取SQLSERVER2005 的连接字符串的另类方法,这个方法是我的一个很牛比的同事告诉我的。 很使用,而且很方面。 1 新建一个.txt文件 2 改名:aa.udl 或 aa.UDL   .后缀名为 udl . 3 双击 aa.udl     ------> 提供程序: 选择SQL Server版本:Micorsoft OLE DB Provider for SQL Server 4 下一步 :连接 (1)选择或输入服务器名称:写如你要连接的数据库服务器名称。
711 0
【转】ADO.NET连接访问dbf数据库问题
from:http://space.cnblogs.com/question/7423/    悬赏园豆:20 [已解决问题] 浏览: 2067次   我发现当dbf文件的长度超过8的时候,使用OleDbCommand 查询就会出现“jet 数据库引擎找不到对象”的错误,我搜索到(http://space.cnblogs.com/question/2046/)说解决了这个问题,方法是将表的名字加个中括号。
1139 0
ASP.NET中检测含有中文字符串的实际长度
以下就是在ASP.NET中检测含有中文字符串的实际长度,这个可能在很多地方都用的上.        VB.NET的写法:    Function StrLength(Byval Str As String) As Integer      Dim En As ASCIIEncoding=New ASCIIEncoding ()    Dim B As Byte()=En.
541 0
C#各种数据库连接字符串大全——SQLServer、Oracle、Access
在这里统计了.NET项目下常用的数据库连接字符串:SQLServer、Oracle、Access三种数据库(MySql、SQLLite、Excel、HTML Table等等暂不列入)。
1139 0
解决伪分布式hadoop部署hive后,无法通过beeline连接
应用场景 当在伪分布式hadoop2.6.0集群中,部署添加了hive2.1.1后,发现输入hive命令,可以进行连接hive,但是用beeline连接连不上。
1872 0
在Entity Framework中重用现有的数据库连接字符串
本文转载:http://www.cnblogs.com/dudu/archive/2011/01/29/entity_framework_connection_string.html 如果EF在使用实体模型时候,即model first 和db first 时候,则 Entity Framework使用的连接字符串与ADO.NET是不同的,见下图: 相比于ADO.NET,Entity Framework的连接字符串不仅要存放metadata配置信息,还要存放完整的数据库连接字符串(上图中的"provider connection string"部分)。
874 0
asp.net 连接新浪微博
资料收集 1 官方 http://open.weibo.com/sdk/js http://open.weibo.com/widget/js#connect   2 教程 http://zzk.
714 0
用二进制来编码字符串"adceadaa",需要能够相据编码,解码回原来的字符串,则至少需要二进制字符的长度是?
利用哈夫曼编码,字符出现的频率越大,则使用越短的二进制进行编码,构建最优二叉树。
713 0
+关注
1338
文章
0
问答
文章排行榜
最热
最新
相关电子书
更多
《2021云上架构与运维峰会演讲合集》
立即下载
《零基础CSS入门教程》
立即下载
《零基础HTML入门教程》
立即下载