当前位置: 网学 > 编程文档 > SQL SERVER > 正文

ADO.net数据库连结字符串

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/18
下载{$ArticleTitle}原创论文样式

ADO.net 中数据库连接方式(微软提供)

微软提供了以下四种数据库连接方式:
System.Data.OleDb.OleDbConnection
System.Data.SqlClient.SqlConnection
System.Data.Odbc.OdbcConnection
System.Data.OracleClient.OracleConnection
下面我们以范例的方式,来依次说明:
System.Data.SqlClient.SqlConnection
常用的一些连接字符串(C#代码):
SqlConnection conn
= new SqlConnection( "Server=(local);user id=sa;pwd=sa;database=Pubs;");
SqlConnection conn
= new SqlConnection("server=(local)\\NetSDK;database=pubs;Integrated Security=SSPI");
SqlConnection conn = new SqlConnection(
"Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;");
SqlConnection conn = new SqlConnection(
" data source=(local);initial catalog=xr;integrated security=SSPI;
persist security info=False;workstation id=XURUI;packet size=4096; ");
SqlConnection myConn = new
System.Data.SqlClient.SqlConnection("Persist Security Info=False;Integrated
Security=SSPI;database=northwind;server=mySQLServer");
SqlConnection conn = new SqlConnection(
" uid=sa;pwd=passwords;initial catalog=pubs;data source=127.0.0.1;Connect Timeout=900");
更多字符串连接说明请看MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataSqlClientSqlConnectionClassConnectionStringTopic.asp
System.Data.OleDb.OleDbConnection
常用的一些连接字符串(C#代码):
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\MyWeb\81\05\GrocerToGo.mdb");
OleDbConnection conn = new OleDbConnection(
@"Provider=Microsoft.Jet.OLEDB.4.0;Password=;
User ID=Admin;Data Source=grocertogo.mdb;");
OleDbConnection conn = new OleDbConnection(
"Provider=MSDAORA; Data Source=ORACLE8i7;Persist Security Info=False;Integrated Security=yes");
OleDbConnection conn = new OleDbConnection(
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\bin\LocalAccess40.mdb");
OleDbConnection conn = new OleDbConnection(
"Provider=SQLOLEDB;Data Source=MySQLServer;Integrated Security=SSPI");
更多字符串连接说明请看MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataOleDbOleDbConnectionClassConnectionStringTopic.asp?frame=true

System.Data.OracleClient.OracleConnection
常用的一些连接字符串(C#代码):
OracleConnection myConn = new System.Data.OracleClient.OracleConnection(
"Data Source=Oracle8i;Integrated Security=yes");

更多字符串连接说明请看MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataOracleClientOracleConnectionClassConnectionStringTopic.asp?frame=true

System.Data.Odbc.OdbcConnection
常用的一些连接字符串(C#代码):

OdbcConnection conn = new OdbcConnection(
"Driver={SQL Server};Server=MyServer;Trusted_Connection=yes;Database=Northwind;");
OdbcConnection conn = new OdbcConnection(
"Driver={Microsoft ODBC for Oracle};Server=ORACLE8i7;
Persist Security Info=False;Trusted_Connection=yes");
OdbcConnection conn = new OdbcConnec

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号