没有为命令对象设置命令文本 - 在其他地方工作

时间:2016-12-02 12:40:07

标签: jscript

由于某些我无法理解的原因,我收到了上述错误。我已经注意掉了Connect()之后断开连接并且它运行正常,所以我知道问题就在那里。我的代码是:

var sixMonth = parseInt(currentDate.getMonth() - 6);
sixMonth++;
var reviewDate = year + "-" + sixMonth + "-" + day;
var d1;
var d2 = new Date(reviewDate);
var intListViewIndex9 = 0;

Connect();
var EOF = 0;

RecordSet = new ActiveXObject("ADODB.Recordset");

//set the source    
RecordSet.Source = statement;

//set the conection for the record set to use
RecordSet.ActiveConnection = ObjConnection;

//Open your RecordSet (i.e. Execute the query)
RecordSet.Open;

//declare the statement
statement = "SELECT AccessDate from screens.signoff WHERE BadgeNo = '" +               BadgeNo + "'";

while (RecordSetas.EOF == false){
    accessDate = RecordSet.Fields("AccessDate").Value;
    d1 = new Date(accessDate);

    if (d1.getTime() > d2.getTime()) {
        SQL("UPDATE screens.signoff SET Recertify = '1' WHERE BadgeNo = '" + BadgeNo + "'");
    }

    //Move to the next record in the RecordSet
    intListViewIndex9 = intListViewIndex9 + 1;
    RecordSet.MoveNext; 
}

//Close the RecordSet
RecordSet.Close;
//Destroy the objRecordSet object variable from memory
RecordSet = {};

disconect();

我在其他地方使用过这种结构,它的工作非常好,所以我很遗憾为什么不这样做。

以下是作为SQL的一部分调用的其他定义位。

var ObjConnection;

function Connect(){
    ObjConnection = new ActiveXObject("ADODB.Connection");
    SQLlook()
    ObjConnection.Open ("DSN=SQL");
}

function disconect(){
    //Close the Database Connection
    ObjConnection.Close;
    //Destroy the objConnection object variable from memory
    ObjConnection = {};
}

1 个答案:

答案 0 :(得分:0)

ADyson是对的,而不是设置RecordSet.source =语句,然后声明它我刚刚设置了实际的SQL命令(RecordSet.Source =“Select etc etc”)

RescordSetas也是一个错字