堆栈问题。(20分)

  • 主题发起人 主题发起人 yunxi126
  • 开始时间 开始时间
Y

yunxi126

Unregistered / Unconfirmed
GUEST, unregistred user!
在数据库的"expressions"字段中,是字段“one”和字段“two”(例如:expressions字段值为:one + two)结果在字段"three"中显示
字段顺序one(float),two(float),expressions(string),three(float)
one two expressions three
1.25 2.35 one+two (结果)

小弟现在没分,等高手给出答案后献上全部分。
 
select one, two, 'one+two' as expressions, one+two as three from 表名
 
这样太简单了。 要是用户临时做改变,改成"/"呢。而且记录很多的时候怎么办。
 
你是想用公式吧,那就自定义一个函数,就+-*/四种情况吧?.
 
是,,但不知如何做,有代码的高手贴一下。
 
还有括号
 
沉了。 自已顶起来。
 
怎么没人来看一下啊。
 
procedure TForm1.Button1Click(Sender: TObject);
var s:string;
begin
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select one, two,');
s:=quotedstr('one'+edit1.Text+'two')+' as expressions,';
ADOQuery1.SQL.Add(s);
ADOQuery1.SQL.Add('one'+edit1.text+'two'+' as three from text');
adoquery1.Active:=true;
adoquery1.Open;

showmessage('该查询语句为:'+adoquery1.SQL.Strings[0]+adoquery1.SQL.Strings[1]+adoquery1.SQL.Strings[2]);
end;

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if (key<>'+') and (key<>'-') and (key<>'*') and (key<>'/') then
key:=#13;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
if edit1.Text<>'' then
button1.Enabled:=true
else
button1.Enabled:=false;
end;
 
用Delphi 7 做的,
使用了几种控件:ADOQuery,Edit,button,timer,datasource,dbgrid
设置好连接,就可以看到效果了。
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
317
import
I
S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
927
SUNSTONE的Delphi笔记
S
后退
顶部