delphi.net在ASP.net中使用数据模块DM
1,project->Add->Other->加入一个Global页面
2,在Global页面中放sqlConnection sqlCommand并设好他们的连接
3,在接口处注销strict private
接口的代码如下
---------------------------
type
TGlobal = class(System.Web.HttpApplication)
{$REGION 'Designer Managed Code'}
// strict private//这行必需注销,其它的行不理它
sqlCNN: System.Data.SqlClient.SqlConnection;
SqlCMD: System.Data.SqlClient.SqlCommand;
procedure InitializeComponent;
{$ENDREGION}
strict protected
procedure Application_Start(sender: System.Object; e: EventArgs);
procedure Session_Start(sender: System.Object; e: EventArgs);
procedure Application_BeginRequest(sender: System.Object; e:
EventArgs);
procedure Application_EndRequest(sender: System.Object; e:
EventArgs);
procedure Application_AuthenticateRequest(sender: System.Object; e:
EventArgs);
procedure Application_Error(sender: System.Object; e: EventArgs);
procedure Session_End(sender: System.Object; e: EventArgs);
procedure Application_End(sender: System.Object; e: EventArgs);
private
{ Private Declarations }
public
constructor Create;
end;
var DM:TGlobal;//在这里要申明一个类变量,以后就会这个变量来访问这个类
implementation
------------------------------------
4,申本类变量,如implementation上面那一行
5,其它页面引用这个单元,引用单元要引用System.Data.SqlClient
要不然,就叫不出DM模块中数据组件的方法了
-------------------------------------------
DoubleCat
2,在Global页面中放sqlConnection sqlCommand并设好他们的连接
3,在接口处注销strict private
接口的代码如下
---------------------------
type
TGlobal = class(System.Web.HttpApplication)
{$REGION 'Designer Managed Code'}
// strict private//这行必需注销,其它的行不理它
sqlCNN: System.Data.SqlClient.SqlConnection;
SqlCMD: System.Data.SqlClient.SqlCommand;
procedure InitializeComponent;
{$ENDREGION}
strict protected
procedure Application_Start(sender: System.Object; e: EventArgs);
procedure Session_Start(sender: System.Object; e: EventArgs);
procedure Application_BeginRequest(sender: System.Object; e:
EventArgs);
procedure Application_EndRequest(sender: System.Object; e:
EventArgs);
procedure Application_AuthenticateRequest(sender: System.Object; e:
EventArgs);
procedure Application_Error(sender: System.Object; e: EventArgs);
procedure Session_End(sender: System.Object; e: EventArgs);
procedure Application_End(sender: System.Object; e: EventArgs);
private
{ Private Declarations }
public
constructor Create;
end;
var DM:TGlobal;//在这里要申明一个类变量,以后就会这个变量来访问这个类
implementation
------------------------------------
4,申本类变量,如implementation上面那一行
5,其它页面引用这个单元,引用单元要引用System.Data.SqlClient
要不然,就叫不出DM模块中数据组件的方法了
-------------------------------------------
DoubleCat