Saturday, February 25, 2012

Connection Error

Hi,

I have developed a program which connects to an SQL Express 2005 server. This worked fine until yesterday when the server failed. I have set up a new server, same name, config, etc and restored the data back into the database.

When the program runs it displays an error:

System.Runtime.InteropServices.COMException (0x800A0E7D): The connection cannot be used to perform this operation. It is either closed or invalid in this context.

Connection code that is erroring:

rs.Open(s, sq, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)

* s is the search string

* sq is the connection string

sq.open("Provider=SQOLEDB;Data Source=mns-web01\sqlexpress;User ID=WLANClient;Password=password;Initial Catalog=WLAN;")

It also has a 'ghost' user which cannot be removed or re-created. This is the user which the code uses to connect to the database.

Any ideas?

Thanks

Sounds like somewhere in your code you closed or destroyed the connection, and tried to initiate an action after that. Create a simple connection test section of code with a simple select, and then try layering your other code back in. This happens a lot when you're doing looping or calling out to sub procedures.

Buck Woody

No comments:

Post a Comment