想实现:
按dbcombobox中的item a,b,c...时,对应DBGird中显示name项为a的所有数据!我是这么写的,但没用,为什么?
dbcomboboxchange()
begin
query1.close;
query1.clear;
query1.sql.add('select * from tableaaa where name='+dbcombobox1.text);
query1.open;
close;
按dbcombobox中的item a,b,c...时,对应DBGird中显示name项为a的所有数据!我是这么写的,但没用,为什么?
dbcomboboxchange()
begin
query1.close;
query1.clear;
query1.sql.add('select * from tableaaa where name='+dbcombobox1.text);
query1.open;
close;
begin
query1.close;
query1.clear;
query1.sql.add('select * from tableaaa where name='+quotedstr(dbcombobox1.text));
query1.open;
close;
begin
query1.close;
query1.clear;
query1.sql.add('select * from tableaaa where name='''+dbcombobox1.text+'''');
query1.open;
close;
连接是否一致?
begin
query1.close;
query1.sql.clear; //这里应该是SQL。CLEAR吧
query1.sql.add('select * from tableaaa where name='''
+trim(dbcombobox1.text)+'''');
query1.open;
close;
这样你试试