开发者社区> 像教授> 正文
阿里云
为了无法计算的价值
打开APP
阿里云APP内打开

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,如需转载请自行联系原作者

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

相关文章
ADO 与ADO.NET
http://www.microsoft.com/china/community/program/originalarticles/techdoc/ADONET.mspx 摘要 ADO与ADO.NET是微软提供的一种高性能访问信息源的策略,这些技术可以使企业很方便的整合多种数据源,创建易维护的解决方案。
849 0
ADO.NET 连接数据库方式
使用Command和DataReader对象:
0 0
ADO.NET结合C#常见的数据库操作(二)
  现在接着上次的来讲SqlDataAdapter的相关应用。   SqlDataAdapter表示用于填充 DataSet 和更新 SQL Server 数据库的一组数据命令和一个数据库连接。 此类不能被继承。
589 0
ADO.NET结合C#常见的数据库操作(一)
  ADO.NET使我们在VS开发中用到最多的数据库访问接口,这里我不见它的原理和其它,直接说它的几种常见的用法。 声明:在ADO.NET全部讲完之后,会将整个源代码贴出,将单个的时候只贴出涉及到的代码。
662 0
ADO.NET中的五个主要对象
Connection 物件    Connection 对象主要是开启程序和数据库之间的连结。没有利用连结对象将数据库打开,是无法从数据库中取得数据的。这个物件在ADO.NET 的最底层,我们可以自己产生这个对象,或是由其它的对象自动产生。
691 0
+关注
文章
问答
文章排行榜
最热
最新
相关电子书
更多
低代码开发师(初级)实战教程
立即下载
阿里巴巴DevOps 最佳实践手册
立即下载
冬季实战营第三期:MySQL数据库进阶实战
立即下载