JavaScript链接数据库出错
function()
{
var conn = new ActiveXObject("ADODB.Connection"); //
var rs = new ActiveXObject("ADODB.Recordset"); //
conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:DataBase Password=jiaming;Data Source="& Server.MapPath("manager/admin_qw/DataBase/#'#dbweb.asa");//定义链接字符串变量
conn.Open(); //打开链接
var sql="select * from product_info order by click desc"; //定义数据库连接语句
rs.Open(sql,conn);//打开数据库
var suggestionText="";//定义变量suggestionText
while(!rs.eof)//循环语句
{
var text=rs("game_name");//将rs中的gamename赋值给text变量
suggestionText=text+suggestionText;//把rs记录集当中的gamename全部循环赋值给suggestionText变量
rs.moveNext;
}
rs.close(); //关闭记录集
rs = null;
conn.close(); //关闭链接
conn = null;
}
每次运行程序,suggestionText都是空值。不知道是js链接数据库出错,还是赋值出错?
------解决方案--------------------
用alert()调试啊