📄 recordset.htm
字号:
{ return this._objEventManager.unadvise(strEvent,nAdviseID); }
function _RS_getRecordSource()
{
if (this._rsRDS != null)
return this._rsRDS.recordset;
return null;
}
//function _RS_setRecordSource(rsADO) OR
function _RS_setRecordSource(strConn,strSQL)
{
if (typeof(strConn) == 'string')
{ // given a connect and SQL string
this._strConn = unescape(strConn);
return this.setSQLText(strSQL);
}
if (typeof(strConn) == 'object')
{ // given an ADO object
this._strConn = '';
this._strSQL = '';
if (this._rsRDS != null)
this._rsRDS.SourceRecordset = strConn;
else
{
this._rsADO = strConn;
this.open();
}
return true;
}
return false;
}
function _RS_open()
{
this._objEventManager.fireEvent(RS_ONBEFOREOPEN);
this._connect();
if (this._rsADO != null)
this._rsRDS.SourceRecordset = this._rsADO;
this._objEventManager.fireEvent(RS_ONAFTEROPEN);
}
function _RS_isOpen()
{
if (this._rsRDS != null)
{
if ((this._rsRDS.ReadyState == 2) || (this._rsRDS.ReadyState == 4))
return true;
}
return false;
}
function _RS_close()
{
this._rsRDS = null;
this._count = -1;
}
function _RS_getConnectString()
{
return this._strConn;
}
function _RS_getSQLText()
{
if (this._rsRDS != null)
return this._rsRDS.SQL;
else
return this._strSQL;
}
function _RS_setSQLText(strSQL)
{
if (typeof(strSQL) == 'string')
{
this._strSQL = strSQL;
if (this._rsRDS != null)
this._rsRDS.SQL = strSQL;
return true;
}
return false;
}
function _RS_requery()
{
if (this.isOpen())
{
this._rsRDS.Refresh();
this._count = -1;
}
}
function _RS_setBookmark(bookmark)
{
this._bookmark = bookmark;
if (this.isOpen() && this._bookmark > 0)
{
if (this._rsRDS.recordset.Supports(8192))
{ // supports bookmarks
this._rsRDS.recordset.Bookmark = this._bookmark;
}
else
{ // use AbsolutePosition
this._rsRDS.recordset.AbsolutePosition = this._bookmark * 1;
}
return true;
}
return false;
}
function _RS_getBookmark()
{
if (this.isOpen())
{
if (this._rsRDS.recordset.Supports(8192))
{ // supports bookmarks
return this._rsRDS.recordset.Bookmark;
}
else
{ // use AbsolutePosition
return this._rsRDS.recordset.AbsolutePosition;
}
}
return this._bookmark;
}
function _RS_isDHTMLAware()
{ return true; }
function _RS_getDHTMLDataSourceID()
{
if (this._rsRDS != null)
return (this.name + '_RDS');
return '';
}
function _RS__connect()
{
var strServer = 'http://' + document.domain;
var strRDS = '';
strRDS = strRDS + '<' + 'OBJECT classid=clsid:BD96C556-65A3-11D0-983A-00C04FC29E33 height=1 style="LEFT: 0px; TOP: 0px" width=1';
strRDS = strRDS + ' id=' + this.name + '_RDS>\n';
strRDS = strRDS + '<PARAM NAME="Server" VALUE="' + strServer + '">\n';
if (this._strConn != '')
strRDS = strRDS + '<PARAM NAME="Connect" VALUE="' + encodeHTMLQuotes(this._strConn) + '">\n';
if (this._strSQL != '')
strRDS = strRDS + '<PARAM NAME="SQL" VALUE="' + encodeHTMLQuotes(this._strSQL) + '">\n';
strRDS = strRDS + '</OBJECT>';
this._spanTag.innerHTML = strRDS;
this._rsRDS = document.all[this.name + '_RDS'];
this.fields = CreateFields(this._rsRDS);
this._rsRDS.onrowenter = _RS__onrowenter;
this._rsRDS.onrowexit = _RS__onrowexit;
this._rsRDS.ondatasetcomplete = _RS__ondatasetcomplete;
this._rsRDS.ondatasetchanged = _RS__ondatasetchanged;
this._bDSChanged = false;
this._bDSComplete = false;
this._count = -1;
return true;
}
function _RS__fireEvent(funcToFire,bUseEvent)
{
if ((typeof(bUseEvent) == 'boolean') && (bUseEvent))
{
var strRS = event.srcElement.id;
strRS = strRS.substring(0,strRS.length-4); // strip _RDS to get name
var _objRS = eval(strRS);
if (typeof(_objRS) == 'object')
{
if (funcToFire == RS_ONDATASETCOMPLETE)
{
_objRS._bDSComplete = true;
}
if (funcToFire == RS_ONDATASETCHANGED)
{
_objRS._syncBOFandEOF();
_objRS.fields = CreateFields(_objRS._rsRDS);
_objRS._bDSChanged = true;
}
if (funcToFire == RS_ONROWENTER)
{
if (_objRS._bFiringOnRowEnter)
return;
_objRS._bFiringOnRowEnter = true;
_objRS._syncBOFandEOF();
_objRS.fields = CreateFields(_objRS._rsRDS);
_objRS._bFiringOnRowEnter = false;
}
if (_objRS._objEventManager != null)
_objRS._objEventManager.fireEvent(funcToFire);
}
}
else
{ // fire recordset initFunc immediately
if (typeof(funcToFire) == 'string')
eval(funcToFire);
else if (typeof(funcToFire) == 'function')
funcToFire();
}
}
function _RS__ondatasetcomplete()
{ _RS__fireEvent(RS_ONDATASETCOMPLETE,true); }
function _RS__ondatasetchanged()
{ _RS__fireEvent(RS_ONDATASETCHANGED,true); }
function _RS__onrowenter()
{ _RS__fireEvent(RS_ONROWENTER,true); }
function _RS__onrowexit()
{ _RS__fireEvent(RS_ONROWEXIT,true); }
function _RS__isEmpty()
{ return (!this.isOpen() || (this.BOF && this.EOF)) }
function _RS__onbeforefuncinit(objRecordset)
{
objRecordset._objEventManager.adviseDefaultHandler(objRecordset.id,RS_ONBEFOREOPEN, true);
objRecordset._objEventManager.adviseDefaultHandler(objRecordset.id,RS_ONROWENTER, true);
objRecordset._objEventManager.adviseDefaultHandler(objRecordset.id,RS_ONROWEXIT, true);
objRecordset._objEventManager.adviseDefaultHandler(objRecordset.id,RS_ONDATASETCHANGED, true);
objRecordset._objEventManager.adviseDefaultHandler(objRecordset.id,RS_ONDATASETCOMPLETE, true);
objRecordset._objEventManager.adviseDefaultHandler(objRecordset.id,RS_ONBEFOREUPDATE, true);
objRecordset._objEventManager.adviseDefaultHandler(objRecordset.id,RS_ONAFTERUPDATE, true);
}
// ************************************************************************
// Fields Object
// ************************************************************************
function CreateFields(rsRDS)
{
if (typeof(rsRDS) == 'object' && rsRDS != null)
return new _Fields(rsRDS);
return null;
}
function _Fields(rsTag)
{
_Fields_Prototype();
this.rsTag = rsTag;
}
function _Fields_Prototype()
{
_Fields.prototype.getName = _FS_getName;
_Fields.prototype.getValue = _FS_getValue;
_Fields.prototype.setValue = _FS_setValue;
_Fields.prototype.getCount = _FS_getCount;
_Fields.prototype._isValid = _FS__isValid;
}
function _FS_getName(nIndex)
{
if (typeof(nIndex) == 'number' && nIndex >= 0 && nIndex < this.getCount())
{
fsTmp = this.rsTag.recordset.Fields;
return fsTmp(nIndex).name;
}
return '';
}
function _FS_getValue(field)
{
var r = '';
if (this._isValid() && (typeof(field) == 'number' || typeof(field) == 'string'))
{
fsTmp = this.rsTag.recordset.Fields;
r = fsTmp(field).value;
if (r == null)
r = '';
}
return r;
}
function _FS_setValue(field,value)
{
if ((typeof(field) == 'number' || typeof(field) == 'string') && typeof(value) != 'undefined')
{ // validate field as updatable
if (this._isValid)
{
fsTmp = this.rsTag.recordset.Fields;
var nAttributes = Number(fsTmp(field).Attributes);
if ((nAttributes & 4) || (nAttributes & 8))
{ // field may be updated, adFldUpdatable=4, adFldUnknownUpdatable=8
if (value == '' && (nAttributes & 32))
{ // field is nullable, adFldIsNullable=32
value = null;
}
fsTmp(field).value = value;
return true;
}
}
}
return false;
}
function _FS_getCount()
{
fsTmp = this.rsTag.recordset.Fields;
if (typeof(fsTmp) == 'object')
return fsTmp.count;
return 0;
}
function _FS__isValid()
{ return !(this.rsTag.recordset.BOF || this.rsTag.recordset.EOF); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -