Qr1.Close;
Qr1.UnPrepare;
Qr1.SQL.Clear;
Qr1.SQL.Append('select sfb05 from sfb_file where sfb01=:sfb01');
Qr1.ParamByName('sfb01').AsString := 'MS1C2CR002';
Qr1.Prepare;
Qr1.Open;
Item := Qr1.FieldByName('sfb05').AsString;
Qr2.Close;
Qr2.UnPrepare;
Qr2.SQL.Clear;
// Qr2.SQL.Append('select bma05 from bma_file where bma01=' + #39 + item + #39);
Qr2.SQL.Append('select bma05 from bma_file where bma01=:bma01');
Qr2.ParamByName('bma01').AsString := Item;
Qr2.Prepare;
Qr2.Open;
PCBA:=Qr2.FieldByName('bma05').AsString);
end;1.在上面的语句中为什么ITEM有值,而PCBA=''
2.但是用引去的// Qr2.SQL.Append('select bma05 from bma_file where bma01=' + #39 + item + #39);为什么PCBA有值呢在DB中PCBA确实有值的呀,
pcba:=xxxx if qr1.recordcount>0 then
xxxxx
你使用
Qr2.SQL.Append('select bma05 from bma_file where bma01=''' + item +'''');
或
Qr2.SQL.Append('select bma05 from bma_file where bma01=' + item);如果第一个方法不行,就使用第二个,应该没问题。
Qr2.SQL.Append('select bma05 from bma_file where bma01=' + #39 + item + #39);
和用
Qr2.SQL.Append('select bma05 from bma_file where bma01=:bma01');
Qr2.ParamByName('bma01').AsString := Item;
是一样的
这个DB与其他DB的不同之处是;这个DB用CHAR型,而其他DB用VARCHAR型
Qr2.SQL.Append('select bma05 from bma_file where bma01=''' + item +'''');这样就行了
Qr2.Close;
Qr2.UnPrepare;
Qr2.SQL.Clear;
Qr2.SQL.Append('select bma05 from bma_file where bma01=:bma01');
Qr2.ParamByName('bma01').AsString := Item;
Qr2.Prepare;
Qr2.Open;
PCBA:=Qr2.FieldByName('bma05').AsString;
改为 Qr2.Close;
Qr2.UnPrepare;
Qr2.SQL.Clear;
Qr2.SQL.Append('select bma05 from bma_file where bma01='''+Item+'''');
Qr2.Prepare;
Qr2.Open;
PCBA:=Qr2.FieldByName('bma05').AsString;不能用parambyname应该与你的数据类型有关