2012-01-14 80 views
0

就像yugal一样,我收到错误3704-当对象关闭时不允许操作。 请帮我解决这个问题,我的系统.. 这是我的代码:如何解决vb6.0中的运行时错误3704?

Private Sub cmdLog_Click() 
txtUser.SetFocus 
frmChange.txtusern = txtUser 
If txtUser <> "" And txtpass <> "" Then 
    **Set rsenrol = cnenrol.Execute("Select * from tblUsers where username = '" & txtUser & "'and password='" & txtpass & "'")**[this is where the error occur] 
    If csenrol.EOF = False Then 
    MsgBox "Welcome " & txtUser & "!!", vbInformation, "Welcome User" 
      txtUser = "" 
      txtpass = "" 
      Unload Me 
      MDIfrm.Show 
     Else 
     MDIfrm.Visible = False 
      MsgBox "Incorrect Username and/or Password. Please verify and Click Retry.", vbRetryCancel, "Log in Error" 
      txtpass = "" 
      txtUser.SetFocus 
      Exit Sub 
     End If 
Else 
    MsgBox "Sorry, I cannot identify you.", vbExclamation, "Intruder Alert" 
    MDIfrm.Visible = False 
    Exit Sub 
End If 
End Sub 

感谢, 亚历克斯。

+4

欢迎来到StackOverflow。你的问题很混乱。首先,你在问题标题中提及VB6,并发布VB代码,但你的标签说'android'。由于VB6和Android不混合,所以没有任何意义。其次,你说“就像Yugal”一样,但是不管你提到的是什么,所以我们知道它是什么。第三,你不会发布实际的问题,而只是一堆代码和对错误的引用。请编辑它并包含更多信息,并使用与问题相关的适当标签对其进行标记。谢谢。 – 2012-01-14 04:07:01

+0

你能告诉我们在哪一行发生错误吗? Unload.Me对我来说看起来很可疑。 – Dabblernl 2012-01-14 10:44:09

+0

所以这个错误与星星**有关? – MarkJ 2012-01-14 14:00:27

回答

4

由于您尝试使用execute命令打开“SELECT”记录集,因此出现错误,因此用于诸如“INSERT,UPDATE”等操作查询。在这种情况下,您需要使用.open命令与您的ADO记录集。

+0

+1。是的,很好的发现!我删除我的答案。 – MarkJ 2012-01-15 09:20:50

相关问题