javascript

位置:IT落伍者 >> javascript >> 浏览文章

.net 通过后台js上传表数据


发布日期:2021年03月16日
 
.net 通过后台js上传表数据

Uploadaspx:

<%@ LANGUAGE=JAVASCRIPT %>
<! #include file = "/adojvsinc">
<! #include file = "/conninc">
<%

// 执行SQL语句
// Gu Laicheng
function RunSQL(MySQL)
{
var ret="";

var rs = ServerCreateObject("ADODBRecordset");
rsCursorType = adOpenKeyset;
rsLockType = adLockBatchOptimistic;

// ResponseWrite("<br/>" + MySQL + "");
try {
rsOpen(MySQLconn);
}
catch (ex) {
var ErrStrErrStrErrStr="==>"+new Date()+"<br/>";
ErrStr = "Error:"+ex+"<br/>"+MySQL;
var o = connErrors;
for (var i=;i<oCount;i++)
{
ErrStr += oItem(i)Number + ":" + oItem(i)Description+" "+oItem(i)SQLState+";"+oItem(i)Source ;
}
ErrStr =ErrStr+"<br/>"+ErrStr;

oClear();
ResponseWrite("<br/>" + ErrStr + "");
}

if(rsState==)
{
if (!(rsBOF && rsEOF))
{
ret = rs()value;
}
rsClose();
}
return ret;
}

var Class = {
create: function() {
return function(n) {
thisinitializeapply(this arguments);
}
}
}

var TABLE = Classcreate();

TABLEprototype = {
initialize:function(TabName){
thisTabName = TabName;
thisFields=[];
thisFieldCount = ;
thisvalues=[];
thistypes=[];
thisMySQL="";
thisflag;
}
F:function(s)
{
var a=ssplit("");
for(var i=;i<alength;i++)
{
thisFields[i]=a[i];
}
thisFieldCount = alength;
}
V:function(s)
{
var a=ssplit("");
thisflag=a[];
for(var i=;i<alength;i++)
{
thisvalues[i]=a[i];
}
if(a[]==) thisReplace();
if(a[]==) thisInsert();
if(a[]==) thisUpdate();
if(a[]==) thisDelete();
}
Replace:function()
{
if(thisvalues[]==)
thisInsert();
else
thisUpdate();
}
Insert:function()
{
var fs=""vs="";
var j=; //ij可能并不同步有些列值可能为空表示不插入其值要保证sql的语法正确
for(var i=;i<thisFieldCount;i++)
{
if(thisvalues[i] == "NULL") continue;
if(j == )
{
fs += thisFields[i];
vs += ""+thisvalues[i]+"";
} else
{
fs += ""+thisFields[i];
vs += ""+thisvalues[i]+"";
}
j++;
}
thisMySQL="insert into "+thisTabName+" ("+fs+") values ("+vs+")";
}
Update:function()
{
thisMySQL="update "+thisTabName+" set ";
for(var i=;i<thisFieldCount;i++)
{
if(thisvalues[i] == "NULL")
{
if(i != ) thisMySQL += "";
thisMySQL += thisFields[i]+"=null ";
} else
{
if(i != ) thisMySQL += "";
thisMySQL += thisFields[i]+"="+thisvalues[i]+"";
}
}
thisMySQL += " where "+thisFields[]+"="+thisvalues[]+"";
}
Delete:function()
{
thisMySQL="delete from "+thisTabName+" where ";
var j=; //ij可能并不同步有些列值可能为空表示不以其为条件要保证sql的语法正确
for(var i=;i<thisFieldCount;i++)
{
if(thisvalues[i]=="") continue;
if(thisvalues[i] == "NULL")
{
if(j != ) thisMySQL += " and ";
thisMySQL += thisFields[i]+" is null ";
} else
{
if(j != ) thisMySQL += " and ";
thisMySQL += thisFields[i]+"="+thisvalues[i]+"";
}
j++;
}
}
};


var fso ts s;
var ForReading = ForWriting = ;

var name;// = "c:webyafulwisadttcsv";
name = ServerMapPath("tcsv");
var fso = new ActiveXObject("ScriptingFileSystemObject");
if (fsoFileExists(name))
{
ResponseWrite(" 文件 "+name+" 存在!");
ts = fsoOpenTextFile(name ForReading true);
// tsSkipLine();

var data=new TABLE(RequestQueryString("a")+"");

s = tsReadLine();
dataF(s);
ResponseWrite("<br/>"+dataFieldCount);
ResponseWrite("<br/>" + sreplace(//g"t") + "");
ResponseWrite("<br/>" + dataFields + "");

while (!tsAtEndOfStream)
{
s = tsReadLine();
// ResponseWrite("<br/>" + sreplace(//g"t") + "");
dataV(s);
ResponseWrite("<br/>" + dataMySQL + "");
RunSQL(dataMySQL);
}
tsClose();
}
else
{
ResponseWrite(" 文件 "+name+" 不存在请核对后查询!");
}
%>

               

上一篇:js返回字符串中某个字符的出现次数

下一篇:删除重复字符js代码