在table1中包含了3字段test1,test2,test3等
根据不同的条件,需要sql语言查询出不同的字段进行显示。实验方法:query1.sql.text:='select :test from table1';
case index_my of
1:query1.params[0].asString:='test1';
2:query1.params[0].asString:='test2';
3:query1.params[0].asString:='test3';
else showmessage('illegal');
end;
query1.open;
但是给出的出错提示是:类型不匹配。是因为参数不能是字符串么?还是因为我的使用错误?叩首请教
根据不同的条件,需要sql语言查询出不同的字段进行显示。实验方法:query1.sql.text:='select :test from table1';
case index_my of
1:query1.params[0].asString:='test1';
2:query1.params[0].asString:='test2';
3:query1.params[0].asString:='test3';
else showmessage('illegal');
end;
query1.open;
但是给出的出错提示是:类型不匹配。是因为参数不能是字符串么?还是因为我的使用错误?叩首请教
case index_my of
1:query1.params[0].Value:='test1';
2:query1.params[0].Value:='test2';
3:query1.params[0].Value:='test3';
else showmessage('illegal');
end;
query1.open;
query1.Close;如果还不行的话可以:
1、query1.sql.text一句前再加上Query1.Params.Clear;
2、或者将query1.params[0].asString改为:
query1.params[0].Value—————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————
这样做:
case index_my of
1:s:='test1';
2:s:='test2';
3:s:='test3';
else showmessage('illegal');
end;
query1.sql.text:='select '+ s +' from table1';
Query1.Open;
s:string;
//---------------------
query1.close;
query1.sql.clear;
case index_my of
1:s:='test1';
2:s:='test2';
3:s:='test3';
else showmessage('illegal');
end;
query1.sql.text:='select '+ s +' from table1';query1.open;