asp循环插入文本域内容的问题 10
按照百度出来的一个方法,循环添加记录集的内容,结果多个字段都加入到一个字段里面,请问是怎么回事呢?代码如下:dreamweaver基础上改的If(CStr(Request...
按照百度出来的一个方法,循环添加记录集的内容,结果多个字段都加入到一个字段里面,请问是怎么回事呢?
代码如下:dreamweaver基础上改的
If (CStr(Request("MM_insert")) = "form1") Then
If (Not MM_abortEdit) Then
' execute the insert
Dim MM_editCmd
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_conntest_STRING
MM_editCmd.CommandText = "INSERT INTO test (user_name, user_password, user_permission) VALUES (?, ?, ?)"
MM_editCmd.Prepared = true
for i=1 to request.form("textfield").count
textfield=request.form("textfield")(i)
textfield2=request.form("textfield2")(i)
textfield3=request.form("textfield3")(i)
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 50, Request.Form("textfield")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 50, Request.Form("textfield2")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 20, Request.Form("textfield3")) ' adVarWChar
MM_editCmd.Execute
next
MM_editCmd.ActiveConnection.Close
End If
End If
结果如下:
谢谢! 展开
代码如下:dreamweaver基础上改的
If (CStr(Request("MM_insert")) = "form1") Then
If (Not MM_abortEdit) Then
' execute the insert
Dim MM_editCmd
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_conntest_STRING
MM_editCmd.CommandText = "INSERT INTO test (user_name, user_password, user_permission) VALUES (?, ?, ?)"
MM_editCmd.Prepared = true
for i=1 to request.form("textfield").count
textfield=request.form("textfield")(i)
textfield2=request.form("textfield2")(i)
textfield3=request.form("textfield3")(i)
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 50, Request.Form("textfield")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 50, Request.Form("textfield2")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 20, Request.Form("textfield3")) ' adVarWChar
MM_editCmd.Execute
next
MM_editCmd.ActiveConnection.Close
End If
End If
结果如下:
谢谢! 展开
1个回答
展开全部
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 50, Request.Form("textfield")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 50, Request.Form("textfield2")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 20, Request.Form("textfield3")) ' adVarWChar
改为
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 50, textfield) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 50, textfield2) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 20, textfield3) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 50, Request.Form("textfield2")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 20, Request.Form("textfield3")) ' adVarWChar
改为
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 50, textfield) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 50, textfield2) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 20, textfield3) ' adVarWChar
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询