主题:  再次犯傻~

coolbee1121

职务:普通成员
等级:1
金币:0.0
发贴:69
注册:2001/6/3 22:32:02
#12001/9/17 0:10:43
怕麻烦~直接把代码帖出来好了~

数据库什么的都没连接错误, 就是最后提交时报116行出错~高人给看看吧~
<%@LANGUAGE="VBSCRIPT"%>

<%
' *** Edit Operations: declare variables

MM_editAction = CStr(Request("URL"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Redirect if username exists
MM_flag="MM_insert"
If (CStr(Request(MM_flag)) <> "") Then
MM_dupKeyRedirect="regErr.asp"
MM_rsKeyConnection=MM_memberDB_STRING
MM_dupKeyUsernamevalue = CStr(Request.Form("regName"))
MM_dupKeySQL="SELECT loginName FROM tbMembers WHERE loginName='" & MM_dupKeyUsernamevalue & "'"
MM_adodbRecordset="ADODB.Recordset"
set MM_rsKey=Server.CreateObject(MM_adodbRecordset)
MM_rsKey.ActiveConnection=MM_rsKeyConnection
MM_rsKey.Source=MM_dupKeySQL
MM_rsKey.CursorType=0
MM_rsKey.CursorLocation=2
MM_rsKey.LockType=3
MM_rsKey.Open
If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then
' the username was found - can not add the requested username
MM_qsChar = "?"
If (InStr(1,MM_dupKeyRedirect,"?") >= 1) Then MM_qsChar = "&"
MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "requsername=" & MM_dupKeyUsernamevalue
Response.Redirect(MM_dupKeyRedirect)
End If
MM_rsKey.Close
End If
%>
<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) <> "") Then

MM_editConnection = MM_memberDB_STRING
MM_editTable = "tbMembers"
MM_editRedirectUrl = "regOk.asp"
MM_fieldsStr = "regName|value|regPwd|value"
MM_columnsStr = "loginName|',none,''|password|',none,''"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")

' set the form values
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If

End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it

If (CStr(Request("MM_insert")) <> "") Then

' create the sql insert statement
MM_tablevalues = ""
MM_dbvalues = ""
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),",")
Delim = MM_typeArray(0)
If (Delim = "none") Then Delim = ""
AltVal = MM_typeArray(1)
If (AltVal = "none") Then AltVal = ""
EmptyVal = MM_typeArray(2)
If (EmptyVal = "none") Then EmptyVal = ""
If (FormVal = "") Then
FormVal = EmptyVal
Else
If (AltVal <> "") Then
FormVal = AltVal
ElseIf (Delim = "'") Then ' escape quotes
FormVal = "'" & Replace(FormVal,"'","''") & "'"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_tablevalues = MM_tablevalues & ","
MM_dbvalues = MM_dbvalues & ","
End if
MM_tablevalues = MM_tablevalues & MM_columns(i)
MM_dbvalues = MM_dbvalues & FormVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tablevalues & ") values (" & MM_dbvalues & ")"

If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>


SignUp to 9911


























用户名:



(15位以内英文或数字, 禁用中文)

密码:



(15位以内英文/ 数字/ 特殊符号)









 







绿茶

职务:普通成员
等级:8
金币:10.0
发贴:19267
注册:2000/12/28 12:10:01
#22001/9/17 7:43:06
不要贴由UD产生的代码,这么长的一篇,我一看到它就头大!!



tonton_5d

职务:普通成员
等级:2
金币:1.0
发贴:176
注册:2001/8/7 23:57:56
#32001/9/17 8:39:52
germchen在上个帖子中说
引用:
不要贴由UD产生的代码,这么长的一篇,我一看到它就头大!!


说得很对。UD这东西,明明很简单的问题,它却要搞得那么复杂(谁叫它要考虑兼容性啊)。


免费提供XML计数器服务 www.tonton.cn

coolbee1121

职务:普通成员
等级:1
金币:0.0
发贴:69
注册:2001/6/3 22:32:02
#42001/9/17 19:53:06
天~
没有解决办法??



tonton_5d

职务:普通成员
等级:2
金币:1.0
发贴:176
注册:2001/8/7 23:57:56
#52001/9/17 22:21:33
我已经帮你重写了一遍。。
代码量还没有上面的六分之一多。

哎。。。。UD啊UD。。想让我爱你都很难。。。。


免费提供XML计数器服务 www.tonton.cn