图5.3 教学计划 内容来自论文无忧网 www.paper51.com 首先在数据库建教师信息的数据表,表中具有界面上的相关字段 copyright paper51.com
用 LABEL控件 画出 各个标签,CAPITION 属性为数据库的各个字段。 http://www.paper51.com 用ADOTABLETABLE控件 使用连接数据库,在文件名,选择当前目录的数据库,在数据源选择教师信息的数据表,然后确定,这样的目的是使用ADOTABLE控件连接到数据库。 http://www.paper51.com 用DataSource控件连接到ADOTABLETABLE数据源。 http://www.paper51.com 然后用EDIT控件通过连接DataSource而连接到数据库通过连接EDIT控件把数据库的字段显示出来。 http://www.paper51.com
用DBEDIT控件在界面画出各个容器,数据源设为 ADOTABLE控件,然后选择要显示的数据库字段, paper51.com
画出DBNavigator1控件,通过DBNavigator1控件对数据库的记录进行向前,向后滚动,并进行添加,删除,刷新,保存的操作。 内容来自论文无忧网 www.paper51.com unit Unit4; 内容来自www.paper51.com interface copyright paper51.com
uses 内容来自www.paper51.com
Windows, Messages, SysUtils, Variants,Classes, Graphics, Controls, Forms, 内容来自论文无忧网 www.paper51.com Dialogs, ADODB, DB, Grids, DBGrids,StdCtrls, ExtCtrls, DBCtrls, ComCtrls, http://www.paper51.com Mask; http://www.paper51.com type http://www.paper51.com
TForm4 = class(TForm) 内容来自论文无忧网 www.paper51.com DataSource1: TDataSource; 内容来自论文无忧网 www.paper51.com
Label1: TLabel; paper51.com ADOTable1: TADOTable; 内容来自论文无忧网 www.paper51.com PageControl1: TPageControl; 内容来自论文无忧网 www.paper51.com
TabSheet1: TTabSheet; 内容来自论文无忧网 www.paper51.com TabSheet2: TTabSheet; 内容来自www.paper51.com TabSheet3: TTabSheet; 内容来自论文无忧网 www.paper51.com
DBNavigator1: TDBNavigator; copyright paper51.com
Label2: TLabel; 内容来自论文无忧网 www.paper51.com DBEdit1: TDBEdit; paper51.com Label3: TLabel; copyright paper51.com Label4: TLabel; paper51.com
DBEdit3: TDBEdit; http://www.paper51.com Label5: TLabel; http://www.paper51.com Label6: TLabel; http://www.paper51.com DBEdit5: TDBEdit; paper51.com DataSource3: TDataSource; copyright paper51.com ADOQuery1: TADOQuery; paper51.com DBGrid1: TDBGrid; 内容来自论文无忧网 www.paper51.com Button1: TButton; 内容来自论文无忧网 www.paper51.com
ADOTable2: TADOTable; 内容来自www.paper51.com DataSource2: TDataSource; http://www.paper51.com Label7: TLabel; http://www.paper51.com
Label8: TLabel; copyright paper51.com ADOTable3: TADOTable; paper51.com
DataSource4: TDataSource; http://www.paper51.com DBGrid3: TDBGrid; http://www.paper51.com TabSheet4: TTabSheet; 内容来自www.paper51.com
DBComboBox1: TDBComboBox; paper51.com DBGrid4: TDBGrid; paper51.com ComboBox1: TComboBox; paper51.com DBGrid2: TDBGrid; http://www.paper51.com DBNavigator2: TDBNavigator; 内容来自www.paper51.com TabSheet5: TTabSheet; http://www.paper51.com ComboBox2: TComboBox; 内容来自www.paper51.com
ADOQuery2: TADOQuery; 内容来自论文无忧网 www.paper51.com DataSource5: TDataSource; copyright paper51.com DBGrid5: TDBGrid; paper51.com Button2: TButton; 内容来自论文无忧网 www.paper51.com
ADOTable1DSDesigner:TIntegerField; http://www.paper51.com
ADOTable1DSDesigner2:TWideStringField; 内容来自论文无忧网 www.paper51.com ADOTable1DSDesigner3:TWideStringField; 内容来自www.paper51.com ADOTable1DSDesigner4:TWideStringField; copyright paper51.com
ADOTable1DSDesigner5:TWideStringField; 内容来自论文无忧网 www.paper51.com
DBLookupComboBox1:TDBLookupComboBox; http://www.paper51.com ADOTable4: TADOTable; paper51.com DataSource6: TDataSource; http://www.paper51.com procedureButton2Click(Sender: TObject); http://www.paper51.com
procedureButton1Click(Sender: TObject); http://www.paper51.com procedure FormCreate(Sender:TObject); 内容来自www.paper51.com
private copyright paper51.com { Private declarations } paper51.com public paper51.com { Public declarations } 内容来自www.paper51.com
end; http://www.paper51.com var 内容来自www.paper51.com
Form4: TForm4; 内容来自www.paper51.com implementation http://www.paper51.com {$R *.dfm} copyright paper51.com
procedureTForm4.Button2Click(Sender: TObject); paper51.com begin copyright paper51.com ADOQuery2.Close; paper51.com ADOQuery2.SQL.Clear; 内容来自www.paper51.com ADOQuery2.SQL.Add('SELECT * FROMjh_qh'); http://www.paper51.com ADOQuery2.SQL.Add('where 学期=:ss'); 内容来自论文无忧网 www.paper51.com
ADOQuery2.Parameters.ParamByName('ss').Value:=ComboBox2.Text ; paper51.com ADOQuery2.Open ; 内容来自论文无忧网 www.paper51.com end; 内容来自www.paper51.com procedureTForm4.Button1Click(Sender: TObject); paper51.com begin 内容来自论文无忧网 www.paper51.com ADOQuery1.Close; 内容来自www.paper51.com ADOQuery1.SQL.Clear; paper51.com ADOQuery1.SQL.Add('SELECT * FROMjxjh'); paper51.com ADOQuery1.SQL.Add('where 学期=:ss'); paper51.com ADOQuery1.Parameters.ParamByName('ss').Value:=ComboBox1.Text ; 内容来自论文无忧网 www.paper51.com
ADOQuery1.Open ; http://www.paper51.com end; paper51.com
procedure TForm4.FormCreate(Sender:TObject); 内容来自www.paper51.com
begin 内容来自www.paper51.com
end; 内容来自论文无忧网 www.paper51.com end. 内容来自论文无忧网 www.paper51.com
图5.4 查询 copyright paper51.com 按学期查询: copyright paper51.com
使用ADOQuery1控件连接数据库, 内容来自论文无忧网 www.paper51.com 在ADOQuery1的数据源选择当前目录的数据库, copyright paper51.com 在SQL 属性输入以下SQL查询语句, 内容来自www.paper51.com select * from http://www.paper51.com where 学期= :ss copyright paper51.com 然后确定,这样的目的是使用SQL查询语句索检出记录 http://www.paper51.com 在(TParameters)属性中建立变量”SS”. copyright paper51.com 用一个EDIT控件输入查询条件,用一个COMMAND控件实现查询 内容来自论文无忧网 www.paper51.com |