我在窗口a关闭时执行如下程序
if a.caption='a' then
begin
a.release;
Application.CreateForm(Ta,a);
a.qy1.close;
a.qy1.sql.clear;
a.qy1.sql.add('select * from a');
a.qy1.open;
a.datasource1.dataset:=qy1;
a.dbgrideh1.datasource:=a.datasource1;
a.show;
a.caption:='b';
end;
if a.caption='b' then
begin
a.release;
Application.CreateForm(Ta,a);
a.qy1.close;
a.qy1.sql.clear;
a.qy1.sql.add('select * from b');
a.qy1.open;
a.datasource1.dataset:=qy1;
a.dbgrideh1.datasource:=a.datasource1;
a.show;
end;目的是用这种方法在同一个窗口显示几屏结果.显示每问题,但是当用
with application.FindComponent('a') as tform do
begin
当选中的字段是STRING类型时
if (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftstring) then
showmessage('v');
end;时出现错误access violation at address 004284f0 in module 'scgl.exe'.read of address 00000010 如何解决
if a.caption='a' then
begin
a.release;
Application.CreateForm(Ta,a);
a.qy1.close;
a.qy1.sql.clear;
a.qy1.sql.add('select * from a');
a.qy1.open;
a.datasource1.dataset:=qy1;
a.dbgrideh1.datasource:=a.datasource1;
a.show;
a.caption:='b';
end;
if a.caption='b' then
begin
a.release;
Application.CreateForm(Ta,a);
a.qy1.close;
a.qy1.sql.clear;
a.qy1.sql.add('select * from b');
a.qy1.open;
a.datasource1.dataset:=qy1;
a.dbgrideh1.datasource:=a.datasource1;
a.show;
end;目的是用这种方法在同一个窗口显示几屏结果.显示每问题,但是当用
with application.FindComponent('a') as tform do
begin
当选中的字段是STRING类型时
if (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftstring) then
showmessage('v');
end;时出现错误access violation at address 004284f0 in module 'scgl.exe'.read of address 00000010 如何解决
YourForm = TYourForm.Create( Nil );
2、释放窗口最好使用Free函数,而不是更底层的Release!!!
YourForm.Free;
3、你的代码中有很多地方是可以共用的,没有必要重复写!!!
按照你写的区别就在SQL语句上,你完全可以把它抽象出来!!!
右键菜单执行
if (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftstring) then
showmessage('v');
代码
end;时就出现错误access violation at address 004284f0 in module 'scgl.exe'.read of address 00000010
不用这个方法怎样实现窗口在关闭时连续三次显示不同结果
sql语句怎么抽象呢 请赐教