1
votes

when i created user by CreateUserWizard control ASPNETDB.MDF Automatically added in App_Data Folder, then i cant open & show ASPNETDB.MDF , Error dialog box appear and tel my :

the attempt to attach to the database failed with the following information: 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: 50 - local database runtime error occurred. unexpected error occurred inside a localdb instance api method call. see the windows application event log for error details. )

1
You're trying to attach an .mdf SQL Server data file. For this to work, you must have SQL Server Express installed on your machine - is that the case? Also, the file should be added in App_Data (not App_Code) - is that the case? (your title says App_Data, but in your question body, you mention App_Code....)marc_s
yes i know, i already have QL Server Express and VS automatically put in App_Data , Also i can't open databaseTwana.Net

1 Answers

0
votes

Firstly,

Make sure your database engine is configured to accept remote connections

• Start > All Programs > SQL Server 2005 > Configuration Tools > SQL Server Surface Area Configuration • Click on Surface Area Configuration for Services and Connections • Select the instance that is having a problem > Database Engine > Remote Connections • Enable local and remote connections • Restart instance - See more at: http://www.sswug.org/articlesection/default.aspx?TargetID=44331#sthash.kzSfADZL.dpuf

Secondly,

You may need to create an exception on the firewall for the SQL Server instance and port you are using • Start > Run > Firewall.cpl • Click on exceptions tab • Add the sqlservr.exe (typically located in C:\Program Files (x86)\Microsoft SQL Server\MSSQL.x\MSSQL\Binn, check your installs for the actual folder path), and port (default is 1433) • Check your connection string as well - See more at: http://www.sswug.org/articlesection/default.aspx?TargetID=44331#sthash.kzSfADZL.dpuf

Thirdly Check if your SQL server services is up and running properly

Go to All Programs >> Microsoft SQL Server 2008 >> Configuration Tools >> SQL Server Configuration Manager >> SQL Server Services, and check if SQL Server service status is “Running”.

In addition, ensure that your remote server is in the same network. Run “sqlcmd -L” in your command prompt to ascertain if your server is included in your network list. You can even find tutorial for the same here SQL SERVER – Find All Servers From Local Network – Using sqlcmd – Detect Installed SQL Server on Network.

Next Enable TCP/IP in SQL Server Configuration

Go to All Programs >> Microsoft SQL Server 2008 >> Configuration Tools >> SQL Server Configuration Manager >> Select TCP/IP. Right click and select enable

Lastly Go to your firewall setting, under exception tab, select add port include TCP:1433 and tick the SQL check box.

All these did helped me and several of my lab mates whom have trouble connecting to the remote server

References : http://www.sswug.org/articlesection/default.aspx?TargetID=44331 http://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/

Source: Why am I getting "Cannot Connect to Server - A network-related or instance-specific error"?