JS 下 System.Data.Connection V1

// Public
// ----------------------------------------------------------------
// Name   Begin  Modifiy  Description
// Connection  2005-3-21 2005-3-21 System.Data.Connection 对象
function System.Data.Connection()
{
 this.Connection;
 this.ConnectionString;
 this.State = -1;
 this.CommandText;
 this.CommandType = CommandType.Text;
 this.RecordsAffected = 0;
 // Private
 // ----------------------------------------------------------------
 // Name   Begin  Modifiy  Description
 // IsConnection  2005-1-28 2005-1-28 检查 this.Connection 对象
 this.IsConnection = function()
 {
  if ( this.State == -1 )
  {
   this.Connection = Server.CreateObject("ADODB.Connection");
   this.CursorLocation = adUseClient
   this.State = 0;
  }
  if ( this.State == 0)
  {
   try
   {
    this.Connection.Open(this.ConnectionString);
    this.State = 1;
   }
   catch(e)
   {
    new System.Exception("连接失败! "+ e.description)
   }
  }
  return( this.State );
 }
 // Public
 // ----------------------------------------------------------------
 // Name   Begin  Modifiy  Description
 // ExecuteNonQuery 2005-1-28 2005-1-28 针对 Connection 执行 SQL 语句并返回受影响的行数
 this.ExecuteNonQuery = function (CommandText, CommandType)
 {
  this.CheckCommandText(CommandText);
  this.CheckCommandType(CommandType);
  this.IsConnection();
  this.Connection.Execute(this.CommandText, this.RecordsAffected, this.CommandType + adExecuteNoRecords);
  return( this.RecordsAffected );
 }
 // Public
 // ----------------------------------------------------------------
 // Name   Begin  Modifiy  Description
 // ExecuteReader 2005-1-28 2005-1-28 将 CommandText 发送到 Connection 并生成一个 DataReader。
 this.ExecuteReader = function (CommandText, CommandType)
 {
  this.CheckCommandText(CommandText);
  this.CheckCommandType(CommandType);
  this.IsConnection();
  return( this.Connection.Execute(this.CommandText, this.RecordsAffected, this.CommandType) );
 }
 // Public
 // ----------------------------------------------------------------
 // Name   Begin  Modifiy  Description
 // ExecuteScalar 2005-1-28 2005-1-28 执行查询,并返回查询所返回的结果集中第一行的第一列。忽略额外的列或行。
 this.ExecuteScalar = function (CommandText, CommandType)
 {
  return( this.ExecuteReader(CommandText, CommandType)(0) );
 }
 // Public
 // ----------------------------------------------------------------
 // Name   Begin  Modifiy  Description
 // ExecuteXmlReader 2005-1-28 2005-1-28 将 CommandText 发送到 Connection 并生成一个 XmlReader 对象。
 this.ExecuteXmlReader = function (CommandText, CommandType)
 {
  var Stream = Server.CreateObject("ADODB.Stream");
  this.ExecuteReader(CommandText, CommandType).Save(Stream, adPersistXML);
  return( Stream.ReadText(-1) ); // var adReadAll = -1

 }
 // Private
 // ----------------------------------------------------------------
 // Name   Begin  Modifiy  Description
 // CheckCommandText 2005-1-28 2005-1-28 检查 CommandText
 this.CheckCommandText = function(CommandText)
 {
  if ( !Utility.IsEmpty(CommandText) ) this.CommandText = CommandText;
 }
 // Private
 // ----------------------------------------------------------------
 // Name   Begin  Modifiy  Description
 // CheckCommandType 2005-1-28 2005-1-28 检查 CommandType
 this.CheckCommandType = function(CommandType)
 {
  if ( !Utility.IsEmpty(CommandType) ) this.CommandType = CommandType;
 }
 // Public
 // ----------------------------------------------------------------
 // Name   Begin  Modifiy  Description
 // Close  2005-1-28 2005-1-28 关闭 Connection 对象
 this.Close = function()
 {
  this.Connection.Close();
 }
 // Public
 // ----------------------------------------------------------------
 // Name   Begin  Modifiy  Description
 // Dispose  2005-3-18 2005-3-18 销毁 Connection 对象
 this.Dispose = function()
 {
  this.Close();
  this.Connection = null;
 }
 // Public
 // ----------------------------------------------------------------
 // Name   Begin  Modifiy  Description
 // toString  2005-3-21 2005-3-21 获取此实例的 String 表示形式
 this.toString = function()
 {
  return( "System.Data.Connection" );
 }
 // Private
 // ----------------------------------------------------------------
 // Name   Begin  Modifiy  Description
 // ctor   2005-3-21 2005-3-21 重载支持
 this.ctor = function(arguments)
 {
  this.ConnectionString = ( !Utility.IsEmpty(arguments[0]) && typeof(arguments[0]) == "string" ) ? arguments[0] : Setup.AppSettings["ConnectionString"];
 }
 // Private
 // ----------------------------------------------------------------
 // Name   Begin  Modifiy  Description
 // Call ctor()  2005-3-21 2005-3-21 调用重载
 this.ctor(arguments);
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值