中数据库连接方式.doc

上传人:飞****2 文档编号:56548298 上传时间:2022-11-02 格式:DOC 页数:5 大小:21.50KB
返回 下载 相关 举报
中数据库连接方式.doc_第1页
第1页 / 共5页
中数据库连接方式.doc_第2页
第2页 / 共5页
点击查看更多>>
资源描述

《中数据库连接方式.doc》由会员分享,可在线阅读,更多相关《中数据库连接方式.doc(5页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、ADO.net 中数据库连接方式在MSDN中,.net的数据库连接字符串都有详细的说明,我这里以代码范例的方式罗列一些,具体的每一项代表的意义可以参看MSDN.ADO.net 中数据库连接方式(微软提供)微软提供了以下四种数据库连接方式:System.Data.OleDb.OleDbConnectionSystem.Data.SqlClient.SqlConnectionSystem.Data.Odbc.OdbcConnectionSystem.Data.OracleClient.OracleConnection下面我们以范例的方式,来依次说明:System.Data.SqlClient.Sq

2、lConnection常用的一些连接字符串(C#代码):SqlConnection conn = new SqlConnection( Server=(local);Integrated Security=SSPI;database=Pubs);SqlConnection conn = new SqlConnection(server=(local)NetSDK;database=pubs;Integrated Security=SSPI);SqlConnection conn = new SqlConnection(Data Source=localhost;Integrated Secur

3、ity=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

4、;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:System.Data.OleDb.OleDbConnection常用的一些连接字符串(C#代码):OleDbConnection conn = new OleDbConnection(P

5、rovider=Microsoft.Jet.OLEDB.4.0;Data Source=D:MyWeb8105GrocerToGo.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

6、Info=False;Integrated Security=yes);OleDbConnection conn = new OleDbConnection(Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:binLocalAccess40.mdb);OleDbConnection conn = new OleDbConnection(Provider=SQLOLEDB;Data Source=MySQLServer;Integrated Security=SSPI);更多字符串连接说明请看MSDN:System.Data.OracleClient

7、.OracleConnection常用的一些连接字符串(C#代码):OracleConnection myConn = new System.Data.OracleClient.OracleConnection(Data Source=Oracle8i;Integrated Security=yes);更多字符串连接说明请看MSDN:System.Data.Odbc.OdbcConnection常用的一些连接字符串(C#代码):OdbcConnection conn = new OdbcConnection(Driver=SQL Server;Server=MyServer;Trusted_C

8、onnection=yes;Database=Northwind;);OdbcConnection conn = new OdbcConnection(Driver=Microsoft ODBC for Oracle;Server=ORACLE8i7;Persist Security Info=False;Trusted_Connection=yes);OdbcConnection conn = new OdbcConnection(Driver=Microsoft Access Driver (*.mdb);DBQ=c:binnwind.mdb);OdbcConnection conn =

9、new OdbcConnection(Driver=Microsoft Excel Driver (*.xls);DBQ=c:binbook1.xls);OdbcConnection conn = new OdbcConnection(Driver=Microsoft Text Driver (*.txt; *.csv);DBQ=c:bin);OdbcConnection conn = new OdbcConnection(DSN=dsnname);更多字符串连接说明请看MSDN:其他厂商提供的数据库连接:DB2Connection myConn = new IBM.Data.DB2.DB2C

10、onnection(DATABASE = SAMPLE;UID=; PWD=;);DB2Connection myConn = new IBM.Data.DB2.DB2Connection(DATABASE = SAMPLE);BdpConnection myConn = new Borland.Data.Provider.BdpConnection(assembly=Borland.Data.Mssql,Version=1.1.0.0,Culture=neutral,PublicKeyToken=91d62ebb5b0d1b1b;vendorclient=sqloledb.dll;osaut

11、hentication=False;database=;username=;hostname=;password=;provider=MSSQL);BdpConnection myConn = new Borland.Data.Provider.BdpConnection(assembly=Borland.Data.Db2,Version=1.1.0.0,Culture=neutral,PublicKeyToken=91d62ebb5b0d1b1b;vendorclient=db2cli.dll;database=;username=;password=;provider=DB2);Conne

12、ction Pooling在SQL Server、OLE DB和.NET框架结构中的Data Provider中,都提供了隐式的连接池连接支持。你可以在ConnectionString中指定不同的参数值控制连接池的行为。比如下面的例子使OLE DB的连接池无效并自动地进行事务处理:Provider=SQLOLEDB;OLE DB Services=-4;Data Source=localhost;Integrated Security=SSPI;在SQL Server.NET Data Provider中提供了以下参数设置控制连接池的行为:Connection Lifttime、Connection Reset、Enlist、Max Pool Size、Min Pool Size和Pooling。更多数据库连接信息,以及非ADO.net的连接字符串可以参看:

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 教案示例

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com