Js|jscript| Server | client | statement | Execute |js|jscript| server | client <% @LANGUAGE = "JAVASCRIPT" codepage= "936"%>
<%
var queststringbuilder = function () {
1-> query statements, 2-> UPDATE statements, 3-> DELETE statements, 4-> INSERT statements
var questtype = 0;
var Fields = [];
var Values = [];
var Condition;
var PK;
var Pkeysort;
VAR TableName;
var state = false;
var clogic = "and";
var coperator = "=";
This.addfield = function (field,value) {
Fields.push (Processfield (Field));
Values.push (Processvalue (Value));
};
This.addcfield = function (cfield,cvalue) {
var stemp = [];
if (condition!=undefined&&condition!= "") {Stemp.push (Condition);}
if (coperator!= "like") {
Stemp.push (Processfield (Cfield) +coperator+processvalue (cvalue));
}else{
Stemp.push (Processfield (Cfield) + "like '%" +cvalue+ "%");
}
Condition = Stemp.join (clogic);
if (condition== "") {condition=stemp.tostring ();}
};
This. Table = function (s) {tablename = s;};
This. Pkey = function (s) {PK = Processfield (s);};
This. PKEYASC = function () {pkeysort= "ASC";};
This. Pkeydesc = function () {pkeysort= "DESC";};
This.getselect = function () {
Questtype = 1;
return result ();
};
This.getupdate = function () {
Questtype = 2;
return result ();
};
This.getdelete = function () {
Questtype = 3;
return result ();
};
This.getinsert = function () {
Questtype = 4;
return result ();
};
This.clear = function () {
Fields = [];
Values = [];
PK = undefined;
Pkeysort = undefined;
tablename = undefined;
state = false;
};
This. Actionstate = function () {return state;};
This. Changelogic = function (s) {clogic = "" +s.touppercase () + "";};
This. Changeoperator = function (s) {coperator = S.touppercase ();};
var result = function () {
var strtemp;
if (fields.length==0) Fields.push ("*");
Switch (questtype) {
Case 1:
if (tablename!=undefined&&tablename!= "") {
strtemp = "Select" + fields.tostring () + "from" + tablename;
if (condition!=undefined) {strtemp = = "WHERE" + Condition;}
if (pkeysort!=undefined&&pk!=undefined) {strtemp = = "ORDER BY" + PK + "" + Pkeysort;}
state = true;
}else{
strtemp = geterror (0); Enter table name required
}
return strtemp;
Break
Case 2:
if (tablename!=undefined&&tablename!= "") {
strtemp = "UPDATE" + tablename + "SET" + process (fields,values);
if (condition!=undefined) {
state = true;
strtemp + = "WHERE" + Condition;
}else{
strtemp = GetError (1);
}
}else{
strtemp = geterror (0); Enter table name required
}
return strtemp;
Break
Case 3:
if (tablename!=undefined&&tablename!= "") {
strtemp = "DELETE from" + tablename;
if (condition!=undefined) {
state = true;
strtemp + = "WHERE" + Condition;
}else{
strtemp = GetError (1);
}
}else{
strtemp = geterror (0); Enter table name required
}
return strtemp;
Break
Case 4:
if (tablename!=undefined&&tablename!= "") {
strtemp = "INSERT into" + tablename;
if (fields.length!=0) {
state = true;
strtemp