Connecting to a database
VBS:
<%
Dim conn
Dim DBPath
Dim connstr
Set Conn =server.createobject ("Adodb.connection")
Dbpath=server.mappath ("Data.mdb")
Connstr= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" &dbpath
Conn.Open ConnStr
%>
Js:
<%
var Conn;
var DBPath;
var connstr;
Conn=server.createobject ("Adodb.connection");
Dbpath=server.mappath ("Data.mdb");
Connstr= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" +dbpath;
Conn.Open (CONNSTR);
%>
Close connection
VBS:
<% ' off release recordset
Rs.close
Set rs = Nothing
Conn.close
Set conn = Nothing
%>
Js:
<%//off release recordsets
Rs.close;
rs = null;
Conn.close;
conn = null;
%>
Output
VBS:
Response.Write "<script language= ' JavaScript ' >alert (' Operation succeeded, please wait for admin confirmation \ point to close window '); Self.opener.location.reload () ; Window.close ();</script> "
Js:
Response.Write (' <script language= ' JavaScript ' >alert (' successful operation, please wait for administrator confirmation \ Point ok close window '); Self.opener.location.reload ( ); Window.close ();</script> ");
Get Form objects
VBS:
Dim id
id = request.querystring ("id")
Js:
var id = request.querystring ("id"). item;//important, JS Request.QueryString is an object, to add the item
SQL Statement Date query, this is too different from the VBS, the beginning of my depressed for a long time, on the internet for a long time to come up with the following statement (this only wrote JS, the VBS will not write)
<%
var rs,sql;
rs = Server.CreateObject ("Adodb.recordset");
sql = "SELECT * from [Count] to Dae Desc"
Rs.Open (sql,conn,1,1)
Total number of visits achieved
var rst = Server.CreateObject ("Adodb.recordset");
sqlt= "Select SUM (count) as DT from [Count]";
Rst.open (sqlt,conn,1,1);
Achieve Day traffic
var RSD = Server.CreateObject ("Adodb.recordset");
sqld= "Select SUM (count) as DD from [Count] where day (dae) = '" + (new date). GetDate ()) + "' and Month (dae) = '" + (new date). g Etmonth () +1) + "' and year (DAE) = '" + ((new Date). getyear ()) + "'";
Rsd.open (sqld,conn,1,1);
To achieve yesterday's visit volume
var Rsz = Server.CreateObject ("Adodb.recordset");
sqlz= Select SUM (count) as ZD from [Count] where day (dae) = ' "+ (new date). GetDate ()-1) +" ' and Month (dae) = ' "+ (new date) . getmonth () +1) + "' and year (DAE) = '" + (new Date). getyear ()) + "'";
Rsz.open (sqlz,conn,1,1);
To achieve the month's traffic
var rsm = Server.CreateObject ("Adodb.recordset");
sqlm= Select SUM (count) as DM from [Count] where Month (dae) = ' "+ (new Date). GetMonth () +1) +" ' ";
%>