procedure Tform1.FormCreate(Sender: TObject);
var
mc, s, wherestr,gjmc: string;
begin
listbox1.clear;
if ff = 3 then
mc := form3.stringgrid1.cells[1, ggrow];
//wherestr := 'gjmc=''' + mc + '''';
with OraQuery1 do
begin
try
Close;
SQL.Text:='Select gjgg from GJGGDM where gjmc='''+mc+'''';
Open;
while not eof do
begin
s := fieldbyname('gjgg').asstring;
if s <> '' then
listbox1.items.add(s);
next;
end;
except
messagedlg('没有相应的工具!', mtinformation, [mbok], 0);
end;
Close;
end;
end;mc:=form3.stringgrid1.cells[1, ggrow] 这个串的写法有问题吗?是不是无法得到form3的stringgrid的单元格的内容?导致的问题?
var
mc, s, wherestr,gjmc: string;
begin
listbox1.clear;
if ff = 3 then
mc := form3.stringgrid1.cells[1, ggrow];
//wherestr := 'gjmc=''' + mc + '''';
with OraQuery1 do
begin
try
Close;
SQL.Text:='Select gjgg from GJGGDM where gjmc='''+mc+'''';
Open;
while not eof do
begin
s := fieldbyname('gjgg').asstring;
if s <> '' then
listbox1.items.add(s);
next;
end;
except
messagedlg('没有相应的工具!', mtinformation, [mbok], 0);
end;
Close;
end;
end;mc:=form3.stringgrid1.cells[1, ggrow] 这个串的写法有问题吗?是不是无法得到form3的stringgrid的单元格的内容?导致的问题?
begin
StringGrid1.Cells[1,1]:='kkkkk';
edit1.Text:=StringGrid1.Cells[1,1]; //结果是edit1.text:='kkkkk';
end;
把涉及OraQuery1控件的语句写到窗口show事件或者active中就可以了。
再一个:'Select gjgg from GJGGDM where gjmc='''+mc+'''';可能写法有问题,该下引号试试,我忘记怎么写了。
Close;
SQL.Text:='Select gjgg from GJGGDM where gjmc='''+mc+'''';
Open;
first;//是不是要加个
while not eof do
begin
s := fieldbyname('gjgg').asstring;
if s <> '' then
listbox1.items.add(s);
next;
end;
except
messagedlg('没有相应的工具!', mtinformation, [mbok], 0);
end;
我的查询条件是从stringgrid的一个Cells里面取的字符串,但是在sql语句里面不正确呀,应该怎么写呢?