.NET 系列教程2310B_09_第1页
.NET 系列教程2310B_09_第2页
.NET 系列教程2310B_09_第3页
.NET 系列教程2310B_09_第4页
.NET 系列教程2310B_09_第5页
已阅读5页,还剩18页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Module 9:Accessing Relational Data Using Microsoft Visual Studio .NET,Overview,Overview of ADO.NET Creating a Connection to a Database Displaying a DataSet in a List-Bound Control,Lesson: Overview of ADO.NET,What is ADO.NET? Using Namespaces The ADO.NET Object Model What is a DataSet? Accessing Data

2、 with ADO.NET Practice: Identifying ADO.NET Components,ADO.NET provides a set of classes for working with data. ADO.NET provides:,An evolutionary, more flexible successor to ADO A system designed for disconnected environments A programming model with advanced XML support A set of classes, interfaces

3、, structures, and enumerations that manage data access from within the .NET Framework,What is ADO.NET?,Using Namespaces,Use the Imports or using statement to import namespaces Namespaces used with ADO.NET include: System.Data System.Data.SqlClient System.Data.OleDb,Imports System.Data Imports System

4、.Data.SqlClient,using System.Data; using System.Data.SqlClient;,DataSet,SQL Server .NET Data Provider,OLE DB .NET Data Provider,SQL Server 7.0 (and later),OLEDB sources(SQL Server 6.5),OleDbConnection,OleDbDataAdapter,SqlDataAdapter,SqlConnection,DataTable,DataTable,The ADO.NET Object Model,SQL Serv

5、er 2000,DataSet,DataTable,DataTable,Physical storage,OleDb Database,SqlDataAdapter,SqlConnection,DataTable,Web server memory,OleDbDataAdapter,OleDbConnection,What is a Dataset?,Accessing Data with ADO.NET,Database,Return the DataSet to the Client,Client manipulates the data,Create the SqlConnection

6、and SqlDataAdapter objects,Fill the DataSet from the DataAdapter and close the connection,SqlDataAdapter,SqlConnection,List-Bound Control,Client makes request,1,2,3,4,5,Update the DataSet,Use the SqlDataAdapter to open the SqlConnection, update the database, and close the connection,6,7,Client,Web s

7、erver,Practice: Identifying ADO.NET Components,Students will: Move icons of various components of ADO.NET to the correct locations Time: 5 Minutes,Lesson: Creating a Connection to a Database,Using Server Explorer to Generate a Connection The DataAdapter Object Model Demonstration: Connecting to a Da

8、tabase Generating a DataSet Demonstration: Generating a DataSet,Using Server Explorer to Generate a Connection,Create a new data connection by dragging a Table from Server Explorer,Create a new data connection using the Data Links dialog box,The DataAdapter Object Model,sp_SELECT,Command,SelectComma

9、nd,UpdateCommand,InsertCommand,DeleteCommand,DataAdapter,Command,Command,Command,Connection,sp_UPDATE,sp_INSERT,sp_DELETE,Database,DataSet,DataReader,Demonstration: Connecting to a Database,Expand Server Explorer to a table in a SQL Server database Drag the table to an ASP.NET Web Form View the data

10、 using the SqlDataAdapter View the source of the page that was created Configure the DataAdapter object,Generating a DataSet,You can generate a DataSet through the UI Creates a DataSet that allows you to access data as an object or through code and then fill,Dim ds As New DataSet(),DataAdapter1.Fill

11、(ds) DataAdapter2.Fill(ds),DataSet ds = new DataSet();,DataAdapter1.Fill(ds); DataAdapter2.Fill(ds);,Demonstration: Generating a DataSet,Create a typed DataSet from a DataAdapter Add a second DataTable from a different DataAdapter Show the schema of DataSet,Lesson: Displaying a DataSet in a List-Bou

12、nd Control,What are List-Bound Controls? Displaying DataSet Data in List-Bound Controls Demonstration: Binding List-Bound Controls to a Database Practice: Using a DataGrid Demonstration: Customizing the DataGrid Control,What are List-Bound Controls?,Controls that connect to a data source and display

13、 the data List-bound controls include the following: DropDownList ListBox CheckBoxList RadioButtonList,DataGrid DataList Repeater,Displaying DataSet Data in List-Bound Controls,Set the properties Fill the DataSet, then call the DataBind method,DataAdapter1.Fill(ds) lstEmployees.DataBind(),DataAdapte

14、r1.Fill(ds); lstEmployees.DataBind();,Demonstration: Binding List-Bound Controls to a Database,Add a DataGrid to a Web Form Set the DataSource and DataMember properties Fill the DataSet Call DataBind(),Practice: Using a DataGrid,Students will: Create a SqlConnection Create a SqlDataAdapter Generate

15、a DataSet Place a DataGrid on a Web Form Bind the DataGrid to the DataSet Time: 5 minutes,Demonstration: Customizing the DataGrid Control,Using AutoFormat Setting custom column headers Paging Sorting,Review,Overview of ADO.NET Creating a Connection to a Database Displaying a DataSet in a List-Bound Control,MedicalMedical.aspx,BenefitsHome PageDefault.aspx,Life InsuranceLife.aspx,RetirementRetirement.aspx,DentalDental.aspx,Dentists,DoctorsDoctors.aspx,Doctors,Logon Page Login.aspx,Registration Register.aspx,CohoWinery,ProspectusProspectus.as

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论