下面是具體的代碼: batchInput.asp % '##################################### 'File Function:批量錄入數(shù)據(jù) 'Author:Myhon 'Date:2003-8-19 '##################################### '向數(shù)據(jù)庫寫入數(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ù)庫連接 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ù)庫批量寫入數(shù)據(jù) else Call assignHowMuch() '顯示指定錄入多少條記錄的界面 end if %>