国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > ASP > 正文

asp實(shí)現(xiàn)批量錄入數(shù)據(jù)的實(shí)現(xiàn)

2020-07-27 13:21:13
字體:
供稿:網(wǎng)友
批量錄入在數(shù)據(jù)庫(kù)的應(yīng)用中比較廣泛的,關(guān)于批量錄入的方法也有好多種。下面我就結(jié)合我實(shí)際中的應(yīng)用,談一下兒我是怎么實(shí)現(xiàn)的。主要用到的是form的集合的概念,通過循環(huán)取的所有的集合內(nèi)數(shù)據(jù)。考慮到大家看著方便,我把它集成到了一個(gè)頁(yè)面。 

下面是具體的代碼:  
batchInput.asp 
<% 
'##################################### 
'File Function:批量錄入數(shù)據(jù) 
'Author:Myhon 
'Date:2003-8-19 
'##################################### 
'向數(shù)據(jù)庫(kù)寫入數(shù)據(jù) 
SUB writeData() 
dim recCnt,i 
dim fieldName1,fieldName2,fieldName3 
dim conn 
dim sqlStr,connStr 
connStr="Provider=SQLOLEDB.1;Initial Catalog=myDatabase;Data Source=myhon;User Id=sa;PASSWORD=" 
set conn=Server.CreateObject("ADODB.Connection") 
conn.open connStr '建立數(shù)據(jù)庫(kù)連接 
recCnt=request.form("stu_num").count '取得共有多少條記錄 
'批量錄入數(shù)據(jù) 
for i=1 to recCnt 
fieldName1=trim(request.form("fieldName1")(i)) 
fieldName2=trim(request.form("fieldName2")(i)) 
fieldName3=trim(request.form("fieldName3")(i)) 
sqlStr="insert into myTable(fieldName1,fieldName2,fieldName3) values('" 
sqlStr=sqlStr & fieldName1 & "','" 
sqlStr=sqlStr & fieldName2 & "','" 
sqlStr=sqlStr & fieldName3 & "')" 
'response.write sqlStr 
conn.execute(sqlStr) 
next 
END SUB 
'顯示成批錄入的界面 
SUB InputData() 
dim recCnt,i 
%> 
<form name="bathInputData" action="" method="post"> 
<%  
recCnt=cint(request.form("recCnt")) 
for i=1 to recCnt 
%> 
<input type="text" name="fieldName1"> 
<input type="text" name="fieldName2"> 
<input type="text" name="fieldName3"> 
<% 
next 
%> 
<br> 
<input type="submit" name="action" value="提交"> 
</form> 
<% 
END SUB 
'指定要批量錄入多少條記錄 
SUB assignHowMuch() 
%> 
<!------指定要錄入多少條記錄--------------> 
<form name="form1" action="" method="post"> 
您要錄入的記錄的條數(shù):<input type="text" name="recCnt"> 
<input type="submit" name="action" value="下一步>>"> 
</form> 
<% 
END SUB 
if request.form("action")="下一步>>" then 
Call InputData() '顯示成批錄入界面 
elseif request.form("action")="提交" then Call writeData() '向數(shù)據(jù)庫(kù)批量寫入數(shù)據(jù) 
else 
Call assignHowMuch() '顯示指定錄入多少條記錄的界面 
end if 
%>
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 遂宁市| 岳西县| 泗洪县| 乳源| 合阳县| 元朗区| 土默特左旗| 龙泉市| 榆树市| 荔浦县| 中西区| 余江县| 陆川县| 苍南县| 翼城县| 乌鲁木齐市| 亚东县| 烟台市| 多伦县| 修文县| 达孜县| 南丹县| 甘洛县| 舟山市| 邵武市| 铁岭县| 松溪县| 泗阳县| 长沙市| 万源市| 分宜县| 泾源县| 金昌市| 巫山县| 洛宁县| 通河县| 宾阳县| 三都| 黑龙江省| 聊城市| 宽城|