微软内部.Net培训资料ADO_NET部分 (Using ADO_NET to Access Dat

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

ContentsOverview1OverviewofADO.NET2ConnectingtoaDataSource10AccessingDatawithDataSets12UsingStoredProcedures28Lab3:UsingADO.NETtoAccessData37AccessingDatawithDataReaders46BindingtoXMLData53Review59Module3:UsingADO.NETtoAccessDataInformationinthisdocumentissubjecttochangewithoutnotice.Thenamesofcompanies,products,people,characters,and/ordatamentionedhereinarefictitiousandareinnowayintendedtorepresentanyrealindividual,company,product,orevent,unlessotherwisenoted.Complyingwithallapplicablecopyrightlawsistheresponsibilityoftheuser.Nopartofthisdocumentmaybereproducedortransmittedinanyformorbyanymeans,electronicormechanical,foranypurpose,withouttheexpresswrittenpermissionofMicrosoftCorporation.If,however,youronlymeansofaccessiselectronic,permissiontoprintonecopyisherebygranted.Microsoftmayhavepatents,patentapplications,trademarks,copyrights,orotherintellectualpropertyrightscoveringsubjectmatterinthisdocument.ExceptasexpresslyprovidedinanywrittenlicenseagreementfromMicrosoft,thefurnishingofthisdocumentdoesnotgiveyouanylicensetothesepatents,trademarks,copyrights,orotherintellectualproperty.2001MicrosoftCorporation.Allrightsreserved.Microsoft,ActiveX,FrontPage,JScript,MS-DOS,MSDN,Outlook,PowerPoint,VisualBasic,VisualC#,VisualInterDev,VisualStudio,Windows,WindowsMediaPlayer,andWindowsNTareeitherregisteredtrademarksortrademarksofMicrosoftCorporationintheU.S.A.and/orothercountries.Otherproductandcompanynamesmentionedhereinmaybethetrademarksoftheirrespectiveowners.Module3:UsingADO.NETtoAccessData1OverviewOverviewOverviewofADO.NETConnectingtoaDataSourceAccessingDatawithDataSetsUsingStoredProceduresAccessingDatawithDataReadersBindingtoXMLDataOneofthereasonsforthewidespreaduseofMicrosoft®ActiveServerPages(ASP)isthatitfacilitatesaccesstodatastores.ASP.NETexpandsonthiscapabilitywiththeintroductionofADO.NET,whichoffersarichsuiteofdatahandlinganddatabindingfunctionsformanipulatingalltypesofdata.Aftercompletingthismodule,youwillbeableto:DescribetheADO.NETobjectmodel.ConnecttoadatasourcebyusingADO.NET.RetrievedatafromadatabasebyusingDataReaders,andDataSets.Displaythedatafromadatabaseontheclientbyusinglist-boundcontrols.CustomizethelookofRepeatercontrolswithtemplates.UsestoredprocedurestoreturnRecordsets.ReaddatafromanExtendedMarkupLanguage(XML)fileintoDataSets.TherearemanychangesbetweentheBeta1andBeta2versionsofASP.NETwithrespecttodatabinding.Foradetailedlistofchanges,seeAppendixA,inCourse2063A,IntroductiontoASP.NET.Note2Module3:UsingADO.NETtoAccessDataOverviewofADO.NETOverviewofADO.NETTheADO.NETObjectModelAnimation:UsingADO.NETtoAccessDataRecordSetsvs.DataSetsUsingNamespacesADO.NETisnotarevisionofMicrosoftActiveX®DataObjects(ADO),butanewwaytomanipulatedatathatisbasedondisconnecteddataandXML.AlthoughADOisanimportantdataaccesstoolwithinASP,itdoesnotprovideallthenecessaryfeaturesfordevelopingrobustandscalableWebapplications.InspiteofADO'srichobjectmodelandrelativeeaseofuse,itisconnectedbydefault,reliesonanOLEDBprovidertoaccessdata,anditisentirelyComponentObjectModel(COM)-based.ADO.NEThasbeendesignedtoworkwithdisconnecteddatasets.Disconnecteddatasetsreducenetworktraffic.ADO.NETutilizesXMLastheuniversaltransmissionformat.ThisguaranteesinteroperabilityaslongasthereceivingcomponentrunsonaplatformwhereanXMLparserisavailable.WhenthetransmissionoccursthroughXML,itisnolongernecessarythatthereceiverbeaCOMobject.Thereceivingcomponenthasnoarchitecturalrestrictionswhatsoever.AnysoftwarecomponentcanshareADO.NETdata,aslongasitusesthesameXMLschemafortheformatofthetransmitteddata.Inthissection,youwilllearnaboutADO.NET.YouwilllearnaboutthenewandmodifiedobjectsinADO.NET.YouwillalsolearnaboutsomeofthenewnamespacesthatareincludedinASP.NET.Module3:UsingADO.NETtoAccessData3TheADO.NETObjectModelADO.NETevolvedfromtheADOdataaccessmodel.ByusingADO.NET,youcandevelopapplicationsthatarerobustandscalable,andthatcanuseXML.ADO.NEThassomeofthesameobjectsasADO(liketheConnectionandCommandobjects),andintroducesnewobjects,suchasDataSets,DataReaders,andDatasetCommands.SomeofobjectsinADO.NETrepresentupdatesofexistingobjects(suchasConnectionandCommand),whileothersarecompletelynew(suchasDataReader,DataSet,DataView,andDataSetCommand.ConnectionObjectsConnectionobjectsareusedtotalktodatabases.Theyhaveproperties,suchasDataSource,UserID,andPassword,thatareneededtoaccessaparticularDataSource.Commandstraveloverconnections,andresultsetsarereturnedintheformofstreamsthatcanbereadbyDataReadersorpushedintoDataSetobjects.TherearetwokindsofconnectionobjectsinADO.NET:SQLConnectionandADOConnection.CommandObjectsCommandobjectscontaintheinformationthatissubmittedtoadatabase.Acommandcanbeastoredprocedurecall,anupdatestatement,orastatementthatreturnsresults.Youcanalsouseinputandoutputparametersandreturnvalues.InADO.NET,youcanusetwokindsofcommandobjects:SQLCommandandADOCommand.4Module3:UsingADO.NETtoAccessDataDataReaderObjectsADataReaderisaread-only/forward-onlyviewonthedata.Itprovidesasimpleandlightweightwayoftraversingthroughrecordsets.Forexample,ifyouwantedtosimplysho

1 / 62
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功