Wanting2LearnMan
asked on
Cannot access SQL Server database in ASP.net website
I have created a new asp.net website and I wish to use the build in membership feature to e.g. register a new user and log them in.
First I have ran the tool: aspnet_regsql.exe which has created the various databases (I have checked using SQL Management studio).
I have changed the connection string in Web.config to:
I am using Microsoft SQL Server 2008 (Not the express version)
Now when I launch my website in VisualStudio and try to resister myself as a user I get the following error:
First I have ran the tool: aspnet_regsql.exe which has created the various databases (I have checked using SQL Management studio).
I have changed the connection string in Web.config to:
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\MY_LAPTOP;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
</connectionStrings>
I am using Microsoft SQL Server 2008 (Not the express version)
Now when I launch my website in VisualStudio and try to resister myself as a user I get the following error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)]
System.Data.SqlClient.SqlInternalCon nection.On Error(SqlE xception exception, Boolean breakConnection) +5009598
System.Data.SqlClient.TdsParser.Thro wException AndWarning () +234
System.Data.SqlClient.TdsParser.Conn ect(Server Info serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity) +341
System.Data.SqlClient.SqlInternalCon nectionTds .AttemptOn eLogin(Ser verInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) +129
System.Data.SqlClient.SqlInternalCon nectionTds .LoginNoFa ilover(Ser verInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +239
System.Data.SqlClient.SqlInternalCon nectionTds .OpenLogin Enlist(Sql Connection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +195
System.Data.SqlClient.SqlInternalCon nectionTds ..ctor(DbC onnectionP oolIdentit y identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +232
System.Data.SqlClient.SqlConnectionF actory.Cre ateConnect ion(DbConn ectionOpti ons options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +5023255
System.Data.ProviderBase.DbConnectio nFactory.C reateNonPo oledConnec tion(DbCon nection owningConnection, DbConnectionPoolGroup poolGroup) +31
System.Data.ProviderBase.DbConnectio nFactory.G etConnecti on(DbConne ction owningConnection) +76
System.Data.ProviderBase.DbConnectio nClosed.Op enConnecti on(DbConne ction outerConnection, DbConnectionFactory connectionFactory) +126
System.Data.SqlClient.SqlConnection. Open() +125
System.Web.Management.SqlServices.Ge tSqlConnec tion(Strin g server, String user, String password, Boolean trusted, String connectionString) +82
[HttpException (0x80004005): Unable to connect to SQL Server database.]
System.Web.Management.SqlServices.Ge tSqlConnec tion(Strin g server, String user, String password, Boolean trusted, String connectionString) +137
System.Web.Management.SqlServices.Se tupApplica tionServic es(String server, String user, String password, Boolean trusted, String connectionString, String database, String dbFileName, SqlFeatures features, Boolean install) +94
System.Web.Management.SqlServices.In stall(Stri ng database, String dbFileName, String connectionString) +27
System.Web.DataAccess.SqlConnectionH elper.Crea teMdfFile( String fullFileName, String dataDir, String connectionString) +395
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.