//打开数据库连接
function Conn() {
var conn = new ActiveXObject("ADODB.Connection");// Data Source=数据库地址; User ID=数据库用户名; Password=数据库密码; Initial Catalog=数据库名称。
conn.Open("Provider=SQLOLEDB.1; Data Source=192.168.1.252,1433; User ID=king; Password=sa; Initial Catalog=OrderSys"); //打开数据库
return conn;
}
/*查询数据库,传入sql*/
function Query(sql) {
Conn();
try {
var rs = new ActiveXObject("ADODB.Recordset");
rs.open(sql, conn);
var table= "";
while(!rs.EOF) {
table= table+ rs.Fields("order_no") + " | " + rs.Fields("food_name")+"<br/>";
table= table+ "-----------------------------"+"<br/>"; <