-
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
-
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.
-
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)
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks