中文翻译ADO NEWord文档格式.docx

上传人:b****5 文档编号:21530838 上传时间:2023-01-31 格式:DOCX 页数:11 大小:36.46KB
下载 相关 举报
中文翻译ADO NEWord文档格式.docx_第1页
第1页 / 共11页
中文翻译ADO NEWord文档格式.docx_第2页
第2页 / 共11页
中文翻译ADO NEWord文档格式.docx_第3页
第3页 / 共11页
中文翻译ADO NEWord文档格式.docx_第4页
第4页 / 共11页
中文翻译ADO NEWord文档格式.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

中文翻译ADO NEWord文档格式.docx

《中文翻译ADO NEWord文档格式.docx》由会员分享,可在线阅读,更多相关《中文翻译ADO NEWord文档格式.docx(11页珍藏版)》请在冰豆网上搜索。

中文翻译ADO NEWord文档格式.docx

打个比方,一个连接到数据库的应用程序可能比两个做的好,如果是十个那可能更差了。

假如连接达到一百个或超过一百个,那可能都不能用了。

同样,打开数据连接消耗最大限度的系统资源,会使系统的执行效率下降。

为什么要使用ADO.NET?

为了处理上面提到的毛病,ADO.NET诞生了。

它维持一个非连接的数据存取来解决上面的问题。

当应用程序连接数据库的时候,数据连接是打开的。

但是当请求一旦完成连接就关闭了。

同时,如一个数据库被更新了,连接将会保持足够长的时间来完成更新操作然后再关闭。

由于只是维持最小的限度周期的连接,ADO.NET节省了系统资源和提供了最大限度的数据库安全又没多大影响系统的性能。

同时,ADO.NET把数据转换成XML格式来执行相关的操作,这使得他们更有效率。

ADO.NET体系结构

在ADO.NET的数据存取依靠两个组件:

 

数据集(DataSet)和 

数据提供者(DataProvider)数据集(DataSet)数据集是非连接的,用储存功能来表现数据。

它可以被认为是一部分相关数据的本地副本。

数据集驻留在内存中,它可以不依赖数据库被操作和更新。

当数据集被使用完毕后,改变可以被传回中央数据库来更新。

数据可以从任何的数据源被加载,像微软SQLserver数据库,Oracle数据库,或微软Access数据库。

数据供应者(DataProvider)

数据供应者负责提供和维持与数据库的连接。

一个数据供应者是一套工作在一起的组件,它能以有效的方式和性能驱动方式提供数据。

.NET框架现在带来了两个数据提供者:

SQL 

DataProvider是专门为微软SQLServer7.0设计的,而OleDbDataProvider允许我们连接到其他类型的数据库,像Access和Oracle。

每个数据提供者都由以下的组件类组成:

Connection对象提供连接到数据库。

Command对象执行命令。

DataAdapter对象用数据组装一个非连接的数据集和执行更新操作。

用ADO.NET存取数据可以概括如下:

一个连接对象为应用程序建立到数据库的连接,command对象提供直接对数据库的执行命令。

假如命令返回的值多于一个,command对象返回一个DataReader来提供数据。

做为选择,数据适配器可以被用来填充数据集对象。

数据库可以用command对象和适配器来更新。

组件类组成了数据提供者

Connection对象

Connection对象建立了到数据库的连接,MicrosoftVisualStudio.NET提供了两种类型的连接类。

一是SqlConnection对象,它是特别为连接MicrosoftSQLServer7.0而设计的。

二是OleDbConnection对象,它可以提供广泛的数据库连接类型,像微软Access和Oracle。

Connection对象包括全部连接到数据库的所需要的信息。

Command对象

Command对象由两种相应的类来描述:

SqlCommand和OleDbCommand。

Command对象用来直接执行通过数据连接到数据库的命令。

它也可以被用来执行数据库上的存储过程,SQL命令或直接返回一个完全的数据表。

Command对象提供三种方法来执行数据库上的命令:

ExecuteNonQuery:

执行没有返回值的命令,像插入、更行或删除。

ExecuteScalar:

通过数据库查询返回单个值。

ExecuteReader:

用DataReader的方法返回一个结果集。

DataReader对象

DataReader对象从数据库提供一个只向前移动、只读的、连接流数据记录集.不像其他数据提供者的组件。

DataReader对象不能直接实例化,而是通过执行Command对象的ExecuteReader方法返回DataReader实例。

SqlCommand对象的ExecuteReader方法返回一个SqlDataReader对象,OleDbCommand对象的ExecuteReader方法返回一个OleDbDataReader对象。

当你不需要在内存中缓存数据时,DataReader可以直接给应用逻辑提供数据行。

因为在内存中一次只允许缓存一行数据。

DataReader根据系统性能占用最少资源,但是在它的生命周期内却需要使用一个额外打开的Connection对象。

DataAdapter对象

DataAdapter是ADO.NET非连接数据存取的核心类,它的本质是数据库和数据集信息交流的中间媒介。

数据适配器使用它的填充方法同时给数据表和数据集填充数据。

当常驻内存的数据被操作之后,数据适配器调用更新方法来把改变提交给数据库。

它提供四种工具来描述数据库命令:

SelectCommand(选择命令)

InsertCommand(插入命令)

DeleteCommand(删除命令)

UpdateCommand(更新命令)

当更新命令被调用,数据集中的改变被复制回数据库,然后执行适当的插入命令、删除命令或更行命令。

原文1:

ADO.NET1

Mostapplicationsneeddataaccessatonepointoftimemakingitacrucialcomponentwhenworkingwithapplications.Dataaccessismakingtheapplicationinteractwithadatabase,whereallthedataisstored.Differentapplicationshavedifferentrequirementsfordatabaseaccess.VB.NETusesADO.NET(ActiveXDataObject)asit'

sdataaccessandmanipulationprotocolwhichalsoenablesustoworkwithdataontheInternet.Let'

stakealookwhyADO.NETcameintopicturereplacingADO.

EvolutionofADO.NET

Thefirstdataaccessmodel,DAO(dataaccessmodel)wascreatedforlocaldatabaseswiththebuilt-inJetenginewhichhadperformanceandfunctionalityissues.NextcameRDO(RemoteDataObject)andADO(ActiveDataObject)whichweredesignedforClientServerarchitecturesbutsoonADOtookoverRDO.ADOwasagoodarchitecturebutasthelanguagechangessoisthetechnology.WithADO,allthedataiscontainedinarecordsetobjectwhichhadproblemswhenimplementedonthenetwork 

andpenetratingfirewalls.ADOwasaconnecteddataaccess,whichmeansthatwhenaconnectiontothedatabaseisestablishedtheconnectionremainsopenuntiltheapplicationisclosed.Leavingtheconnectionopenforthelifetimeoftheapplication 

raisesconcernsaboutdatabasesecurityandnetworktraffic. 

Also,asdatabasesarebecomingincreasinglyimportantandastheyareservingmorepeople,aconnecteddataaccessmodelmakesusthinkaboutitsproductivity.Forexample,anapplicationwithconnecteddataaccessmaydowellwhenconnectedtotwoclients,thesamemaydopoorlywhenconnectedto10andmightbeunusablewhenconnectedto100ormore.Also,opendatabaseconnectionsusesystemresourcestoamaximumextentmakingthesystemperformancelesseffective.

WhyADO.NET?

Tocopeupwithsomeoftheproblemsmentionedabove,ADO.NETcameintoexistence.ADO.NETaddressestheabovementionedproblemsbymaintainingadisconnecteddatabaseaccessmodelwhichmeans, 

whenanapplicationinteractswiththedatabase,theconnectionisopenedtoservetherequestoftheapplicationandisclosedassoonastherequestiscompleted.Likewise,ifadatabaseisUpdated,theconnectionisopenedlongenoughtocompletetheUpdateoperationandisclosed.Bykeepingconnectionsopenforonlyaminimumperiodoftime,ADO.NETconservessystemresourcesandprovidesmaximumsecurityfordatabasesandalsohaslessimpactonsystemperformance.Also,ADO.NETwheninteractingwith 

thedatabaseusesXML 

andconvertsallthedataintoXMLformat 

fordatabaserelatedoperationsmakingthemmoreefficient.

TheADO.NETDataArchitecture

DataAccessinADO.NETreliesontwocomponents:

DataSetand 

DataProvider.

DataSet

Thedatasetisadisconnected,in-memoryrepresentationofdata.Itcanbeconsideredasalocalcopyof 

therelevantportionsofthedatabase.TheDataSetispersistedinmemoryandthedatainitcanbemanipulatedandupdatedindependentofthedatabase.WhentheuseofthisDataSetisfinished,changescanbemadebacktothecentraldatabaseforupdating.ThedatainDataSetcanbeloadedfromanyvaliddatasourcelikeMicrosoftSQLserverdatabase,anOracledatabaseorfromaMicrosoftAccessdatabase.

DataProvider

TheDataProviderisresponsibleforprovidingandmaintainingtheconnectiontothedatabase.ADataProviderisasetofrelatedcomponentsthatworktogethertoprovidedatainanefficientandperformancedrivenmanner.The.NETFrameworkcurrentlycomeswithtwoDataProviders:

theSQL 

DataProviderwhichisdesignedonlytoworkwithMicrosoft'

sSQLServer7.0orlaterandtheOleDbDataProviderwhichallowsustoconnecttoothertypesofdatabaseslikeAccessandOracle.EachDataProviderconsistsofthefollowingcomponentclasses:

Theobjectwhichprovides 

aconnectiontothedatabase

TheCommandobjectwhichisusedtoexecuteacommand

TheDataReaderobjectwhichprovidesaforward-only,readonly,connectedrecordset

TheDataAdapterobjectwhichpopulatesadisconnectedDataSetwithdataandperformsupdate

DataaccesswithADO.NETcanbesummarizedasfollows:

Aconnectionobjectestablishestheconnectionfortheapplicationwiththedatabase.Thecommandobjectprovidesdirectexecutionofthecommandtothedatabase.Ifthecommandreturnsmorethanasinglevalue,thecommandobjectreturnsaDataReadertoprovidethedata.Alternatively,theDataAdaptercanbeusedtofilltheDatasetobject.ThedatabasecanbeupdatedusingthecommandobjectortheDataAdapter.

ComponentclassesthatmakeuptheDataProviders

TheConnectionObject

TheConnectionobjectcreatestheconnectiontothedatabase.MicrosoftVisualStudio.NETprovidestwotypesofConnectionclasses:

theSqlConnectionobject,whichisdesignedspecificallytoconnecttoMicrosoftSQLServer7.0orlater,andtheOleDbConnectionobject,whichcanprovideconnectionstoawiderangeofdatabasetypeslikeMicrosoftAccessandOracle.TheConnectionobjectcontainsalloftheinformationrequiredtoopenaconnectiontothedatabase.

TheCommandObject

TheCommandobjectisrepresentedbytwocorrespondingclasses:

SqlCommandandOleDbCommand.Commandobjectsareusedtoexecutecommandstoadatabaseacrossadataconnection.TheCommandobjectscanbeusedtoexecutestoredproceduresonthedatabase,SQLcommands,orreturncompletetablesdirectly.Commandobjectsprovidethreemethodsthatareusedtoexecutecommandsonthedatabase:

ExecutescommandsthathavenoreturnvaluessuchasINSERT,UPDATEorDELETE

Returnsasinglevaluefromadatabasequery

ReturnsaresultsetbywayofaDataReaderobject

TheDataReaderObject

TheDataReaderobjectprovidesaforward-only,read-only,connectedstreamrecordsetfromadatabase.UnlikeothercomponentsoftheDataProvider,DataReaderobjectscannotbedirectlyinstantiated.Rather,theDataReaderisreturnedastheresultof 

theCommandobject'

sExecuteReadermethod.TheSqlCommand.ExecuteReadermethodreturnsaSqlDataReaderobject,andtheOleDbCommand.ExecuteReadermethodreturnsanOleDbDataReaderobject.TheDataReadercanproviderowsofdatadirectlytoapplicationlogicwhenyoudonotneedtokeepthedatacachedinmemory.Becauseonlyonerowisinmemoryatatime,theDataReaderprovidesthelowestoverheadintermsofsystemperformancebutrequirestheexclusiveuseofanopenConnectionobjectforthelifetimeoftheDataReader.

TheDataAdapterObject

TheDataAdapteristheclassatthecoreofADO.NET'

sdisconnecteddataaccess.ItisessentiallythemiddlemanfacilitatingallcommunicationbetweenthedatabaseandaDataSet.TheDataAdapterisusedeithertofillaDataTableorDataSetwithdatafromthedatabasewithit'

sFillmethod.Afterthememory-residentdatahasbeenmanipulated,theDataAdaptercancommitthechangestothedatabasebycallingtheUpdatemethod.TheDataAdapterprovidesfourpropertiesthatrepresentdatabasecommands:

SelectCommand

InsertCommand

DeleteCommand

Update

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 初中教育

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1