主题:  一次更新多个表中的记录,为什么出现错误?

看我的资料

职务:普通成员
等级:1
金币:0.0
发贴:81
注册:2003/5/24 12:06:05
#12003/6/6 21:21:18
我是完全按照教程http://km.kmyouth.com.cn/txbook/gbook/tutorial/ct01/ct01_index.htm
作的,但是有问题?
(没有1.asp,是)

Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e14'

[Microsoft][ODBC Microsoft Access Driver] UPDATE 语句的语法错误。



{ 在指尖上绽放的花朵 }

职务:普通成员
等级:5
金币:14.0
发贴:3209
注册:2002/7/25 21:24:11
#22003/6/6 21:25:04
update语句怎样写的呢?



看我的资料

职务:普通成员
等级:1
金币:0.0
发贴:81
注册:2003/5/24 12:06:05
#32003/6/6 21:31:33
教程中没有要写update语句,所有语句都是dw mx自动生成的



{ 在指尖上绽放的花朵 }

职务:普通成员
等级:5
金币:14.0
发贴:3209
注册:2002/7/25 21:24:11
#42003/6/6 21:33:59
给我看一下源代码?

编辑历史:[这消息被行者编辑过(编辑时间2003-06-06 21:34:24)]


看我的资料

职务:普通成员
等级:1
金币:0.0
发贴:81
注册:2003/5/24 12:06:05
#52003/6/6 22:01:13
经过多次修改,现在变成:
Microsoft OLE DB Provider for ODBC Drivers 错误 '80004005'

[Microsoft][ODBC Microsoft Access Driver] 字段 'kp_qz_fy.rizhi_id' 不能是零长度的字符串。

请指教,谢谢!!



看我的资料

职务:普通成员
等级:1
金币:0.0
发贴:81
注册:2003/5/24 12:06:05
#62003/6/6 22:04:56
哦,是数据库设置的问题,打扰了。



不是高手

职务:普通成员
等级:3
金币:5.0
发贴:1352
注册:2002/8/23 2:27:18
#72003/6/7 12:52:54
数据库里是不是设置了某字段不能为空,但是提交的值里这个字段是个空值?



看我的资料

职务:普通成员
等级:1
金币:0.0
发贴:81
注册:2003/5/24 12:06:05
#82003/6/7 18:55:30
是的!!高手还是高手!不过,现在有了新的问题,数据库不能更新,不知道是什么原因,真奇怪!!!还得有劳高手,真不好意思,谢谢。代码如下:
<%

if(request.form("rizhi_id") <> "") then
Command1__varrizhi_id = request.form("rizhi_id")
end if

if(request.form("user") <> "") then
Command1__varuser = request.form("user")
end if

%>


<%

set Command1 = Server.CreateObject("ADODB.Command")
Command1.ActiveConnection = MM_ldbc_fy_STRING
Command1.CommandText = "UPDATE kp_qz_fy SET rizhi_id = '" + Replace(Command1__varrizhi_id, "'", "''") + "' WHERE user = '" + Replace(Command1__varuser, "'", "''") + "' "
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()
set command1=nothing
%>




我佛山人

职务:版主
等级:4
金币:16.0
发贴:2269
注册:2002/8/7 15:09:27
#92003/6/7 19:47:25
Command1.CommandText = "UPDATE kp_qz_fy SET rizhi_id = '" + Replace(Command1__varrizhi_id, "'", "''") [color=#FF0000]+[/color] "' WHERE user = '" + Replace(Command1__varuser, "'", "''") [color=#FF0000]+[/color] "' "


看你的代码,脚本语言好象是VBScript,怎么用+ ,改成& 看看~~



看我的资料

职务:普通成员
等级:1
金币:0.0
发贴:81
注册:2003/5/24 12:06:05
#102003/6/7 21:38:43
脚本语言是VBScript,先前还好的,但是现在不了!!
我把+改成了&也不行呀,到底是什么问题呀??



我佛山人

职务:版主
等级:4
金币:16.0
发贴:2269
注册:2002/8/7 15:09:27
#112003/6/7 22:42:34
具体的错误提示呢?



看我的资料

职务:普通成员
等级:1
金币:0.0
发贴:81
注册:2003/5/24 12:06:05
#122003/6/7 22:53:19
没有提示,提交成功,就是数据库不更新!我在代码当中搜了一下,好像没有调用command1的程序,如:onclick之类的,而且,有这样的语句居然在运行时也不提示错误,我真的不明白了!请教?
<%
if(request.form("rizhi_id") <> "") then Command1__varrizhi_id = request.form("rizhi_id")
if(request.form("user") <> "") then Command1__varuser = request.form("user")
%>

没有end if语句块!!上面的end if是我加上去的!



看我的资料

职务:普通成员
等级:1
金币:0.0
发贴:81
注册:2003/5/24 12:06:05
#132003/6/7 23:18:10
还有,我的代码和教程有不同的地方:
action="<%=MM_editAction%>" 教程是:action=1.asp



缺缺

职务:管理员
等级:8
金币:41.0
发贴:9620
注册:2004/1/14 19:14:47
#142003/6/8 12:34:36
if then在一行时不需要end if

还有command是服务器端满足条件是执行的,不是和客户端通过事件触发的,你把他和js弄混了。

以上代码完整么?是整个文件的代码?



看我的资料

职务:普通成员
等级:1
金币:0.0
发贴:81
注册:2003/5/24 12:06:05
#152003/6/8 16:03:54
以下是全部代码:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>



<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
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 = ""
%>
<%
' *** Update Record: set variables

If (CStr(Request("MM_update")) = "form1" And CStr(Request("MM_recordId")) <> "") Then

MM_editConnection = MM_ldbc_fy_STRING
MM_editTable = "gj_fy"
MM_editColumn = "ID"
MM_recordId = "" + Request.Form("MM_recordId") + ""
MM_editRedirectUrl = "gj_diaodong_ok.asp"
MM_fieldsStr = "danwei|value|user|value|jibie|value|time_renzhi|value|zhiwu|value|sex|value|time_chusheng|value|time_gongzuo|value|time_rudang|value|jieguan|value|minzhu|value|wenhua|value|zhuanye|value|gongzi|value|faguandengji|value"
MM_columnsStr = "ID_danwei|none,none,NULL|user|',none,''|jibie|',none,''|time_renzhi|none,none,NULL|zhiwu|',none,''|sex|',none,''|time_chusheng|none,none,NULL|time_gongzuo|none,none,NULL|time_rudang|none,none,NULL|jieguan|',none,''|minzhu|',none,''|wenhua|',none,''|zhuanye|',none,''|gongzi|',none,''|faguandengji|',none,''"

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

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_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
%>
<%
' *** Update Record: construct a sql update statement and execute it

If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then

' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId

If (Not MM_abortEdit) Then
' execute the update
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
%>
<%
if(request.form("rizhi_id") <> "") then Command1__varrizhi_id = request.form("rizhi_id")
if(request.form("user") <> "") then Command1__varuser = request.form("user")
%>
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.QueryString("ID") <> "") Then
Recordset1__MMColParam = Request.QueryString("ID")
End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_ldbc_fy_STRING
Recordset1.Source = "SELECT gj_fy.*,kp_qz_fy.rizhi_id,danwei.danwei FROM gj_fy,kp_qz_fy,danwei WHERE gj_fy.ID = " + Replace(Recordset1__MMColParam, "'", "''") + " and gj_fy.user=kp_qz_fy.user and gj_fy.ID_danwei=danwei.id_danwei"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%

set Command1 = Server.CreateObject("ADODB.Command")
Command1.ActiveConnection = MM_ldbc_fy_STRING
Command1.CommandText = "UPDATE kp_qz_fy SET rizhi_id = '" + Replace(Command1__varrizhi_id, "'", "''") + "' WHERE user = '" + Replace(Command1__varuser, "'", "''") + "'"
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()
set command1=nothing
%>




澧县法院联带包创星级管理





































澧县人民法院联带包创星级管理站点



 







































































首页>>管理入口>>修改干警的基本情况




修改干警的基本情况




































































所属单位:
姓 名: " size="32">
级 别: " size="32">
任现职时间: " size="32">
职 务: " size="32">
性 别: " size="3">
日志编号:
" size="10">
出生时间: " size="32">
参加工作时间: " size="32">
入党时间: " size="32">
籍 贯: " size="5">
民 族: " size="4">
文化程度: " size="4">
所学专业: " size="8">
工资级别: " size="32">
法官等级: " size="32">
 




">

 






返回>>  
 














color=#ffffff>  color=#ffffff face="Geneva, Arial, Helvetica, san-serif">Copyright ©
2003 澧县人民法院联带包创星级管理领导小组

color=#ffffff>



<%
Recordset1.Close()
Set Recordset1 = Nothing
%>