首页 > 其他分享 >JSCRIPT连接ado

JSCRIPT连接ado

时间:2023-08-15 20:12:51浏览次数:54  
标签:function return commandText handle JSCRIPT rs var ado 连接

// JavaScript source code
// JScript source code

var console = {
log: function (txt)
{
WScript.Echo(txt);
}
}

function Recordset(h)
{
this.commandText = "";
this.activeConnection = null;
this.handle = h;
this.open = function ()
{
if (this.handle == null) {
this.handle = new ActiveXObject("adodb.Recordset");
}

return this.handle.Open(this.commandText, this.activeConnection, 3, 4,1);
}
this.get = function (id) { return this.handle(id); }
this.set = function (id, data){ return this.handle(id) = data; }
this.update = function () { this.handle.Update();}
this.close = function () { if (this.handle != null) { return this.handle.Close(); } }
this.recordCount = function ()
{
return this.handle == null ? -1 : this.handle.RecordCount;
}
this.eof = function () { return this.handle.EOF; }
this.moveNext = function () { return this.handle.MoveNext(); }
this.addNew = function () { if (this.handle !=null) { return this.handle.AddNew(); } }
}

function Connection()
{
this.commandText = "";
this.connectionString = "Provider=SQLOLEDB.1;Data Source=129.9.1.100,1433;Network Library=DBMSSOCN; Initial Catalog=test;User ID=sa;Password=00000;";
this.handle = new ActiveXObject("adodb.connection");
this.open = function () { return this.handle.Open(this.connectionString); }
this.close = function () { return this.handle.Close(); }
this.execute = function () { return this.handle.Execute(this.commandText); }
this.query = function () { var rs = this.handle.Execute(this.commandText); return new Recordset(rs); }
}

try
{
var db = new Connection();
db.open();
//db.commandText = "select * from sys_app";
//var rs = db.query();
//var n = rs.recordCount();

//while (!rs.eof())
//{
// console.log(rs.get("appname"));
// rs.moveNext();

//}

//rs.close();
//console.log("Rows:" + n.toString());

var r = new Recordset();
r.activeConnection = db.handle;
r.commandText = "select * from sys_app ";
r.open();
r.addNew();
r.set("appcode",'J001');
r.update();
//var r = new Recordset();
//r.activeConnection = db.handle;
//r.commandText = "select * from sys_app";
//r.open();
//while (!r.eof())
//{
// console.log(r.get("appname"));
// r.moveNext();

//}

//console.log("Rowcount:" + r.recordCount());
r.close();

db.close();
}catch(e)
{
console.log( e.description);
}

标签:function,return,commandText,handle,JSCRIPT,rs,var,ado,连接
From: https://www.cnblogs.com/qzxff/p/17632317.html

相关文章

  • VS Code通过public key连接服务器开发
    1.需要安装的插件:Remote-SSH2.配置Remote-SSH安装完Remote-SSH以后左侧会出现一个远程资源管理的图标,选择SSHTargets,进入config配置文件选择文件地址填写网址信息:#自己取个名字Host192.168.141.234#服务器地址HostName192.168.141.234#自己的服务器用户名Userjinb......
  • mormot笔记一 连接数据库
    unitUnit1;interfaceusesWinapi.Windows,Winapi.Messages,System.SysUtils,System.Variants,System.Classes,Vcl.Graphics,Vcl.Controls,Vcl.Forms,Vcl.Dialogs,Vcl.Grids,Vcl.StdCtrls,mormot.db.sql,mormot.db.core,mormot.db.sql.oledb,mormot.c......
  • Nginx 代理 MySQL 连接,并限制可访问IP
    1.前言我们的生产环境基本上都部署在云服务器上,例如应用服务器、MySQL服务器等。如果MySQL服务器直接暴露在公网,就会存在很大的风险,为了保证数据安全,MySQL服务器的端口是不对外开放的。好巧不巧,线上业务遇到bug了,开发的小伙伴需要远程连接MySQL来查看数据,那应该怎么办呢?我们可以通......
  • 工业物联网网关:连接智能制造的关键
    随着工业4.0和智能制造的快速发展,工业物联网网关逐渐成为智能制造体系中的核心组件。这个物联网设备承担着设备连接、数据采集、协议转换和数据处理等多重任务,对于实现工业互联网的实时监控、远程控制、故障诊断和预测维护等功能具有重要作用。例如,在生产设备的智能化改造中,物联网......
  • 解决浏览器”您的连接不是私密链接“的问题!最详细!!!
    Google的Chorom浏览器打开baidu主页,显示您的连接不是私密连接攻击者可能会试图从x.x.x.x窃取您的信息(例如:密码、通讯内容或信用卡信息)。了解详情NET::ERR_CERT_INVALID网上找了很多人的解决办法,但都不好用,比如输入thisisunsafe,修改DNS等等其实这个问题的本质就是证书的问题,原......
  • 工业物联网平台:连接智能制造的未来
    随着工业4.0时代的到来,物联网技术正在逐渐渗透到制造业的各个环节。工业物联网平台作为物联网技术在工业领域的典型应用,正在成为连接智能制造未来的重要桥梁。 工业物联网平台通过传感器、智能设备、网络通信、云计算与大数据分析等技术,将制造过程中的各种数据和信息进行实时采集......
  • 使用 OpenSSL 解密 DBeaver 保存的数据库连接信息获取数据库连接密码
    你是不是使用任何软件时都喜欢记住密码?是的,我也喜欢。但如果有一天你想把密码分享给其他人,而你又不记得密码是什么了,没错你可以去查看已保存的密码,但是当你使用的是DBeaver时,不好意思,没有查看已保存的密码功能,这个时候不就尴尬了嘛。那么现在你也许不再需要因此而烦恼了,因为......
  • 问题--连接超时
    1.问题sqlalchemy.exc.OperationalError:(pymysql.err.OperationalError)(2003,"Can'tconnecttoMySQLserveron'113.54.246.60'(timedout)")(Backgroundonthiserrorat:https://sqlalche.me/e/20/e3q8)2.解决这个错误提示是SQLAlchemy和pymysq......
  • 使用 JScript 查找操作系统名称/版本
    varwbemFlagReturnImmediately=0x10;varwbemFlagForwardOnly=0x20;varobjWMIService=GetObject("winmgmts:\\\\.\\root\\CIMV2");varcolItems=objWMIService.ExecQuery("SELECT*FROMWin32_OperatingSystem","WQL",......
  • VScode 远程连接服务器 GUI 显示
    VScode远程连接服务器的指导就不详述了注意以下几点在本地ssh配置文件config中加上如下配置ForwardAgentyesForwardX11yesForwardX11Trustedyes正文如下:安装插件vscode上安装RemoteX11(SSH)和RemoteX11插件:安装xserver服务微软官方推荐安装VcXsrv理......