使用JavaScript连接SqlServer数据库。执行CRUD操作。
function db()
{
//活动编号
var activeid = Request.Form("activeid");
//用户名
var username = Request.Form("username");
//手机号码
var mobile = Request.Form("mobile");
var conn= Server.CreateObject("ADODB.connection");
var rs= Server.CreateObject("adodb.recordset");
var userid = getUserIdByName(username);
conn.open("PROVIDER=SQLOLEDB;DATA SOURCE=127.0.0.1;UID=sa;PWD=123456;DATABASE=test");
var sql = "insert into user (activeid,userid,chrtel,dtappenddate) values("+activeid+","+userid+",'"+mobile+"',getdate())";
rs.open(sql,conn);
rs.close();
conn.close();
rs=null;
conn=null;
}
function getUserIdByName(username)
{
var conn= Server.CreateObject("ADODB.connection");
var rs= Server.CreateObject("adodb.recordset");
conn.open("PROVIDER=SQLOLEDB;DATA SOURCE=127.0.0.1;UID=sa;PWD=123456;DATABASE=test");
var sql = "select userid from RegUsers where chrname='"+username+"'";
rs.open(sql,conn);
if(!rs.EOF)
{
return rs("userid");
}
rs.close();
conn.close();
rs=null;
conn=null;
}
function baoming()
{
var conn= Server.CreateObject("ADODB.connection");
var rs= Server.CreateObject("adodb.recordset");
conn.open("PROVIDER=SQLOLEDB;DATA SOURCE=127.0.0.1;UID=sa;PWD=123456;DATABASE=test");
var sql = "select userid,activeid,chrtel,CONVERT(varchar(30),dtappenddate,20) as dtappenddate from baoming order by id desc";
rs.open(sql,conn);
var i =1;
while(!rs.EOF && i<31)
{
Response.Write("<tr align='center'>");
Response.Write("<td>"+i +"</td>");
Response.Write("<td>"+ getUserNameById(rs('userid')) +"</td>");
Response.Write("<td>"+ getActi
相关文档:
eg:
select * from Exception_Log where DATEDIFF(day,OPER_DATE,getdate())<30 ;
/*
oper_date 为表中查询出来的时间
getdate()为SQLServer里面获得系统时间的函数
含义:当前时间-查询出来的时间小于30天
DateDiff具体用法:
*/
DateDiff 函数
返回两个日期之间的时间间隔。
DateDiff(interval, date1, da ......
<script>setTimeout("redirect('<?=$url_forward?>');", <?=$ms?>);</script>
设置分页:$page $pagesize $offset = ($page-1)*$pagesize;
$limit = "limit $offset,$pagesize" ......
功能:
重新加载文档。
语法:
location.reload(force)
参数:
force:可选参数,是一个布尔值。
如果省略参数,或者参数是false,它就会用HTTP头If-Modified-Since来检测服务器上的文档是否已改变。如果文档已改
变,reload()会再次下载该文档。如果文档未改变,则该方法将从缓存中 ......
Nested Members 嵌套成员
Since object members may contain other members, it's not uncommon to see patterns such as window.location.href in JavaScript code. These nested members cause the JavaScript engine to go through the object member resolution process each time a dot is ......
第三章 DOM Scripting DOM编程
DOM scripting is expensive, and it's a common performance bottleneck in rich web applications. This chapter discusses the areas of DOM scripting that can have a negative effect on an application's responsiveness and gives recommendations o ......