濮阳杆衣贸易有限公司

主頁 > 知識庫 > ASP中文本文件與數(shù)據(jù)庫文件的數(shù)據(jù)交換(FSO)

ASP中文本文件與數(shù)據(jù)庫文件的數(shù)據(jù)交換(FSO)

熱門標簽:萊西電子地圖標注 武夷山旅游地圖標注 外呼系統(tǒng)API接口 縣域地圖標注打印店 個人可以辦理400電話么 怎么在地圖標注自己 鳳臺百度地圖標注店 修改地圖標注 金昌電話機器人價格
ASP中文本文件與數(shù)據(jù)庫文件的數(shù)據(jù)交換

網(wǎng)絡數(shù)據(jù)庫的應用是WWW上一個很重要的組成部分,可以這樣說,如果缺少了數(shù)據(jù)庫,網(wǎng)絡也就失去了靈魂。大家可以想象一下,如果沒有象YAHOO,SOHU等搜索引擎的話,那么在網(wǎng)上尋找一個目標變得多么困難,大家在茫茫網(wǎng)海里變得不知所往,動輒迷失方向。其實,這些搜索引擎是網(wǎng)絡數(shù)據(jù)庫的最典型的應用,在ASP(Active Server Pages)技術(shù)里對數(shù)據(jù)庫的直接操作是比較多的,下面講述一種由文本文件向數(shù)據(jù)庫文件傳遞數(shù)據(jù)的方法。
這個文本文體是由終端采集傳送到服務器的一個固定目錄下,由服務器去讀取數(shù)據(jù)并存放在本機數(shù)據(jù)庫里,轉(zhuǎn)換完后刪除掉這個文本文件。這樣終端負責采集數(shù)據(jù),并按給定的格式上傳到服務器的指定目錄下,服務器端的數(shù)據(jù)庫對終端來講是完全不透明的,保障了服務器的安全,對現(xiàn)在的網(wǎng)絡數(shù)據(jù)庫應用來講或許有點幫助。
Txttolib.asp
html>

head>
meta http-equiv="refresh" content="30;url=deltext.asp">
meta http-equiv="Content-Type"
content="text/html; charset=gb_2312-80">
meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
title>[把文本文件轉(zhuǎn)換成數(shù)據(jù)庫文件]/title>
/head>

body bgcolor="#FFFFFF">
align="center">
p align="center">font color="#FF0000">正在處理數(shù)據(jù),請稍候!
br>
/font>font color="#000000">align="center">%
str=server.mappath("/") ‘取得服務器的根目錄
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(str "\thetext")
Set fc = f.Files
k=1
For Each f1 in fc
file(k)=f1.name ‘得到此路徑下的所有文件名
k=k+1
next
%>% ii=1%>%
set fs = CreateObject("Scripting.FileSystemObject")%>%
while iik
response.write file(ii) "br>"
set textinstance=fs.opentextfile(str "\thetext\&; file(ii),1,false,false)‘打開文件來讀數(shù)據(jù)
while textinstance.atendofstream> true ‘如果文件沒有結(jié)束
visitornum=textinstance.readline ‘讀進一行數(shù)據(jù)
j=0
cd=len(visitornum)
for i=1 to cd
if mid(visitornum,i,1)="," then ‘數(shù)據(jù)與數(shù)據(jù)之間以“,”隔開
j=j+1
else
select case j‘分別取得各數(shù)據(jù)值
case 0
me1=me1+mid(visitornum,i,1)
case 1
me2=me2+mid(visitornum,i,1)
case 2
me3=me3+mid(visitornum,i,1)
case 3
me4=me4+mid(visitornum,i,1)
case 4
me5=me5+mid(visitornum,i,1)
case 5
me6=me6+mid(visitornum,i,1)
end select
end if
next
response.write me1 " " me2 " " me3 " " me4 " " me5 " " me6 " " "br>"
set cn=server.createobject("adodb.connection")
cn.open "water","",""
set rs=server.createobject("adodb.recordset")
sql="select * from watertable"
rs.open sql,cn,3,3‘打開數(shù)據(jù)庫進行追加操作
if rs.eof=true then
on error resume next
'rs.movelast
rs.movefirst
on error resume next
end if
rs.addnew‘增加一條記錄
rs("wvalue")=me1
rs("wdate")=me2
rs("wtime")=me3
rs("zxz")=me4
rs("jdh")=me5
rs("czh")=me6
rs.update‘更新數(shù)據(jù)
rs.close
me1=""
me2=""
me3=""
me4=""
me5=""
me6=""
wend
ii=ii+1
wend %>align="center">/font>font color="#FF0000">數(shù)據(jù)處理完畢!/font>
/p>
/body>
/html>

deltext.asp
html>

head>
meta http-equiv="refresh" content="30;url=txttolib.asp">
meta http-equiv="Content-Type"
content="text/html; charset=gb_2312-80">
meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
title>[刪除文件]/title>
/head>

body bgcolor="#FFFFFF">

p align="center">font color="#FF0000">正在刪除文件,請稍候!br>
/font>font color="#000000">%
dim file(50)‘定義最大文件數(shù)
str=server.mappath("/")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(str "\thetext\&;)
Set fc = f.Files
k=1
For Each f1 in fc
file(k)=f1.name
response.write file(k) "br>"
k=k+1
next
%>% i=1
while ik
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile(str "\thetext\&; file(i))
i=i+1
wend
%>/font>font color="#FF0000">文件刪除完畢!/font>/p>
/body>
/html>
這兩個小程序在NT4上作者都調(diào)試通過。但有幾點要認清,一個是文本文件大小的規(guī)劃(文本文件的數(shù)量多少也是如此),如果數(shù)據(jù)量大,那么在轉(zhuǎn)換時的時間大小要調(diào)整;二是轉(zhuǎn)換文本文件到數(shù)據(jù)庫文件時的程序調(diào)試一定要嚴謹,如果程序有誤,在數(shù)據(jù)轉(zhuǎn)換過程中沒有全部轉(zhuǎn)換,而后又刪除了這個文本文件,則會有所損失。所以這兩點一定要注意,不能馬虎。

您可能感興趣的文章:
  • php中關于codeigniter的xmlrpc的類在進行數(shù)據(jù)交換時的類型問題
  • Flash與后臺數(shù)據(jù)交換方法整理
  • 使用JavaScript構(gòu)建JSON格式字符串實現(xiàn)步驟
  • 前后臺交互過程中json格式如何解析以及如何生成
  • PHP json格式和js json格式 js跨域調(diào)用實現(xiàn)代碼
  • asp.net中各種類型的JSON格式化
  • jQuery asp.net 用json格式返回自定義對象
  • asp.net轉(zhuǎn)出json格式客戶端顯示時間
  • 在.NET使用JSON作為數(shù)據(jù)交換格式實例演示

標簽:赤峰 邢臺 南京 涼山 通遼 上海 清遠 楚雄

巨人網(wǎng)絡通訊聲明:本文標題《ASP中文本文件與數(shù)據(jù)庫文件的數(shù)據(jù)交換(FSO)》,本文關鍵詞  ASP,中,文本,文件,與,數(shù)據(jù)庫,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權(quán)與本站無關。
  • 相關文章
  • 下面列出與本文章《ASP中文本文件與數(shù)據(jù)庫文件的數(shù)據(jù)交換(FSO)》相關的同類信息!
  • 本頁收集關于ASP中文本文件與數(shù)據(jù)庫文件的數(shù)據(jù)交換(FSO)的相關信息資訊供網(wǎng)民參考!
  • 推薦文章
    平潭县| 民勤县| 黔西县| 江口县| 安图县| 眉山市| 永和县| 宣恩县| 台南县| 岳阳市| 香港 | 兴隆县| 丰县| 和林格尔县| 三都| 长沙县| 伊宁县| 上林县| 襄樊市| 宿迁市| 鸡泽县| 临洮县| 太白县| 吴川市| 岢岚县| 陆良县| 金坛市| 扶沟县| 扎兰屯市| 绥化市| 阿拉尔市| 勃利县| 滦平县| 兴隆县| 昌吉市| 改则县| 惠水县| 磴口县| 沾益县| 基隆市| 万荣县|