how to access database kept in App_Data folder - asp.net

I am getting problem while I try to access MS-SQL database that is kept in "App_Data" folder.
My connection string in web.config file is-
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\CRMDb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
The Exception is-
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)
Any relevant help would be highly appreciated.
Thanks in advance

First things first: do you have SQL Express installed on your machine? If not you can get it here for free.
If you do have SQL Express installed, check if your SQL Express instance is running. If it's not running, open a command prompt (as Administrator) and execute the following command:
net start mssql$sqlexpress

Related

Error in SQL server connection

I have an ASP.net website and I have uploaded it on a free hosting site. I have uploaded all files and directories. Changed the connection string with the connection string given by the hosting site. But still I am receiving this error. Error message is:
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)
http://opacpsu-001-site1.smarterasp.net/psu-home1.aspx
Here is the connection string give by the hosting site.
"Data Source=SQL5013.Smarterasp.net;Initial Catalog=DB_9B4835_OPAC;User Id=DB_9B4835_OPAC_admin;Password=12345678;"
What should I do?
Okay so I forgot to show the configuration in the Web.config file.
Here it is.
<connectionStrings>
<add name="OPACConnectionString" connectionString="Data Source=SQL5013.Smarterasp.net;Initial Catalog=DB_9B4835_OPAC;User Id=DB_9B4835_OPAC_admin;Password=12345678;" providerName="System.Data.SqlClient" />
</connectionStrings>

Can't connect to SQL Server from asp.net application

Hi i want to publish my application in a IIS server.
First i create a database in my sql server and put all my needed data on it.
Then i update my web.config to use the new remote Database. Unfortunatly i get an error
ConnectionString:
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=IntranetDatabase;Data Source=SRVDEV2010\SRVDEV2010" />
Stacktrace :
[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: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]
I cheked if i can access database remotly. I create a udlfile to verify my connectionstring, Here is the result.
I don't know why the udl file can connect but not my application. Any help is appreciated
Under which user is the Application Pool configured to run? you're using Windows Authentication which means your IIS App pool should be configured to run under a user that has access to the DB.

not able to registered user on sql membership on server?

I have successfully hosted my mvc website on server.
But I'm not able to registered new user.
I have used following connection string.
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
Error is
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)
Using SQL membership tables for create user .
All going good on localhost but after hosting getting error.
Where I go wrong?
Sound like the aspnetdb.mdf file is not in the Data folder on the host can you confirm the App_Data directory and aspnetdb.mdf file exists on the host?
On remote server you need to change your connection string. Please user correct server url/ip and db name

cannot establish a connection to SQL Server

I have a web app that I developed using Visual Web Developer 2010. The database is local inside the solution:
<add name="SFDBConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\SFDB.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
I'm trying to run the app on another machine using Visual Studio 2010 instead of the web developer and it's giving me the following error when it tries to connect to the database:
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)
Does anybody has any idea on what could be happening?
Usually, this error message means exactly what it says...
Can you connect to the SQL server through UI client (like, management studio)? If yes - how do you do that (user/password or Windows authentication; what is the server name)?
What is the connection string? You put here the connection string to SQL Express (which works; so it isn't quite helpful) - but forgot to put the connection string that doesn't work.
If you can connect in UI, and connection string is correct - there is no reason why the code would throw an error!

A network-related or instance-specific error occurred while establishing a connection to SQL Server

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)
when i upload my site on webserver and connect with remote sqlserver2005 using connection string....
<connectionStrings>
<remove name="ConnectionString"/>
<add name="ConnectionString" connectionString="Data Source=69.16.253.19,1433;Initial Catalog=vb_usa;Persist Security Info=True;User ID=username;Password=password" providerName="System.Data.SqlClient"/>
</connectionStrings>
it produces the following errr --
you can see error in my webpage :
http://vbi.volvobusesindia.com
it shows an error above ..
i m using aspnetdb.mdf in my website in APP_Data Folder... features i use in my website is Login Control, Password recovery, signup control...
Tried all the above but did not work for me. When I checked Services, I found that the SQLExpress service which was set Automatic, was not started. Once I started the SQLExpress service, everything worked.
See the guide in this site http://www.connectionstrings.com/sql-server-2005
In particular look at the section on that page titled "Attach a database file, located in the data directory, on connect to a local SQL Server Express instance"
The format is:
Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;
Database=dbname;Trusted_Connection=Yes;
Basically, you need to connect to the SQL Express instance installed on the web server and point it to where your database file is located.
On that remote machine (63.15.223.19), the SQL services are not running. You can go to that machine and try to run "net start mssqlserver" from command prompt.

Resources