VB提示:实时错误3704,对象关闭时,不允许操作。
OptionExplicitPrivateSubCommand1_Click()DimrstBookStyleAsNewADODB.RecordsetDimsqlAsSt...
Option Explicit
Private Sub Command1_Click()
Dim rstBookStyle As New ADODB.Recordset
Dim sql As String
Dim msg As String
If Trim(namee.Text) = "" Then
MsgBox "请输入个人姓名!", 0 + 48, "警告!"
namee.SetFocus
Exit Sub
End If
If Trim(sex.Text) = "" Then
MsgBox "请输入性别!", 0 + 48, "警告!"
sex.SetFocus
Exit Sub
End If
sql = "select * from 个人信息 where 姓名='" & namee.Text & "'"
Set rstBookStyle = ExeRecordset(sql, msg)
If rstBookStyle.EOF Then
sql = "insert into 个人信息(姓名,性别) values('" & namee.Text & "','" & sex.Text & "')"
ExeNonQuery sql, msg
MsgBox " 添加个人信息成功!", 0 + 64, "消息!"
rstBookStyle.Close
namee.Text = ""
sex.Text = ""
Else
MsgBox " 个人信息重复!", 0 + 64, "消息!"
namee.SetFocus
namee.Text = ""
rstBookStyle.Close
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
--------------------------------------------------------
If rstBookStyle.EOF Then 这一句显示黄色,出现错误提示. 展开
Private Sub Command1_Click()
Dim rstBookStyle As New ADODB.Recordset
Dim sql As String
Dim msg As String
If Trim(namee.Text) = "" Then
MsgBox "请输入个人姓名!", 0 + 48, "警告!"
namee.SetFocus
Exit Sub
End If
If Trim(sex.Text) = "" Then
MsgBox "请输入性别!", 0 + 48, "警告!"
sex.SetFocus
Exit Sub
End If
sql = "select * from 个人信息 where 姓名='" & namee.Text & "'"
Set rstBookStyle = ExeRecordset(sql, msg)
If rstBookStyle.EOF Then
sql = "insert into 个人信息(姓名,性别) values('" & namee.Text & "','" & sex.Text & "')"
ExeNonQuery sql, msg
MsgBox " 添加个人信息成功!", 0 + 64, "消息!"
rstBookStyle.Close
namee.Text = ""
sex.Text = ""
Else
MsgBox " 个人信息重复!", 0 + 64, "消息!"
namee.SetFocus
namee.Text = ""
rstBookStyle.Close
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
--------------------------------------------------------
If rstBookStyle.EOF Then 这一句显示黄色,出现错误提示. 展开
1个回答
展开全部
sql = "select * from 个人信息 where 姓名='" & namee.Text & "'"
Set rstBookStyle = ExeRecordset(sql, msg)
'主要是没有返回对象,先查看sql串有没问题,我看着namee 别扭,是不是name啊? 再查看msg信息。这两句下面打句:debug.print sql,msg ,运行时在立即窗口查看这两个变量。
如果自己找不出原因可以把工程发来让我试试,2978454279@qq.com,代码上实在看不出问题。
Set rstBookStyle = ExeRecordset(sql, msg)
'主要是没有返回对象,先查看sql串有没问题,我看着namee 别扭,是不是name啊? 再查看msg信息。这两句下面打句:debug.print sql,msg ,运行时在立即窗口查看这两个变量。
如果自己找不出原因可以把工程发来让我试试,2978454279@qq.com,代码上实在看不出问题。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询