Last post Apr 04, 2013 10:39 AM by alezacx
Sep 13, 2010 03:01 PM|Apples|LINK
I'm using Visual Studio 2008, and my database is SQL Server 2000.
I want to add a connection to the Server Explorer in VS. The Data source is Microsoft SQL Server (SqlClient). After entering in all my information and I click Test Connection, it is successful.
But when I click OK, I get the error:
Unable to add data connection. ExecuteScalar requires an open and available connection. The connection's current state is closed.
What's going on here?
Sep 14, 2010 03:25 AM|mehta.rahulit|LINK
can i get to see ur code??
it will be helpful to resolve ur issue
Sep 15, 2010 04:22 PM|deedee1969|LINK
I am getting the same exact message. It doesn't make sense that the test connection works ok.
I had been able to connect to this SQL Server when developing on another machine.
I am wondering if it has something to do with the network protcols or setup?
If you have found a solution to this problem please email me, it would be very much appreciated.
visual Studio 2008 professional
Oct 13, 2010 12:26 PM|Programor|LINK
Did you open the connection before calling executescalar?
Sounds like you created the SqlConnection object but did not call the open method.
Jan 18, 2012 11:55 PM|Bonjufra|LINK
Hi, found this forum as I was having the same problem. Another forum suggested restarting Visual Studio and adding the connection again... lo and behold, it worked! The only thing I did differently was I didn't test the connection the second time.
Hope this helps
Jan 19, 2012 07:58 AM|Ruchira|LINK
Can we see the part of your coding where you do the SQL connection part? Check whether you are closing the connection before you reach to the ExecuteScalar method. Or may be, you are never opening a connection. It's a problem with your code. Not a problem
with your network connection, Visual Studio or SQL server, I guess.
Please 'Mark as Answer' if this post helps you
Apr 04, 2013 10:39 AM|alezacx|LINK
That was it.. I just had to restart Visual Studio and it worked !