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 ’建立数据库连接
reccnt=request.form("stu_num").count ’取得共有多少条记录
’批量录入数据
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>
首页 1 2 末页