Operation is not allowed on an object...


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Operation is not allowed on an object...

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    Operation is not allowed on an object...

    [Originally posted by David]

    I'm trying to connect to a DB remotely and in my SQL Select statement I get the run time error:

    Operation is not allowed on an object referencing a closed or invalid connection.

    My code is below. What possible things could be causing this so I can start trouble shooting?

    I have DSN and ODBC connection setup on a win2000 machine.



    Public Sub cmdOK_Click()

    Set cnnGeneric = New ADODB.Connection

    cnnGeneric.Open "Provider=MS Remote;" _
    & "Remote Provider=MSDataShape;" _
    & "Remote Server=http://MyIpAdressHere;" _
    & "Data Source=MyDSNname;"

    Set rsGeneric = New ADODB.Recordset

    rsGeneric.CursorLocation = adUseClient
    rsGeneric.Open ("SELECT UserName, Password From tblUsers Where Username = '" & txtUserName.Text & "' AND Password = '" & txtPassword & "'")

    If rsGeneric.EOF Then
    MsgBox "Invalid Username or Password"
    rsGeneric.ActiveConnection = Nothing
    Exit Sub
    Else

    frmMain.Show
    Unload Me
    End If
    End Sub

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Operation is not allowed on an object...

    [Originally posted by FreeVBCode.com]

    You have to pass cnnGeneric as the 2nd argument to the open method of the recordset.

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Operation is not allowed on an object...

    [Originally posted by David]

    Whenever I do that I always get Expected "="

    Is it my syntax?

    rsGeneric.Open ("SELECT UserName, Password From tblUsers Where Username = '" & txtUserName.Text & "' AND Password = '" & txtPassword & "'",cnnGeneric)

  4. #4
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Re:Operation is not allowed on an object...

    [Originally posted by FreeVBCode.com]

    Try getting rid of the parantheses.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center