简单问题:DBGrid显示数据
我在窗体中添加了一个DBGrid1和一个DataSource1和一个qryGetValue(TADOQuery),和一个ADOConnection
DBGrid1的DataSource设置为DataSource1
DataSource1的DataSet设置为qryGetValue
qryGetValue的连接字符串设置为ADOConnection;
////////////////////////以上所有的设置都没问题的
查询SQL语句的代码如下
with qryGetValue do
begin
close;
SQL.Clear;
SQL.Add('select b.name as 零售商,c.name as 报刊,a.baseDiscount as 基本折扣,a.TransDiscount as 运输折扣, ');
SQL.Add('a.AllDiscount as 合计折扣,d.name as 印点,e.name as 运输线路,f.name as 运输方式,');
SQL.Add('a.saleDiscount as 销售折扣,a.proofID as 票签 ');
SQL.Add('from t_code_retailer_newpaper as a ');
SQL.Add('join t_code_Retailer as b on a.retailerID = b.ID ');
SQL.Add('join t_code_newPaper as c on a.paperid = c.id ');
SQL.Add('join t_code_printPoint as d on a.printID = d.id');
SQL.Add('join t_code_GoodsLine as e on a.transLinesID = e.id');
SQL.Add('join t_code_TransType as f on a.transType = f.id');
SQL.Add('where b.code = :id');
Prepared:= true;
Parameters.ParamByName('id').Value := '2-001';
Active := True;
open;
ExecSQL;
end;
我用单步跟踪之后发现DBGrid中显示的数据为空,我把SQL语句栲到ms sql的查询分析器里执行
是有结果的,我不知道我的代码那里出现漏洞了,请各位指点一下