sql.Add('select GoodsName,TotalDepot,TotalMoney from T_DepotStart where GoodsType in (select top 100 percent Name from Goods_Category where Code like :a) and depot =:b order by GoodsCode');
parameters.ParamByName('a').Value:=ADOquery1.Fields[0].AsString+'%';
parameters.ParamByName('b').Value:=cbbWorkPlace.Text;
为什么这句话在Access中可以运行 在MSSQL中就要改成下面的形式。
sql.Add('select GoodsName,TotalDepot,TotalMoney from T_DepotStart where GoodsType in (select top 100 percent Name from Goods_Category where Code like :a) and depot ='+QuotedStr(cbbWorkPlace.Text)+' order by GoodsCode');
parameters.ParamByName('a').Value:=ADOquery1.Fields[0].AsString+'%';
//parameters.ParamByName('b').Value:=cbbWorkPlace.Text;
还有 parameters.ParamByName这个在MSSQL中是否可以用?
parameters.ParamByName('a').Value:=ADOquery1.Fields[0].AsString+'%';
parameters.ParamByName('b').Value:=cbbWorkPlace.Text;
为什么这句话在Access中可以运行 在MSSQL中就要改成下面的形式。
sql.Add('select GoodsName,TotalDepot,TotalMoney from T_DepotStart where GoodsType in (select top 100 percent Name from Goods_Category where Code like :a) and depot ='+QuotedStr(cbbWorkPlace.Text)+' order by GoodsCode');
parameters.ParamByName('a').Value:=ADOquery1.Fields[0].AsString+'%';
//parameters.ParamByName('b').Value:=cbbWorkPlace.Text;
还有 parameters.ParamByName这个在MSSQL中是否可以用?
首先cbbWorkPlace.Text这个值是不是为空
其次你可以把SQL输出一下,放到MSSQL中区执行下看看