各位老大,我从数据库中读出数据,把“姓名”显示出来,然后点击点击姓名就可以查看具体的内容,我做的这一个只将“姓名”显示出来,但是具体的在点击之后出现了问题:错误是“[Warning] Unit1.pas(96): Variable 'page2' might not have been initialized”,什么地方错了,请教各位大侠,我是学asp的,现在开始学习delphi,希望大家多帮小弟,感激不尽:
procedure TWebModule1.WebModule1showwebAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
page:tstringlist;
data:string;
begin
page:=tstringlist.Create;
table1.active:=true;
try
with page do
begin
add('<html>');
add('<head>');
add('<title>处理程序</title>');
add('</head>');
add('<body>');
with table1 do
begin
first;
while not eof do begin
data:=fieldbyname('name').asstring;
add('<a href="http://127.0.0.1/scripts/project1.exe/detail?name='+data+'">'+data+'</a></p>');
next;
end;
end;
add('</body>');
add('</html>');
end;
response.Content:=page.Text;
finally
table1.active:=false;
page.Free;
end; end;
procedure TWebModule1.WebModule1showdetailAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
quynm:string;
page2:tstringlist; begin
try
page2:=tstringlist.Create;
quynm:=request.queryfields.Values['name'];
with table1 do
begin
active:=true;
if table1.Locate('name',quynm,[locaseinsensitive]) then
begin
with page2 do
begin
add('<html>');
add('<head>');
add('<title>结果</title>');
add('</head>');
add('<body>');
add(table1.Fields[0].asstring+'的资料如下:');
add('姓名为:'+table1.Fields[1].asstring);
add('学号为:'+table1.Fields[2].asstring);
add('</body>');
add('</html>');
end;
end;
end;
response.Content:=page2.text;
finally
table1.Active:=false;
page2.Free;
end;
end;
procedure TWebModule1.WebModule1showwebAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
page:tstringlist;
data:string;
begin
page:=tstringlist.Create;
table1.active:=true;
try
with page do
begin
add('<html>');
add('<head>');
add('<title>处理程序</title>');
add('</head>');
add('<body>');
with table1 do
begin
first;
while not eof do begin
data:=fieldbyname('name').asstring;
add('<a href="http://127.0.0.1/scripts/project1.exe/detail?name='+data+'">'+data+'</a></p>');
next;
end;
end;
add('</body>');
add('</html>');
end;
response.Content:=page.Text;
finally
table1.active:=false;
page.Free;
end; end;
procedure TWebModule1.WebModule1showdetailAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
quynm:string;
page2:tstringlist; begin
try
page2:=tstringlist.Create;
quynm:=request.queryfields.Values['name'];
with table1 do
begin
active:=true;
if table1.Locate('name',quynm,[locaseinsensitive]) then
begin
with page2 do
begin
add('<html>');
add('<head>');
add('<title>结果</title>');
add('</head>');
add('<body>');
add(table1.Fields[0].asstring+'的资料如下:');
add('姓名为:'+table1.Fields[1].asstring);
add('学号为:'+table1.Fields[2].asstring);
add('</body>');
add('</html>');
end;
end;
end;
response.Content:=page2.text;
finally
table1.Active:=false;
page2.Free;
end;
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货