为何两个差不多的界面,一个功能可以实现,一个不可以呢
delphi吧
全部回复
仅看楼主
level 7
可以实现功能
2015年01月11日 15点01分 1
level 7
代码是:
unit Unit7;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, GridsEh, DBGridEh, StdCtrls, PrnDbgeh, DBTables,
jpeg, ExtCtrls;
type
TForm7 = class(TForm)
GroupBox2: TGroupBox;
Label1: TLabel;
Label2: TLabel;
ComboBox1: TComboBox;
Edit1: TEdit;
Button2: TButton;
PrintDBGridEh1: TPrintDBGridEh;
GroupBox1: TGroupBox;
DBGridEh1: TDBGridEh;
Button1: TButton;
Image1: TImage;
ADOConnection1: TADOConnection;
ADOTable1: TADOTable;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form7: TForm7;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm7.FormCreate(Sender: TObject);
begin
with ADOQuery1 do
begin
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from 学生基本信息表 where 学号='''+form1.Edit1.Text+'''');
ADOQuery1.Open;
end;
end;
procedure TForm7.FormClose(Sender: TObject; var Action: TCloseAction);
begin
action:=cafree;
form7:=nil;
end;
procedure TForm7.Button2Click(Sender: TObject);
begin
with ADOQuery1 do
begin
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('update 学生基本信息表 set '+ComboBox1.Text+'='''+edit1.Text+'''');
ADOQuery1.SQL.Add('where 学号='''+form1.Edit1.Text+'''');
ADOQuery1.ExecSQL;
form7.Close;
end;
end;
procedure TForm7.Button1Click(Sender: TObject);
begin
PrintDBGridEh1.Preview;
end;
end.
2015年01月11日 15点01分 2
level 7
不能实现
2015年01月11日 15点01分 3
level 7
代码是:
unit Unit5;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, GridsEh, DBGridEh, ExtCtrls, Gradpan, DBNavigatorL,
StdCtrls, Grids, DBGrids, ADODB, PrnDbgeh, jpeg;
type
TForm5 = class(TForm)
Image1: TImage;
ADOConnection1: TADOConnection;
ADOTable1: TADOTable;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
DBGridEh2: TDBGridEh;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form5: TForm5;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm5.FormCreate(Sender: TObject);
begin
with ADOQuery1 do
begin
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from 学生成绩表 where 学号='''+form1.Edit1.Text+'''');
ADOQuery1.Open;
end;
end;
procedure TForm5.FormClose(Sender: TObject; var Action: TCloseAction);
begin
action:=cafree;
form5:=nil;
end;
end.
2015年01月11日 15点01分 4
level 7
2015年01月11日 15点01分 5
level 7
2015年01月11日 15点01分 6
level 7
求大神解决
2015年01月11日 15点01分 7
level 3
估计是表格的数据源没有连接好。
2015年01月11日 15点01分 8
确认好几遍了,感觉两个界面的数据源连接的都是一样的。
2015年01月11日 16点01分
ADOConnection没连接好。
2015年01月11日 18点01分
回复 QQ361408996 : DataSource1的dataset设置为adotable1可以直接显示出表里的内容啊但是换成adoquery就不能显示查询的数据 adoquery就不能显示查询的数据
2015年01月12日 02点01分
level 7
加我给你看看
图片来自:cushaw95的百度相册
2015年01月12日 05点01分 9
level 7
自顶
2015年01月12日 09点01分 10
level 6
既然两段代码一样的,你在第二段代码找个地方
showmessage(form1.Edit1.Text);
2015年01月12日 16点01分 12
另外vcl设定你得去看看是不是一样。
2015年01月12日 16点01分
1