JScript 模拟 ADO.NET 基本对象

<%@ Language="JScript" CODEPAGE = "936" %>
<!-- METADATA TYPE="TypeLib" UUID="00000200-0000-0010-8000-00AA006D2EA4" -->
<%
/*
ADO.NET Module For ASP

Error:
err.name
err.message
err.description

*/
// OLEDBConnection Class
function OLEDBConnection(strConnection)
{

  this.ConnectionString = strConnection;
  this.Connection = Server.CreateObject("ADODB.Connection");
  this.Connection.ConnectionString = this.ConnectionString;

  this.Open = function()
  {
    try {
      this.Connection.ConnectionString = this.ConnectionString;
      this.Connection.Open();
    }   catch(err) {
      err.name = "Connection Open Error"
      Debug(err);
    }
  }

  this.Close = function()
  {
    try {
      this.Connection.Close;
    } catch(err) {
      err.name = "Connection Close Error"
      Debug(err);
    }
  }

// return this.Connection;
}


// OLEDBCommand Class
function OLEDBCommand(strCommandText, objConnection)
{
  this.CommandText = strCommandText;
  this.Connection = objConnection;
  this.Command = Server.CreateObject("ADODB.Command");
  this.Command.CommandType = 8; // adCmdUnknown
  this.Command.CommandText = this.CommandText;

  this.ExecuteReader = function()
  {
    try {
      this.Command.CommandText = this.CommandText;
      this.Command.ActiveConnection = this.Connection.Connection;
      return this.Command.Execute;
    } catch(err) {
      err.name = "ExecuteReader Error"
      Debug(err);
    }
  }

  this.ExecuteNonQuery = function()
  {
    try {
      this.Command.ActiveConnection = this.Connection;
      this.Command.Execute;
    } catch(err) {
      err.name = "ExecuteNonQuery Error"
      Debug(err);
    }
  }
// prototype: Parameters
  this.Parameters = function(strParametersName,strParametersValue)
  {

    this.Parameters.Name = strParametersName;
    this.Parameters.Value = strParametersValue;
    if ((this.Parameters.Name) && (this.Parameters.Value)) {
      this.Command.Parameters(this.Parameters.Name) = this.Parameters.Value;
    }
  }
// prototype: AddParameters
  this.CreateParameters = function(strParametersName, intParametersType, intParametersDirection, intParametersSize, strParametersValue)
  {
    this.Parameters.Name = strParametersName;
    this.Parameters.Type = intParametersType;
    this.Parameters.Direction = intParametersDirection;
    this.Parameters.Size = intParametersSize;
    this.Parameters.Value = strParametersValue;
    this.Command.Parameters.Append(this.Command.CreateParameter(this.Parameters.Name, this.Parameters.Type, this.Parameters.Direction, this.Parameters.Size, this.Parameters.Value));
  }

  function Debug(err)
  {
    Response.Write (err.name);
    Response.Write ("<br>")
    Response.Write (err.description);
    Response.End
  }
//  return this.Command
}
%>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值