Upload. aspx: <% @ LANGUAGE = 'javascript '%> <! -- # Include file = "../adojvs. inc" --> <! -- # Include file = ".. /conn. inc "--> <% // run the SQL statement // 2012-12-6 Gu Laichengfunction RunSQL (MySQL) {var ret =" "; var rs1 = Server. createObject ("ADODB. recordset "); rs1.CursorType = adOpenKeyset; rs1.LockType = adLockBatchOptimistic; // Response. write ("<br/>" + MySQL + ""); try {rs1.Open (MySQL, conn);} catch (ex) {var ErrStr, ErrStr0, errStr1 = "=>" + new Date () + "<br/>"; ErrStr0 = "Error:" + ex + "<br/>" + MySQL; v Ar o = conn. errors; for (var I = 0; I <o. count; I ++) {ErrStr1 + = o. item (I ). number + ":" + o. item (I ). description + "," + o. item (I ). SQLState + ";" + o. item (I ). source;} ErrStr = ErrStr0 + "<br/>" + ErrStr1; o. clear (); Response. write ("<br/>" + ErrStr + "");} if (rs1.State = 1) {if (! (Rs1.BOF & rs1.EOF) {ret = rs1 (0 ). value;} rs1.Close ();} return ret;} var Class = {create: function () {return function (n) {this. initialize. apply (this, arguments) ;}} var TABLE = Class. create (); TABLE. prototype = {initialize: function (TabName) {this. tabName = TabName; this. fields = []; this. fieldCount = 0; this. values = []; this. types = []; this. mySQL = ""; this. flag;}, F: function (s) {var a = s. spl It (","); for (var I = 1; I <. length; I ++) {this. fields [I-1] = a [I];} this. fieldCount =. length-1 ;}, V: function (s) {var a = s. split (","); this. flag = a [0]; for (var I = 1; I <. length; I ++) {this. values [I-1] = a [I];} if (a [0] = 1) this. replace (); if (a [0] = 2) this. insert (); if (a [0] = 3) this. update (); if (a [0] = 4) this. delete () ;}, Replace: function () {if (this. values [0] = 0) this. insert (); else this. update () ;}, Ins Ert: function () {var fs = "", vs = ""; var j = 0; // I, j may not be synchronized, and some column values may be empty, indicates that the value is not inserted. Make sure that the SQL syntax is correct for (var I = 0; I <this. fieldCount; I ++) {if (this. values [I] = "NULL") continue; if (j = 0) {fs + = this. fields [I]; vs + = "'" + this. values [I] + "'";} else {fs + = "," + this. fields [I]; vs + = ", '" + this. values [I] + "'";} j ++;} this. mySQL = "insert into" + this. tabName + "(" + fs + ") values (" + vs + ")" ;}, Update: function () {this. mySQ L = "update" + this. tabName + "set"; for (var I = 1; I <this. fieldCount; I ++) {if (this. values [I] = "NULL") {if (I! = 1) this. MySQL + = ","; this. MySQL + = this. Fields [I] + "= null";} else {if (I! = 1) this. mySQL + = ","; this. mySQL + = this. fields [I] + "= '" + this. values [I] + "'" ;}} this. mySQL + = "where" + this. fields [0] + "= '" + this. values [0] + "'";}, Delete: function () {this. mySQL = "delete from" + this. tabName + "where"; var j = 0; // I, j may not be synchronized, and some column values may be empty, indicating that it is not a condition, make sure that the SQL syntax is correct for (var I = 0; I <this. fieldCount; I ++) {if (this. values [I] = "") continue; if (this. values [I] = "NULL") {if (j! = 0) this. MySQL + = "and"; this. MySQL + = this. Fields [I] + "is null";} else {if (j! = 0) this. mySQL + = "and"; this. mySQL + = this. fields [I] + "= '" + this. values [I] + "'" ;}j ++ ;}}; var fso, ts, s; var ForReading = 1, ForWriting = 2; var name; // = "c: \ web \ yafulwisad \ t \ t.csv"; name = Server. mapPath ("t.csv"); var fso = new ActiveXObject ("Scripting. fileSystemObject "); if (fso. fileExists (name) {Response. write ("file" + name + "exists! "); Ts = fso. openTextFile (name, ForReading, true); // ts. skipLine (); var data = new TABLE (Request. queryString ("a") + ""); s = ts. readLine (); data. F (s); Response. write ("<br/>" + data. fieldCount); Response. write ("<br/>" + s. replace (/,/g, "\ t") + ""); Response. write ("<br/>" + data. fields + ""); while (! Ts. atEndOfStream) {www.2cto.com s = ts. readLine (); // Response. write ("<br/>" + s. replace (/,/g, "\ t") + "); data. V (s); Response. write ("<br/>" + data. mySQL + ""); RunSQL (data. mySQL);} ts. close ();} else {Response. write ("file" + name + "does not exist. Check the file and query it! ") ;}%>