关于数据库的问题(sql 05)

cedvfr 2010-10-05 03:48:31
我的面板上有两个text框 txt1 和txt2 两个按钮 确定 和 取消 我想实现的功能是用 rdo连接 在输入完text框的值时点击确定 将两个text框的值写进数据库的对应的表里 库名 comeet 表名是 test 字段是 usern 和 password

Private mrdoCon As rdoConnection
Dim mRes As rdoResultset
Dim mSQL As String
Private Sub Command1_Click()
If txt1.Text = "" Or txt2.Text = "" Then
MsgBox "原因或类型不能为空!", vbCritical, "错误"
Else
mrdoCon.Execute "update test set [usern ] = '" & txt1 & "' ,usern = " & txt2 & " where RStyle='" & curRstyle & "'"
End If
End Sub

运行时报错了 说是with变量未设置 请问各位这是怎么回事?

...全文
27 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
cnuser1 2010-10-14

Private Sub cmdSave_Click()
Dim UpdateSql As String
Dim UpdateCommand As New ADODB.Command
On Error GoTo eNext:
UpdateSql = "update tabPowerRange set " + _
"RatedPower=" + Trim(txtRatedPower.Text) + "," + _
"Ratedv=" + Trim(txtRatedV.Text) + " where id=" & Trim(txtID.Text)
UpdateCommand.ActiveConnection = SqlConn
UpdateCommand.CommandType = adCmdText
UpdateCommand.CommandText = UpdateSql
UpdateCommand.Execute

Call frmMain.ReLoadData
MsgBox "Update Success...", vbInformation, App.Title

Unload Me
eNext:
MsgBox Err.Description, vbCritical, Err.Number
End Sub

回复
zzhgb 2010-10-06
加new,这是类
Private mrdoCon As New rdoConnection
回复
饮水需思源 2010-10-05
mrdoCon还没有与数据库连接
回复
lxq19851204 2010-10-05

Private mrdoCon As rdoConnection
Dim mRes As rdoResultset
Dim mSQL As String
Private Sub Command1_Click()
If txt1.Text = "" Or txt2.Text = "" Then
MsgBox "原因或类型不能为空!", vbCritical, "错误"
Else
mrdoCon.Execute "update test set [usern] = '" & txt1.text & "',password= '" & txt2.text & "' where RStyle='" & curRstyle & "'"
End If
End Sub
回复
相关推荐
发帖

1188

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2010-10-05 03:48
社区公告
暂无公告