2008年(60)
分类: 系统运维
2008-03-21 15:27:02
<%
'申明变量
Dim valName
Dim arrName
Dim objConn
Dim connStr
If Request.Form("mySubmit") = "确定" Then
'数据库链接代码
set objConn=server.CreateObject("ADODB.connection")
connStr = "PROVIDER=SQLOLEDB;Server=(local);DATABASE=test;UID=sa;PWD=123456;"
objConn.Open connstr
'取得值
valName = Cstr(Request.Form("myName"))
'插入数据库
arrName = split(valName,",")
arrPassword = split(valPassword,",")
'执行插入数据库的过程
For i = 0 to Ubound(arrName)
'请自行更改SQL语句
objConn.execute("insert into mytable(sname) values('"&Trim(arrName(i))&"')")
Next
Response.write("数据插入成功")
'关闭数据库连接
objConn.close
Set objConn = nothing
End If
%>