我能用这样的代码么?
procedure TForm5.Button1Click(Sender: TObject);
begin
adotable1.close;
if radiobutton1.checked then
adotable1.sql.clear;
adotable1.sql.add('select*from 表2 where bianhao=:bianhao');
adotable1.parameters.parambyname('bianhao').value:=trim(edit1.text);
if edit1.text=''then
begin
application.messagebox('请输入商品编号','提示信息',64);
edit1.setfocus;
exit;
end;
adotable1.open;
end;
但运行的时候,错误指在adotable1.sql.clear;
希望大侠们帮帮忙。。小弟是初学者
procedure TForm5.Button1Click(Sender: TObject);
begin
adotable1.close;
if radiobutton1.checked then
adotable1.sql.clear;
adotable1.sql.add('select*from 表2 where bianhao=:bianhao');
adotable1.parameters.parambyname('bianhao').value:=trim(edit1.text);
if edit1.text=''then
begin
application.messagebox('请输入商品编号','提示信息',64);
edit1.setfocus;
exit;
end;
adotable1.open;
end;
但运行的时候,错误指在adotable1.sql.clear;
希望大侠们帮帮忙。。小弟是初学者
解决方案 »
- 求解决!
- 这个句子中加个变量怎么写?
- 请教delphi用一个按钮实现启动和暂停
- 把用户的检索要求提交到搜索引擎上
- 数据集中,用户删除某条纪录时,如何判断该条纪录是刚刚添加的纪录,而不必更新数据库?
- 做数据库运用软件,提供字段的筛选和记录的筛选.大家给客户的灵活性有多大,什么是你的底线?什么是客户的底线?
- 怎么将RadioButtonn分组啊?up有分
- win2000下对设备进行操作为什么报previllege instruction?
- 急!!!如何实现数据的统计??(用query中的sum()该如何实现??)急!!!!
- delphi 5.0 装后不能运行,急急急!!!!!
- 如何修改DBGrid中的数据,delphi
- 大家看看现在的RIA开发,赶上了C/S的功能了把 (我最近做的一个程序)
adotable1.sql.add('select * from 表2 where bianhao=:bianhao');
select*from 连在一块了
如果错误仍在:改在Adoquery控件试试
adotable1.sql.Text :='select * from 表2 where bianhao=:bianhao';
1.adotable是没有SQL属性的,只能设置Tablename直接关联表,要用SQL就改成adoquery吧
2.select*from 注意空格select * from
3.adotable1.close;最好放在if radiobutton1.checked then里面
4.if radiobutton1.checked then要加上begin...end
5.if edit1.text='' then判断放在if radiobutton1.checked then这个判断外面最终代码:
procedure TForm5.Button1Click(Sender: TObject);
begin
if edit1.text=''then
begin
application.messagebox('请输入商品编号','提示信息',64);
edit1.setfocus;
exit;
end
else if radiobutton1.checked then
begin
with adoquery1 do
begin
close;
sql.clear;
sql.add('select * from 表2 where bianhao=:bianhao');
parameters.parambyname('bianhao').value:=trim(edit1.text);
open;
end;
end;
end;