The ASP language JS writing and the VBScript formulation

Source: Internet
Author: User
Tags getdate

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) +" ' ";
%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.