javascript对数据库的操作
1、insert
2、delete、update操作与insert操作类似,只需修改sql语句即可。
3、select
var conn = new ActiveXObject("ADODB.Connection");
conn.Open("Provider=SQLOLEDB; Data Source=xxs-oatest; User ID=sa; Password=sa; Initial Catalog=ExFlow");
var sql="insert into sms_temp (id,Name_Re,Name_Se,Text,Time_Se) values ('"+id+"','"+have_send_name+"','"+user_name+"','"+textbox[0].value+"','"+send_time+"')";
var objrs = conn.Execute(sql);
objrs = null;
conn = null;
conn.Open("Provider=SQLOLEDB; Data Source=xxs-oatest; User ID=sa; Password=sa; Initial Catalog=ExFlow");
var sql="insert into sms_temp (id,Name_Re,Name_Se,Text,Time_Se) values ('"+id+"','"+have_send_name+"','"+user_name+"','"+textbox[0].value+"','"+send_time+"')";
var objrs = conn.Execute(sql);
objrs = null;
conn = null;
3、select
var conn = new ActiveXObject("ADODB.Connection");
conn.Open("Provider=SQLOLEDB; Data Source=xxs-oatest; User ID=sa; Password=sa; Initial Catalog=ExFlow");
var rs = new ActiveXObject("ADODB.Recordset");
var sql="select * from mypower";
rs.open(sql, conn);
if (!rs.EOF)
{
alert(rs("toget_power");
}
rs.close();
rs = null;
conn.close();
conn = null;
conn.Open("Provider=SQLOLEDB; Data Source=xxs-oatest; User ID=sa; Password=sa; Initial Catalog=ExFlow");
var rs = new ActiveXObject("ADODB.Recordset");
var sql="select * from mypower";
rs.open(sql, conn);
if (!rs.EOF)
{
alert(rs("toget_power");
}
rs.close();
rs = null;
conn.close();
conn = null;