汪
汪汪汪汪
Unregistered / Unconfirmed
GUEST, unregistred user!
我用delphi写了个自动化对象,实现两个接口,代码如下:
procedure Tmethodobject.getname(out myname: OleVariant);
begin
myname:='hello';
end;
procedure Tmethodobject.insert(var mydata: OleVariant);
var query1:Tquery;
database1:Tdatabase;
begin
query1:=Tquery.Create(nil);
database1:=Tdatabase.Create(nil);
database1.AliasName :='test';
database1.DatabaseName :='test';
database1.LoginPrompt :=false;
database1.Params.Clear
database1.Params.Add('user name=sa');
database1.Params.Add('password=');
database1.Connected :=true;
query1.DatabaseName:='test';
with query1 do
begin
close;
sql.clear;
sql.add('insert into test values('''+mydata[0]+''',
'''+mydata[1]+''')');
execsql;
end;
query1.close;
database1.CloseDataSets
query1.Free;
database1.Free;
end;
编译通过,并注册了dll,我要在asp中调用这两个接口
asp的代码如下:
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
dim mydata(2),me1
mydata(0)="121"
mydata(1)="121"
set myobject=server.CreateObject("wangwang.methodobject") '创建对象成功
myobject.getname me1 '此方法调用也成功
response.write me1
myobject.insert mydata '但是这个方法调用始终不成功
set myobject=nothing
%>
<P>&nbsp;</P>
</BODY>
</HTML>
数据库在sql server上,不知道我哪里写错了,望大侠就我阿。。
procedure Tmethodobject.getname(out myname: OleVariant);
begin
myname:='hello';
end;
procedure Tmethodobject.insert(var mydata: OleVariant);
var query1:Tquery;
database1:Tdatabase;
begin
query1:=Tquery.Create(nil);
database1:=Tdatabase.Create(nil);
database1.AliasName :='test';
database1.DatabaseName :='test';
database1.LoginPrompt :=false;
database1.Params.Clear
database1.Params.Add('user name=sa');
database1.Params.Add('password=');
database1.Connected :=true;
query1.DatabaseName:='test';
with query1 do
begin
close;
sql.clear;
sql.add('insert into test values('''+mydata[0]+''',
'''+mydata[1]+''')');
execsql;
end;
query1.close;
database1.CloseDataSets
query1.Free;
database1.Free;
end;
编译通过,并注册了dll,我要在asp中调用这两个接口
asp的代码如下:
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
dim mydata(2),me1
mydata(0)="121"
mydata(1)="121"
set myobject=server.CreateObject("wangwang.methodobject") '创建对象成功
myobject.getname me1 '此方法调用也成功
response.write me1
myobject.insert mydata '但是这个方法调用始终不成功
set myobject=nothing
%>
<P>&nbsp;</P>
</BODY>
</HTML>
数据库在sql server上,不知道我哪里写错了,望大侠就我阿。。