文档详情

方法及编程设置了解SQL的构成和语法,掌握基本数据操纵语句掌握.ppt

发布:2018-11-14约1.85万字共95页下载文档
文本预览下载声明
本章教学目标 理解数据库的基本概念, 掌握数据绑定的实现方法,熟悉DataGridView、BindingSource等常用数据控件 掌握ADO.NET主要对象的属性、方法及编程设置 了解SQL的构成和语法,掌握基本数据操纵语句 掌握数据库查询和更新(插入、删除、修改)的实现方法 11.1 数据库的基本概念 典型的关系数据库产品 Access SQL Server Oracle 11.1.1 表与记录 11.1.2 表的结构设计 11.2 数据绑定 数据绑定(data binding) DataSet BindingSource DataGridView 只需编写少量代码,就可以实现数据库访问 11.2.1 设计时与数据控件的绑定 在应用程序界面设计阶段,通过手工操作实现的数据绑定 实例11.1 例11.1 利用数据绑定技术,以及DataGridView控件,不编写任何代码,实现数据库内容的查看 操作步骤 操作步骤 操作步骤 操作步骤 操作步骤 操作步骤 自动生成的代码 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; namespace ex11_01 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void 学生基本情况表BindingNavigatorSaveItem_Click(object sender, EventArgs e) { this.Validate(); this.学生基本情况表BindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this.studentDataSet); } private void Form1_Load(object sender, EventArgs e) { this.学生基本情况表TableAdapter.Fill(this.studentDataSet.学生基本情况表); } } } 自动生成的代码 private void 学生基本情况表BindingNavigatorSaveItem_Click(object sender, EventArgs e) { this.Validate(); this.学生基本情况表BindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this.studentDataSet); } private void Form1_Load(object sender, EventArgs e) { this.学生基本情况表TableAdapter.Fill(this.studentDataSet.学生基本情况表); } 11.2.2 设计时与公共控件的绑定 例11.2 利用文本框、图片框和标签控件,实现数据库内容的查看、添加、删除、修改和保存,并查看相关联图片 例11.2程序代码 private void 学生基本情况表BindingNavigatorSaveItem_Click(object sender, EventArgs e) { this.Validate(); this.学生基本情况表BindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this.studentDataSet); } private void Form1_Load(object sender, EventArgs e) { this.学生基本情况表TableAdapter.Fill(this.studentDataSet.学生基本情况表); pictureBox1.Load(@images\ + 学号TextBox.Text + .jpg); //加载图片 } private void 照片TextBox_TextChanged(object sen
显示全部
相似文档