adoquery1.close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select Password,Income from 职员 where Password='''+edit1.Text+'''');
adoquery1.Open;
Password:=trim(edit1.Text);
sleep(2000);
Income:=trim(edit2.Text);
这个是我现在的码,系统老是说Password,Income没有定义,这两个是我的数据库中字段的名称,请问高人给看一下,到底是怎么回事,望改正!
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select Password,Income from 职员 where Password='''+edit1.Text+'''');
adoquery1.Open;
Password:=trim(edit1.Text);
sleep(2000);
Income:=trim(edit2.Text);
这个是我现在的码,系统老是说Password,Income没有定义,这两个是我的数据库中字段的名称,请问高人给看一下,到底是怎么回事,望改正!
解决方案 »
- 请教 sztony 关于 利用 PGPOOL 替代DataSnap 解决方案
- 关于delphi7自动提示代码的问题
- 帮忙解释一下memodragvoer事件啊
- 转换问题
- 为什么我关闭A窗口去刷新B窗口的Adoquery时,数据更新不了,是不是存在什么缓存问题?
- 如何提供用户选择打印机的功能???????
- 如何设计一个类
- 我想新建一个不带表单的公共单元存储公共变量和函数,但interface到imtepmnet之间不会写请指教!谢谢!!!最好给个例子!!
- 如何实时获取网页中特定的内容和与之对应的数据?
- 强烈建议borland开发一个比windows方便得多、bug少得多的操作系统!!
- ActiveX自定义属性
- 对比文件的修改时间
sleep(2000);
Income:=trim(edit2.Text); 你这两句想要干嘛呢? 要么你声明一下变量,要么这两个你也别要了,我没看出来有什么用...
FieldByName('Income ').asstring:= trim(edt2.text);
或者是用 parameter 写 大概的意思是一样的
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select Password,Income from 职员 where Password='''+edit1.Text+'''');
adoquery1.Open;如果OK,说明数据库没有问题。而是下面语句的问题。
//补充定义
var
password,income: string;Password:=trim(edit1.Text);
// sleep(2000); //可以删除,并没有用处。
Income:=trim(edit2.Text);
adoquery1.SQL.Add('select Password,Income from 职员 where Password='''+edit1.Text+'''');
adoquery1.Open;
可以改为:
adoQuery1.SQL.Clear;
adoQuery1.SQL.Add(Format('select Password,Income from 职员 where Password=''%s''', [Edit1.Text]));
adoQuery1.Open;
adoquery1.SQL.Add('select Password,Income from 职员 where [Password]='''+edit1.Text+'''');
adoquery1.sql.close;
adoquery1.sql.clear;
adoquery1.SQL.Add('select Password,Income from 职员 where password=a and Income=b');
adoquery1.Parameters.ParamByName('a').Value:=trim(edt1.text);
adoquery1.Parameters.ParamByName('b').Value:=trim(edt2.text);
adoquery1.open;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select [Password],Income from 职员 where [Password]='''+edit1.Text+'''');
adoquery1.Open;
用SQL语句来修改吧
case Application.MessageBox('此为不可逆操作,确定要执行吗?', '提示',
MB_OKCANCEL + MB_ICONINFORMATION) of
IDOK:
begin
try
with FrmLogin do
begin
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('update ' + FrmChoice.ComboBox1.Text + ' set 失效=1 where 文件名称=:name');
ADOQuery1.Parameters.ParamByName('name').Value:=ComboBox1.Text;
ADOQuery1.ExecSQL;
end;
Application.MessageBox('设置成功!', '提示', MB_OK +
MB_ICONINFORMATION);
except
Application.MessageBox('未知错误!', '提示', MB_OK + MB_ICONSTOP);
Exit;
end;
end;
IDCANCEL:
begin
Exit;
end;
end;
password,income: string;
adoq.sql.text:='select f1,f2 from table where f1='+quotedstr(edit1.text);
adoq.open;出现很多个个单引号,会把人看晕的用参数,经常得不到你的结果,而且使得代码量大增.参数较多的时候,就用 format('selet f1,f2 from table where f1=%s and f2 =%s',[quotedstr(edit1.text),edit2.text]);