vb高手进来,帮我看看代码,运行时输入添加信息后,在表格中显示不出添加的信息,刷新也没,怎么回事啊 100
PrivateSubLblAdd_Click()'标明操作为添加而非修改FrmUsersEdit.Modify=False'显示用户信息编辑窗口FrmUsersEdit....
Private Sub LblAdd_Click()
'标明操作为添加而非修改
FrmUsersEdit.Modify = False
'显示用户信息编辑窗口
FrmUsersEdit.Show 1
'刷新系统用户管理界面
Refresh_Users
End Sub
Public Modify As Boolean
Public OriName As String
Private Sub LblOK_Click()
'判断要编辑信息是否完整
If Check = False Then
'如果不完整或设置不符合规定则跳出函数
Exit Sub
End If
With MyUsers
'给MyUsers对象的参数赋值
.Name = TxtName.Text
.Password = TxtPassword.Text
If List1.Selected(1) = True Then
.EngineerUse = "有权限"
Else
.EngineerUse = "无权限"
End If
If List1.Selected(2) = True Then
.PurchaseUse = "有权限"
Else
.PurchaseUse = "无权限"
End If
If List1.Selected(3) = True Then
.SalesUse = "有权限"
Else
.SalesUse = "无权限"
End If
If List1.Selected(4) = True Then
.StocksUse = "有权限"
Else
.StocksUse = "无权限"
End If
If List1.Selected(5) = True Then
.ManpowerUse = "有权限"
Else
.ManpowerUse = "无权限"
End If
If List1.Selected(6) = True Then
.ClientUse = "有权限"
Else
.ClientUse = "无权限"
End If
If List1.Selected(0) = True Then
.ManageUse = "有权限"
Else
.ManageUse = "无权限"
End If
'判断操作是添加还是修改
If Modify = False Then '判断为添加操作
'判断该用户名是否已经有人使用
If .In_DB(TxtName.Text) = True Then '如果已经存在
MsgBox "用户名已存在,请重新设置"
TxtName.SetFocus
TxtName.SelStart = 0
TxtName.SelLength = Len(TxtName)
Exit Sub
Else '如果不存在
.Insert '执行添加操作
MsgBox "添加成功"
End If
Else '判断为修改操作
.Update (OriName) '存储修改后的纪录
MsgBox "修改成功"
End If
End With
Unload Me
End Sub
Public Sub Insert()
'连接数据库
MyDB.openDB
'设置Insert语句
SqlStmt = "INSERT INTO Users (Name, Password,EngineerUse,PurchaseUse,SalesUse,StocksUse,ManpowerUse,ClientUse,ManageUse)" _
+ " Values('" + Trim(Name) + "','" + Trim(Password) _
+ "','" + Trim(EngineerUse) + "','" + Trim(PurchaseUse) _
+ "','" + Trim(SalesUse) + "','" + Trim(StocksUse) _
+ "','" + Trim(ManpowerUse) + "','" + Trim(ClientUse) _
+ "','" + Trim(ManageUse) + "')"
'执行SQL语句
Dim Isexe As Boolean
Dim rsUsers As ADODB.Recordset
Isexe = MyDB.exeSql(SqlStmt, rsUsers, True)
'断开与数据库的连接
MyDB.closeDB
End Sub 展开
'标明操作为添加而非修改
FrmUsersEdit.Modify = False
'显示用户信息编辑窗口
FrmUsersEdit.Show 1
'刷新系统用户管理界面
Refresh_Users
End Sub
Public Modify As Boolean
Public OriName As String
Private Sub LblOK_Click()
'判断要编辑信息是否完整
If Check = False Then
'如果不完整或设置不符合规定则跳出函数
Exit Sub
End If
With MyUsers
'给MyUsers对象的参数赋值
.Name = TxtName.Text
.Password = TxtPassword.Text
If List1.Selected(1) = True Then
.EngineerUse = "有权限"
Else
.EngineerUse = "无权限"
End If
If List1.Selected(2) = True Then
.PurchaseUse = "有权限"
Else
.PurchaseUse = "无权限"
End If
If List1.Selected(3) = True Then
.SalesUse = "有权限"
Else
.SalesUse = "无权限"
End If
If List1.Selected(4) = True Then
.StocksUse = "有权限"
Else
.StocksUse = "无权限"
End If
If List1.Selected(5) = True Then
.ManpowerUse = "有权限"
Else
.ManpowerUse = "无权限"
End If
If List1.Selected(6) = True Then
.ClientUse = "有权限"
Else
.ClientUse = "无权限"
End If
If List1.Selected(0) = True Then
.ManageUse = "有权限"
Else
.ManageUse = "无权限"
End If
'判断操作是添加还是修改
If Modify = False Then '判断为添加操作
'判断该用户名是否已经有人使用
If .In_DB(TxtName.Text) = True Then '如果已经存在
MsgBox "用户名已存在,请重新设置"
TxtName.SetFocus
TxtName.SelStart = 0
TxtName.SelLength = Len(TxtName)
Exit Sub
Else '如果不存在
.Insert '执行添加操作
MsgBox "添加成功"
End If
Else '判断为修改操作
.Update (OriName) '存储修改后的纪录
MsgBox "修改成功"
End If
End With
Unload Me
End Sub
Public Sub Insert()
'连接数据库
MyDB.openDB
'设置Insert语句
SqlStmt = "INSERT INTO Users (Name, Password,EngineerUse,PurchaseUse,SalesUse,StocksUse,ManpowerUse,ClientUse,ManageUse)" _
+ " Values('" + Trim(Name) + "','" + Trim(Password) _
+ "','" + Trim(EngineerUse) + "','" + Trim(PurchaseUse) _
+ "','" + Trim(SalesUse) + "','" + Trim(StocksUse) _
+ "','" + Trim(ManpowerUse) + "','" + Trim(ClientUse) _
+ "','" + Trim(ManageUse) + "')"
'执行SQL语句
Dim Isexe As Boolean
Dim rsUsers As ADODB.Recordset
Isexe = MyDB.exeSql(SqlStmt, rsUsers, True)
'断开与数据库的连接
MyDB.closeDB
End Sub 展开
3个回答
展开全部
查看你的INSERT语句,将SqlStmt的值复制到查询设计器中执行一下,看一看是不是有问题。
追问
是有问题的。
服务器: 消息 170,级别 15,状态 1,行 1
第 1 行: '=' 附近有语法错误。
可是我不会修改
追答
加QQ250585158给你调试一下。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
HI我,我帮你调试一下
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询