Original Easyasp v1.5 simplifies ASP development, including database operations classes

Source: Internet
Author: User
Tags mssql sql new features string sql injection table name version variable
Easyasp v1.5 simplifies ASP development, including database operations classes

easyasp is a convenient and rapid development of the ASP class, which contains a database control class ( The original clsdbctrl.asp, the original code has been optimized and modified, including the database of various operations and stored procedures of the call, all encapsulated in the easp.db, it will be more convenient to use, the call is simpler). And the Easp class provides a lot of practical ASP common process and method, can simplify most ASP operation. Only the VBScript version is currently available, and the JScript version may be available in the future. For more information, please download the Help manual, which has a very detailed description of the use of methods and source code examples.

SOURCE Download: Http://easyasp.googlecode.com/files/EasyASP.v1.5.rar
Help manual download: Http://easyasp.googlecode.com/files/EasyASP.v1.5.Manual.rar
Follow-up update please pay attention to: http://easyasp.googlecode.com

=================================================================
Easyasp v1.5 (updated in 2008-10-22)
new Features:
1, the Database control class (original clsdbctrl.asp) encapsulated into the Easp class, through the EASP.DB call, can also be used independently.
2, add the MSSQL stored procedure call method, you can flexibly invoke the stored procedure and return return value, Recordset and out parameters.
3, add db. Creatconn method, you can connect to a database based on a custom connection string.
4, add db. Json method, you can output a database recordset in JSON format.
5, add db. Rand and Db.randstr methods that generate a random or random string that is not repeated
6, the new database operation methods of shorthand method, more economical writing code time.
7, in the Easp class to add a large number of practical methods, such as secure access to the value, anti-SQL injection, server-side form validation.
Other Updates:
1, optimize DB. Autoid automatically gets the number, the efficiency is increased more than 20 times times, the data quantity is bigger more obvious.
2, modify DB. Openconn database connection method, more consistent with the daily description habits.
3, modify DB. Getrecord Recordset method with fewer parameters. Fix the bug with an array error.
4, modify and optimize db. DeleteRecord Delete Logging method, there are currently only two parameters.
5, modified the error debugging method, add Debug global Property Control error display.
Update Description:
Previously wrote a clsdbctrl.asp database control class, received some feedback, and a friend sent me a message to tell me some ways to improve, thank them. And I in the thread of the original post to see a message that "there is a memory of the parameters of the time, the SQL statement has been written all over", but also directly pointed out that the embarrassment, indeed, although the VBS does not have arguments attributes, but too many parameters are not a good idea. So it took me a while to rewrite a lot of the code for this class, a method with a maximum of 3 parameters in the premise that the function can only be stronger and not weaker. In addition, a new method called the MSSQL stored procedures, you can flexibly invoke the stored procedure and return one or more records, output parameters and return values as needed, of course, the lesson, this method has only two parameters. are now encapsulated in this new name easyasp, as the name suggests, nothing more than to think that everything is simple.
There is also a more embarrassing, that is VBScript is not an object-oriented language, so this class in fact, it is only a few processes and methods of encapsulation, easy to use, so most of the methods and procedures can be proposed to use alone. Of course, if necessary, it can also be encapsulated into WSC or DLL components to use.

=================================================================
Instructions for use
=================================================================


1, the use of methods:

(1) All calls to the Easp class are already contained in easp.asp, so you only need to introduce the file at the top of the page, such as:

QUOTE: <!--#include file= "inc/easp/easp.asp"-->
Or:

QUOTE: <!--#include virtual= "/inc/easp/easp.asp"-->
(2) The class has been instantiated without any further instantiation, directly using the easp. Prefix invocation, such as:

QUOTE:Easp.wn ("Test String") or Easp.db.AutoId ("Table:id")
(3) If you want to operate multiple databases at once, instantiate the new Easpdb object, such as:

Quote:dim db2:set DB2 = New easyasp_db
Db2.dbconn = DB2. Openconn (0,dbase,server)
2. Parameter Agreement:

(1) array parameters:Because VBScript has no arguments properties and cannot use dynamic parameters, array (array) is used to achieve this effect in the code that involves database data in this class. Some of the parameters in this class can be used in arrays (as noted in the parameter descriptions), but the following format should be used when using arrays:

Quote:array ("Field1:value1", "Field2:true", "field3:100")
Yes, a bit like JSON format, if it involves variables, that's it:

Quote:array ("Field1:" & Value1, "Field2:" & Value2, "Field3:" & Value3)
It can be said that almost all of the content associated with database fields in this class can be set with the above array format or get content, including calling parameters to be passed by the stored procedure. The biggest advantage of this class is that you don't have to consider the type of field when you use it, and then follow the field with a colon, followed by the corresponding value. If you often write ASP programs, you will soon feel the charm of using this method, in addition to the data type not to consider, it is also easy to add and delete conditions at any time. Here's an example to illustrate this usage:
For example, how to add a new record:

QUOTE:Easp.db.AddRecord "Table", Array ("FIELDSA: Test Data", "FIELDSB:" &now (), "Fieldsc:true")
There are only two arguments, one is the table name, and the other is the array parameter. If you want to change the structure of the database, it is very easy to modify the program code above.
(2) Common parameters (separated by special symbols):It is also considered that to minimize the parameters, if some of the parameters in many cases can not, there is no need to specifically add a parameter for it. In this class, special symbols such as colons (:) separate multiple values in one parameter are used to pass multiple arguments. For a few examples, you can also preview some of the advantages of using this class:
For example, to establish the MSSQL database connection object method:

Quote:set Conn = Easp.db.Open (0, "Database", "user:password@serveraddress")
At a glance right, here it is: and @ separated a few parameters and placed in the same parameter. In addition, if the Access database has a password, enter in the 3rd argument, no more arguments.
Again, for example, to get a recordset:

Quote:set rs = Easp.db.GetRecord ("table:fieldsa,fieldsb,fieldsc:20", "ID > Ten", "ID Desc")
The 1th parameter contains the table name, the field to take and the number of records to take, because the number of fields and records can be omitted many times, so I simply omitted the parameters, so that the parameters to be recorded a lot less.
Another example of this class has a geturl () to get the address of this page, many places have seen it, but this method in this class with a parameter, through this parameter can achieve a lot of results, see examples:
For example, the actual address of this page is:

Quote:http://www.domain.com/news/index.asp?type=public&feed=on&page=23
The following results are returned using different parameters:

QUOTE: Method Return result
GetUrl ("") HTTp://www.domain . com/nEws/index.asp?type=public&feed=on&page=23
GETURL (0)/news/index.asp
GETURL (1)/news/index.asp?type=public&feed=on&page=23
GETURL ("page")/news/index.asp?page=23
GETURL ("-page")/news/index.asp?type=public&feed=on
GETURL (":")/news/?type=public&feed=on&page=23
GETURL (":-feed,-page")/news/?type=public
No more explanation, hehe. This class of flexible use of common parameters where there are many, this is also a major feature of easyasp, we look at the manual.

3. Overview of methods and properties:

(1) Database operation:

Property:
Easp.db.dbConn (read-write) setting and getting current database connection objects
Easp.db.DatabaseType (read-only) query the type of database currently in use
Easp.db.Debug (read-write) setup and query error debug switch
EASP.DB.DBERR (read-only) query error message
Method:
Easp.db.OpenConn database connection objects based on templates
Easp.db.CreatConn Establish a database connection object based on a custom string
Easp.db.AutoID get automatic numbering based on table name
Easp.db.GetRecord get recordsets based on conditions
Easp.db.wGetRecord output Gets the recordset's SQL statement
Easp.db.GetRecordBySQL get a recordset based on a custom SQL statement
Easp.db.GetRecordDetail get details of a record
Easp.db.AddRecord Add a new record
Easp.db.wAddRecord an SQL statement that adds a new record to the output
Easp.db.UpdateRecord update records based on criteria
Easp.db.wUpdateRecord output update record SQL statement
Easp.db.DeleteRecord Delete records based on criteria
Easp.db.wDeleteRecord output Deletes a record's SQL statement
Easp.db.ReadTable to get the specified field data according to the criteria
Easp.db.Json generates Json-formatted data from a recordset
Easp.db.doSP invokes a stored procedure and returns a variety of data
Easp.db.Rand generates a random number that is not repeated
EASP.DB.RANDSTR generates a random string that is not duplicated
EASP.DB.C closes the recordset and frees resources

(2) String processing:

EASP.W Output string
Easp.wn output string and one HTML wrap ("<br/>")
Easp.we the output string and terminates the program
EASP.ISN determine if a string is a null value
Easp.js output JavaScript code
Easp.alert Popup JS message box and return to the previous page
Easp.alerturl Popup JS message box and jump to new page
Easp.jsencode convert string to secure JavaScript string
Easp.cutstring intercept a string and replace the truncated part with a custom symbol
Easp.htmlencode HTML Overweight function
Easp.htmldecode HTML decoding function
Easp.htmlfilter Filter HTML Tags
Easp.randstr a random string that generates a specified length
EASP.R gets the request value and converts it to a SQL security string
Easp.ra secure the request value and eject the JS message box when the error occurs
Easp.test validation of data legality based on regular expressions

(3) Time and date processing:

Easp.datetime formatted date of day
Easp.diffhour returns the number of hours that a date-time variable differs from the present
Easp.diffday returns the number of days that a date-time variable differs from the present
Easp.getscripttime returns accurate to millisecond script execution time based on the timestamp

(4) Digital processing:

Easp.rand generates a random number
Easp.tonumber converts a number to a format that specifies the number of decimal places
Easp.toprice convert number to currency format
Easp.topercent convert number to percent format

(5) Cookies and application processing:

Easp.setcookie set a cookie value
Easp.getcookie Get a cookie value
Easp.removecookie Delete a cookie value
Easp.setapp set a application value
Easp.getapp Gets a application value
Easp.removeapp Deletes a application value

(6) Other:

Three-dimensional expression of easp.ifthen judgment
EASP.RR server-side jump page
Easp.geturl gets the URI address of the current page
Easp.getip Get the Visitor IP
Easp.nocache Settings page does not cache
Easp.close closes objects and frees resources
Easp.checkform server-side form authentication pop-up JS message box
Easp.checkdatafrom Authentication Submission Data source
Easp.checkdatafroma Verify that the data source is out of code. Popup JS message box
Easp.checksql anti-SQL injection strong verification
EASP.CHECKSQLA anti-SQL injection strong validation irregularities pop-up JS message box


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.