| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1371 人关注过本帖
标题:[求助]Update语法错误!
取消只看楼主 加入收藏
kaishiuexi
Rank: 1
等 级:新手上路
帖 子:264
专家分:0
注 册:2007-6-8
收藏
 问题点数:0 回复次数:6 
[求助]Update语法错误!

'窗体中的修改操作
Private Sub cmdGuestInfoAdd_Click()
Dim sql As String
Set objGuest = New CGuest
With objGuest
.G_ID = Me.txtG_ID
.G_Name = Me.txtG_Name
.G_Linkman = Me.txtG_Linkman
.G_Duty = Me.txtG_Duty
.G_OfficePhone = Me.txtG_OfficePhone
.G_MobilePhone = Me.txtG_MobilePhone
.G_Fax = Me.txtG_Fax
.G_Address = Me.txtG_Address
.G_Cooperate = Me.txtG_Cooperate
.G_Demand = Me.txtG_Demand
.G_Maintenance = Me.txtG_Maintenance
.G_Actualize = Me.cmbG_Actualize
.G_Feedback = Me.txtG_Feedback
.G_Settle = Me.cmbG_Settle
.G_Importance = Val(Me.cmbG_Importance)
.G_Friendly = Val(Me.cmbG_Friendly)
.G_Satisfaction = Val(Me.cmbG_Satisfaction)
.G_Remark = Me.txtG_Remark
End With
'这里是添加操作
If flag = 1 Then
If objGuest.AddGuestInfoNewRecord Then
MsgBox "添加客户信息成功!", vbOKOnly + vbInformation, "添加结果"

sql = "update AutoNum set G_ID_AutoNum= G_ID_AutoNum+1" '计数器加1
TransactSQL (sql)
sql = "select G_ID_AutoNum from AutoNum" '客户编号初始化
Set rs = TransactSQL(sql)
Me.txtG_ID = "GNO." & Right(Format(1000 + rs(0)), 3)
rs.Close
Else
MsgBox "添加客户信息发生未知错误!", vbOKOnly + vbExclamation, "添加结果"
End If

'这里是修改操作
ElseIf flag = 2 Then
If objGuest.UpdateGuestInfoOldRecord Then
MsgBox "修改客户信息成功!", vbOKOnly + vbInformation, "修改结果"
flag = 1
Me.cmdGuestInfoAdd.Caption = "添加"
Me.labTitle.Caption = "添加客户信息"
Unload Me
Else
MsgBox "操作失败!"
End If
Else
MsgBox Err.Description
End If
End sub

'类模块中的部分相关代码

Public Function UpdateGuestInfoOldRecord() As Boolean
Dim strSQL As String
On Error GoTo UpdateGuestInfoOldRecord_ERROR
strSQL = "update GuestInfo set (G_Name='" & mvarG_Name
strSQL = strSQL & "',G_Linkman='" & mvarG_Linkman
strSQL = strSQL & "',G_Duty='" & mvarG_Duty
strSQL = strSQL & "',G_OfficePhone='" & mvarG_OfficePhone
strSQL = strSQL & "',G_MobilePhone='" & mvarG_MobilePhone
strSQL = strSQL & "',G_Fax='" & mvarG_Fax
strSQL = strSQL & "',G_Address='" & mvarG_Address
strSQL = strSQL & "',G_Cooperate='" & mvarG_Cooperate
strSQL = strSQL & "',G_Demand='" & mvarG_Demand
strSQL = strSQL & "',G_Maintenance=" & mvarG_Maintenance
strSQL = strSQL & ",G_Actualize='" & mvarG_Actualize
strSQL = strSQL & "',G_Feedback='" & mvarG_Feedback
strSQL = strSQL & "',G_Settle='" & mvarG_Settle
strSQL = strSQL & "',G_Importance='" & mvarG_Importance
strSQL = strSQL & "',G_Friendly='" & mvarG_Friendly
strSQL = strSQL & "',G_Satisfaction='" & mvarG_Satisfaction
strSQL = strSQL & "',G_Remark='" & mvarG_Remark
strSQL = strSQL & "' where G_ID='" & mvarG_ID & "')"
'Debug.Print strSQL
TransactSQL (strSQL)
UpdateGuestInfoOldRecord_EXIT:
'Debug.Print UpdateGuestInfoOldRecord
'UpdateGuestInfoOldRecord = True
Exit Function
UpdateGuestInfoOldRecord_ERROR:
UpdateGuestInfoOldRecord = False
End Function

附:各字段对应的变量的数据类型
Private mvarG_ID As String
Private mvarG_Name As String
Private mvarG_Linkman As String
Private mvarG_Duty As String
Private mvarG_OfficePhone As String
Private mvarG_MobilePhone As String
Private mvarG_Fax As String
Private mvarG_Address As String
Private mvarG_Cooperate As String
Private mvarG_Demand As String
Private mvarG_Maintenance As Date
Private mvarG_Actualize As String
Private mvarG_Feedback As String
Private mvarG_Settle As String
Private mvarG_Importance As Integer
Private mvarG_Friendly As Integer
Private mvarG_Satisfaction As Integer
Private mvarG_Remark As String


添加操作完全正常,修改操作总提示"Update语法错误"!

下面是Debug.Print strSQL
update GuestInfo set (G_Name='wewe',G_Linkman='wewe',G_Duty='wewe',G_OfficePhone='123',G_MobilePhone='123',G_Fax='123',G_Address='123',G_Cooperate='123',G_Demand='123',G_Maintenance=2007-2-5,G_Actualize='是',G_Feedback='123',G_Settle='否',G_Importance='2',G_Friendly='2',G_Satisfaction='2',G_Remark='2' where G_ID='GNO.007')

我被忽悠晕,大家帮我看看吧,数据库的操作代码我就不贴了!
搜索更多相关主题的帖子: Update 语法 
2007-09-23 16:06
kaishiuexi
Rank: 1
等 级:新手上路
帖 子:264
专家分:0
注 册:2007-6-8
收藏
得分:0 

完全可以!


当白天又一次把黑夜按翻在床上的时候,太阳就出生了……
2007-09-23 16:20
kaishiuexi
Rank: 1
等 级:新手上路
帖 子:264
专家分:0
注 册:2007-6-8
收藏
得分:0 
咋整?

当白天又一次把黑夜按翻在床上的时候,太阳就出生了……
2007-09-23 16:21
kaishiuexi
Rank: 1
等 级:新手上路
帖 子:264
专家分:0
注 册:2007-6-8
收藏
得分:0 
没解决

当白天又一次把黑夜按翻在床上的时候,太阳就出生了……
2007-09-23 16:21
kaishiuexi
Rank: 1
等 级:新手上路
帖 子:264
专家分:0
注 册:2007-6-8
收藏
得分:0 

代码来了:
Public Function TransactSQL(ByVal sql As String) As ADODB.Recordset
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strConnection As String
Dim strArray() As String
Set con = New ADODB.Connection '创建连接
Set rs = New ADODB.Recordset '创建记录集
On Error GoTo TransactSQL_Error
strConnection = "Provider=Microsoft.jet.oledb.4.0;Data Source=" & App.Path & "\pms.mdb"
strArray = Split(sql)
con.Open strConnection '打开连接
If StrComp(UCase$(strArray(0)), "select", vbTextCompare) = 0 Then
rs.Open Trim$(sql), con, adOpenKeyset, adLockOptimistic
Set TransactSQL = rs '返回记录集
dbFlag = 1
Else
con.Execute sql '执行命令
dbFlag = 1
End If
TransactSQL_Exit:
Set rs = Nothing
Set con = Nothing
Exit Function
TransactSQL_Error:
MsgBox "查询错误:" & Err.Description
dbFlag = 2
Resume TransactSQL_Exit
End Function

这里能出什么问题?其他模块都能正常运行,就他妈的这一点不行了!!


当白天又一次把黑夜按翻在床上的时候,太阳就出生了……
2007-09-23 16:32
kaishiuexi
Rank: 1
等 级:新手上路
帖 子:264
专家分:0
注 册:2007-6-8
收藏
得分:0 

贴出来了,大家帮忙分析一下吧,我彻底郁闷了!


当白天又一次把黑夜按翻在床上的时候,太阳就出生了……
2007-09-23 16:52
kaishiuexi
Rank: 1
等 级:新手上路
帖 子:264
专家分:0
注 册:2007-6-8
收藏
得分:0 

哎,我换成SQLSERVER数据库就没事了,邪了门了!!!


当白天又一次把黑夜按翻在床上的时候,太阳就出生了……
2007-09-23 17:17
快速回复:[求助]Update语法错误!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016589 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved