你先确认一下数据库中sid和zm是什么类型的,如果是字符型的数据,你在拼接sql的时候就需要用''两个单引号将数据括起来,也就是说
Sql.Add('Select * from PCCC where SID='+PcStr+' and ZM='+ComboBox3.Text);
需要改成
Sql.Add('Select * from PCCC where SID='+quotedstr(PcStr)+' and ZM='+quotedstr(ComboBox3.Text));
或者改成
Sql.Add('Select * from PCCC where SID='''+PcStr+''' and ZM='''+ComboBox3.Text+'''');
但是假如我不修改数据库中的数据类型那么还可以实现吗?
那就要把
'Select * from PCCC where SID='''+PcStr+''' and ZM='''+ComboBox3.Text+''''
改成
'Select * from PCCC where SID='+PcStr+' and ZM='''+ComboBox3.Text+''''
而且PCstr这个变量要是文本(string)类型。
'Select * from PCCC where SID='+PcStr+' and ZM='+ComboBox3.Text);
SQL语句中,如果是字符型,则要多加一个单引号 ''
'Select * from PCCC where SID='''+PcStr+''' and ZM='''+ComboBox3.Text+''');
检查 ComboBox3.Text 之中是否用到了 a 变量;
如果用到了, a 必须赋值。