[求助]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')
我被忽悠晕,大家帮我看看吧,数据库的操作代码我就不贴了!