javascript 从数据库字段输出多个TXT文件

hkstudio hkstudio 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
需求描述:利用javascript 连接 ORACLE,把assp_voucher表里voucher_no,voucher_no输出到txt文件里 ,assp_voucher一条记录输出 一个 txt文件,文件名以voucher_no命名。

下面是我写的代码,只能写一个。

大虾帮我 修改下,谢谢。

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script type="text/javascript" defer="defer">
var strConnString = "Provider=OraOLEDB.Oracle;Data Source=evsdata;User ID=assp;Password=assp;PLSQLRset=1";
var conn = new ActiveXObject("ADODB.Connection");
conn.open(strConnString);
var rs = conn.execute("select * from assp_voucher");
document.all.voucher.value = "";
document.all.voucher_no.value = "";
while (!rs.EOF)
{
// alert(rs("voucher_no")+rs("voucher"));
// document.all.dbContent.value = document.all.dbContent.value + rs("voucher")+"/n";
document.all.voucher.value =rs("voucher")+"/n";
document.all.voucher_no.value =document.all.voucher_no.value + rs("voucher_no")+"/t";
//alert(rs("voucher_no"));
// document.getElementById("voucher").value=rs("voucher")
rs.moveNext;
}
rs.close();
conn.close();
conn = null;

//读文件
function readFile(filename){
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.OpenTextFile(filename,1);
var s = "";
while (!f.AtEndOfStream)
s += f.ReadLine()+"/n";
f.Close();
return s;
}
//
//写文件
function writeFile(filename,filecontent){
var fso, f, s ;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.OpenTextFile(filename,8,true);
f.WriteLine(filecontent);
f.Close();
alert('write ok');
}

</script>
<title>无标题文档</title>
</head>
<body>
<textarea id="voucher" name="voucher" rows="10" cols="100"></textarea>
<textarea id="voucher_no" name="voucher_no" rows="5" cols="100"></textarea>
<input type="button" value="Write!" onclick="writeFile('c:/12.txt',document.getElementById('voucher').value);"/>
</body>
</html>
...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
hkstudio
JavaScript 87,983 成员 224,681 内容