| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1371 人关注过本帖
标题:[求助]Update语法错误!
只看楼主 加入收藏
kaishiuexi
Rank: 1
等 级:新手上路
帖 子:264
专家分:0
注 册:2007-6-8
收藏
 问题点数:0 回复次数:17 
[求助]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
purana
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:广东-广州
等 级:版主
威 望:66
帖 子:6039
专家分:0
注 册:2005-6-17
收藏
得分:0 
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-9-23 16:14:47编辑过]


我的msn: myfend@
2007-09-23 16:08
缘吇弹
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:地球
等 级:版主
威 望:43
帖 子:3038
专家分:27
注 册:2007-7-2
收藏
得分:0 
"看能不能成功先"

Repeat  Life=Study;Until (death);
2007-09-23 16:14
purana
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:广东-广州
等 级:版主
威 望:66
帖 子:6039
专家分:0
注 册:2005-6-17
收藏
得分:0 
晕晕.

我的msn: myfend@
2007-09-23 16:15
缘吇弹
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:地球
等 级:版主
威 望:43
帖 子:3038
专家分:27
注 册:2007-7-2
收藏
得分:0 
我刚才是校正你1#的错误

Repeat  Life=Study;Until (death);
2007-09-23 16:16
缘吇弹
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:地球
等 级:版主
威 望:43
帖 子:3038
专家分:27
注 册:2007-7-2
收藏
得分:0 

准确说应该是错别字


Repeat  Life=Study;Until (death);
2007-09-23 16:16
kaishiuexi
Rank: 1
等 级:新手上路
帖 子:264
专家分:0
注 册:2007-6-8
收藏
得分:0 

完全可以!


当白天又一次把黑夜按翻在床上的时候,太阳就出生了……
2007-09-23 16:20
缘吇弹
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:地球
等 级:版主
威 望:43
帖 子:3038
专家分:27
注 册:2007-7-2
收藏
得分:0 
问题解决了?

[此贴子已经被作者于2007-9-23 16:21:33编辑过]


Repeat  Life=Study;Until (death);
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 
没解决

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



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

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