Please advise in the below error after publishing ASP.NET web application from IIS .
SQL Authentication mode is mixed
Environment : - Windows Server 2008 r2 Enterprice
- MS SQL 2008 R2
- MS Visual Studio 2010
Server Error in '/' Application.
ExecuteReader requires an open and available Connection. The connection's current state is closed.
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: ExecuteReader requires an open and available Connection. The connection's current state is closed.
Thanks tusharrs and bhaskar.mule for your quick reply..
My code is exactlly as what you explained..
I think the problem in sql level..
I created sql user I tried to connect from SSMS from it but error 18456 occure
TITLE: Connect to Server
------------------------------
Cannot connect to xx.xx.xx.xx
------------------------------
ADDITIONAL INFORMATION:
Login failed for user 'admin'. (Microsoft SQL Server, Error: 18456)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=18456&LinkId=20476
------------------------------
BUTTONS:
OK
------------------------------
ba7ranya
Member
2 Points
4 Posts
Runtime Error : ExecuteReader requires an open and available Connection.
May 07, 2012 12:44 PM|LINK
Hi All,
Please advise in the below error after publishing ASP.NET web application from IIS .
SQL Authentication mode is mixed
Environment : - Windows Server 2008 r2 Enterprice
- MS SQL 2008 R2
- MS Visual Studio 2010
Server Error in '/' Application.
ExecuteReader requires an open and available Connection. The connection's current state is closed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: ExecuteReader requires an open and available Connection. The connection's current state is closed.
tusharrs
Contributor
3230 Points
668 Posts
Re: Runtime Error : ExecuteReader requires an open and available Connection.
May 07, 2012 12:45 PM|LINK
use con.open(); before executing whereever execute reader method is used
check where you have used SqlCommand object and called executereader method, so first you have to open the connection by using
suppose con is the object of SqlConnection so use con.Open(); and then call the executereader method
( Mark as Answer if it helps you out )
View my Blog
bhaskar.mule
Contributor
2280 Points
659 Posts
Re: Runtime Error : ExecuteReader requires an open and available Connection.
May 07, 2012 12:54 PM|LINK
You have to set the connection state is open
Con.Open();
//yor logic ex..ExcuteReader
con.Close();
Site:Rare technical solutions
ba7ranya
Member
2 Points
4 Posts
Re: Runtime Error : ExecuteReader requires an open and available Connection.
May 08, 2012 05:38 AM|LINK
Thanks tusharrs and bhaskar.mule for your quick reply..
My code is exactlly as what you explained..
I think the problem in sql level..
I created sql user I tried to connect from SSMS from it but error 18456 occure
Chen Yu - MS...
All-Star
21829 Points
2513 Posts
Microsoft
Re: Runtime Error : ExecuteReader requires an open and available Connection.
May 09, 2012 10:37 AM|LINK
Hi,
Would you please post your code ? It will provide us more information about your problem.
Please check your sql server wether server authentication has changed to mixed authentication.
Check your username and password.
There is a blog taking about this issue: http://www.katieandemil.com/microsoft-sql-server-error-18456-login-failed-for-user.
Thanks.
Feedback to us
Develop and promote your apps in Windows Store
christiandev
Star
8607 Points
1841 Posts
Re: Runtime Error : ExecuteReader requires an open and available Connection.
May 09, 2012 10:57 AM|LINK
use the USING statement too...
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.read.aspx
Regards, Christiandev (@chrisdev80), MCPD Web (2 & 4) & MCTS Windows (www.ScoreDonkey.com)