ServerVersion: Invalid operation. Connection closed

I have a workstation with Windows 7 (IIS 6.0), MS SQL Server 2008, Visual Studio 2008. My SQL Server Management Studio works fine. But I cannot get the connection through any of my projects in VS2008 or VS2010 The code I am using is:

        Dim _SqlConnectionString As String = "Data Source=" + Environment.MachineName + "\\SQLEXPRESS;Initial Catalog=MyDatabase;Integrated Security=true;"
        Dim cn As SqlConnection = New SqlConnection(_SqlConnectionString) 
        Dim da As New SqlDataAdapter(cmd)
        Dim dt As New DataTable
        cmd.Connection = cn
        cn.Open()

      

The error I'm getting is inside the ServerVersion property of my SqlConnection: Invalid Operation. Connection closed

This issue came up after installing the wamp and php server. What should I do? Is there a conflict? I made my wamp server listen on a different port than IIS, but what about SQL Server? Why can't I connect to it?

+3


source to share


1 answer


I've had this problem before. One day, a Visual Studio Windows application that I successfully ran with code in debug mode worked great and did what needed to be done. The very next day, he simply did not establish a connection, giving me this error: ServerVersion: Invalid Operation. The connection is closed. Funny, I was using a SQL user who had permissions to this database since my user connected to the database. The reason I got this message is because this particular SQL user that I was using to connect was disconnected at the time. I turned it on again and it worked again.



It could be something like this, or it could be a Windows service that is not running. Personal experiment

0


source







All Articles