(200分)如何使用Delphi开发带有可视控件(如:DBGrid)的dll,供ASP调用,ASP调用此DLL时,要显示可视控件,即在网页中显示DBGrid等D

  • 主题发起人 主题发起人 shiyangking
  • 开始时间 开始时间
S

shiyangking

Unregistered / Unconfirmed
GUEST, unregistred user!
(200分)如何使用Delphi开发带有可视控件(如:DBGrid)的dll,供ASP调用,ASP调用此DLL时,要显示可视控件,即在网页中显示DBGrid等Delphi控件, (200分)<br />
代码:
[h1]如何使用Delphi开发带有可视控件(如:DBGrid)的dll,供ASP调用[/h1]
 
File->New->Other->ActiveX->ActiveForm
 
ASP调用此DLL时,要显示可视控件,即在网页中显示DBGrid等Delphi控件,
最好有源代码,在下对Delphi了解不深
 
ActiveForm能做到吗?ASP的服务端,和ACTIVEform的客户端能这么简单统一吗?
 
activeform可以
 
File->New->Other->ActiveX->ActiveForm()
unit AdoPage;

{$WARN SYMBOL_PLATFORM OFF}

interface

uses
ComObj, Classes,adodb, ActiveX, AspTlb, PadoPage_TLB, StdVcl, SysUtils, AdoDataModule;


type
TAdoPage = class(TASPObject, IAdoPage)
private
fadodm:TDataModule1;


protected
procedure OnEndPage
safecall;
procedure OnStartPage(const AScriptingContext: IUnknown)
safecall;
procedure getpage(const Pconnandsgl: WideString)
safecall;
procedure addnew(const Pconnandsgl: WideString
addid: SYSINT;
const addname: WideString)
safecall;
procedure delelist
safecall;
procedure dele(const testid: WideString)
safecall;
public
procedure initialize;override;
destructor destroy;override;





end;

implementation

uses ComServ,forms;

destructor Tadopage.destroy;
begin
inherited;
fadodm.Destroy;

end;
procedure Tadopage.initialize;
begin
inherited;


end;



procedure TAdoPage.OnEndPage;
begin
inherited OnEndPage;
end;

procedure TAdoPage.OnStartPage(const AScriptingContext: IUnknown);
begin
inherited OnStartPage(AScriptingContext);
end;

procedure TAdoPage.getpage(const Pconnandsgl: WideString);
var
i:integer;
rs:_recordset;
begin
//syform.Show;
response.Write('<hr>');
response.Write('成功');
response.Write('</hr>');
fadodm:=TDataModule1.Create(forms.application);
fadodm.adoconnection1.ConnectionString:=Pconnandsgl;
response.Write(fadodm.adoconnection1.ConnectionString);
{fadodm.adoconnection1.ConnectionString:='Provider=MSDASQL.1;Persist Security Info=False;Data Source=wage';
}
fadodm.ADOQuery1.Connection:=fadodm.adoconnection1;
fadodm.adoquery1.SQL.Add('select * from test');
fadodm.adoquery1.Active:=True;
fadodm.adoquery1.open;
//fadodm.ADODataSet1.Recordset:=fadodm.adoquery1.Recordset;
//fadodm.ADODataSet1.Active:=True;
//fadodm.ADODataSet1.Open;

response.write('<p></p>');
response.Write('<form>');
response.write('<table width="738" border="1" cellpadding="1" cellspacing="1" bordercolorlight="#000000" bordercolordark="#FFFFFF" height="30" align="center">');
response.write('<tr valign="middle" align="center" bgcolor="#DDDDDD">');
for I:=0 to fadodm.adoquery1.fields.count-1 do
response.write('<td width="98" height="30"><div align="center"><font size="-1">'+fadodm.adoquery1.fields.fieldname+'</font></div></td>');

response.write('</tr>');



with fadodm.adoquery1 do

while (not EOF ) do
begin
response.write(' <tr valign="middle" align="center"> ');
for i:=0 to fields.count-1 do
response.write('<td height="30" width="112"><div align="center"></div><div align="center"><input type="text" name="'+fields.fieldname+fields[0].asstring+'" value="'+fields.asstring+'"></div></td> ');
//response.write('<input type="hidden" name="hidden'+fields.fieldname+fields[0].asstring+'">');
response.write('</tr>');

next;

end;

response.write('</table>');
response.write('</form>');
//fadodm.adoquery1.Active:=false;
fadodm.adoquery1.close;
fadodm.adoconnection1.Close;

end;


procedure TAdoPage.addnew(const Pconnandsgl: WideString
addid: SYSINT;
const addname: WideString);
begin
fadodm:=TDataModule1.Create(forms.application);
fadodm.adoconnection1.ConnectionString:=Pconnandsgl;
fadodm.ADOQuery1.Connection:=fadodm.adoconnection1;
fadodm.adoquery1.SQL.Clear;
fadodm.adoquery1.SQL.Add('insert into test(testid,testname) values(:s1,:s2)');
//adoquery1.Active:=True;
fadodm.adoquery1.Parameters.ParamByName('s1').Value:=addid;
fadodm.adoquery1.Parameters.ParamByName('s2').Value:=addname;
fadodm.adoquery1.ExecSQL;
fadodm.adoquery1.close;
fadodm.adoconnection1.Close

end;

procedure TAdoPage.delelist;


begin
fadodm:=TDataModule1.Create(forms.application);
fadodm.adoconnection1.ConnectionString:='Provider=MSDASQL.1;Persist Security Info=False;Data Source=wage';
fadodm.ADOQuery1.Connection:=fadodm.adoconnection1;
fadodm.adoquery1.SQL.Add('select * from test');
fadodm.adoquery1.Active:=True;
fadodm.adoquery1.open;


with fadodm.adoquery1 do

while (not EOF ) do
begin


response.write('<option value="'+fields[0].asstring+'">'+fields[1].asstring+'</option>');
//response.write('<input type="hidden" name="hidden'+fields.fieldname+fields[0].asstring+'">');


next;

end;


fadodm.adoquery1.close;
fadodm.adoconnection1.Close;
end;

procedure TAdoPage.dele(const testid: WideString);
begin
fadodm:=TDataModule1.Create(forms.application);
fadodm.adoconnection1.ConnectionString:='Provider=MSDASQL.1;Persist Security Info=False;Data Source=wage';
fadodm.ADOQuery1.Connection:=fadodm.adoconnection1;
fadodm.adoquery1.SQL.Clear;
fadodm.adoquery1.SQL.Add('delete from test where testid=:s1');
//adoquery1.Active:=True;
fadodm.adoquery1.Parameters.ParamByName('s1').Value:=testid;
//adoquery1.Parameters.ParamByName('s2').Value:='试验成功';
fadodm.adoquery1.ExecSQL;

fadodm.adoquery1.close;
fadodm.adoconnection1.Close;
end;

initialization
TAutoObjectFactory.Create(ComServer, TAdoPage, Class_AdoPage,
ciMultiInstance, tmApartment);
end.

<HTML>
<H1>
Delphi 6 ActiveX Test Page
</H1>
<p>
You should see your Delphi 6 forms or controls embedded in the form below.
<HR>
<center><P>
<OBJECT classid="clsid:84854FB5-1EC8-4ADB-B112-BD5330510005" codebase="http://IT66/PadoPage.ocx#version=1,0,0,0" width="690" height="455" align="center" hspace="0" vspace="0" VIEWASTEXT>
</OBJECT>
</HTML>
 
接受答案了.
 

Similar threads

D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
875
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部