我无法弄清楚我做错了什么,这让我疯了。这是一些查询访问数据库的javascript代码。所有RS.fields [i]都是未定义的,但是返回的行数正确。知道是什么导致了这个吗?
adOpenForwardOnly = 0;
adLockReadOnly = 1;
adCmdText = 1;
var data = new Array();
var myConnect = 'Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\\asdf.mdb';
var ConnectObj = new ActiveXObject('ADODB.Connection');
var RS = new ActiveXObject('ADODB.Recordset');
var sql = 'SELECT * FROM TTT WHERE XXX = "'+xxx+'" AND YYY = "'+yyy+'" AND ZZZ = '+zzz+' AND AAA = "'+aaa+'" AND BBB = #'+bbb+'# ';
//alert(sql);
ConnectObj.Open(myConnect);
RS.Open(sql, ConnectObj);
RS.MoveFirst();
while(!RS.eof){
data.push( new FFFRow(
'a',
parseFloat(RS.fields[1]),
new String(RS.fields[8]),
GetDateFromString(RS.fields[9]),
GetDateFromString(RS.fields[10]),
GetDateFromString(RS.fields[4]),
GetDateFromString(RS.fields[12]),
parseFloat(RS.fields[13]),
parseFloat(RS.fields[14]),
new String(RS.fields[15]),
parseFloat(RS.fields[16]),
parseFloat(RS.fields[17]),
parseFloat(RS.fields[18]),
parseFloat(RS.fields[19]),
'',
'',
parseFloat(RS.fields[0]),
new String(RS.fields[3]),
new String(RS.fields[2])
)
);
RS.MoveNext();
}
答案 0 :(得分:1)
试试这个:
RS.Fields.Item(1)
注意,Fields是cap,Item是cap,它是函数调用而不是数组引用。