[求助]这个程序中有错误,怎么改
这个程序为什么错?请帮我看看 Private Sub Command1_Click() Dim rsclass As New ADODB.Recordset Dim sql As String If Trim(Txtclass.Text) = "" Then MsgBox "班级不能为空", vbOKOnly + vbExclamation, "" Txtclass.SetFocus Exit Sub End If If Trim(Txtdep.Text) = "" Then MsgBox "所在系不能为空", vbOKOnly + vbExclamation, "" Txtdep.SetFocus Exit Sub End If sql = "select * from class where name='" & Txtclass.Text & "'" rsclass.Open sql, Dataenv.con 错误提示:连接无法用于执行次操作,在次上下文中他可能已被关闭或无效。 If rsclass.EOF Then rsclass.AddNew rsclass.Fields(0) = Trim(Txtclass.Text) rsclass.Fields(1) = Trim(Txtdep.Text) rsclass.Update MsgBox "添加信息成功!", vbOKOnly, "" rsclass.Close Else MsgBox "班级重复!", vbOKOnly + vbExclamation, "" Txtclass.SetFocus Txtclass.Text = "" rxtclass.Close Exit Sub End If End Sub |