I just build my first web-application in asp.net that connects to a local database.
I got a weird problem.
The connection to the database works if i open the website BEFORE sql server after reboot. I can insert/read from the db from my webpage. But then sql server cant connect to the db. It looks like this then:
If i start sql server before the website then sql server works but the webpage doesnt work, visual studio then gives me this error:
Why are they interfering with each other and what can i do about it?
I use visual studio 2010 and sql server 2008 R2.
did you try to open your connection through server explorer from visual studio 2010 ? everytime you want to display the page in an web browser..just make sure you open the database connection through server explorer, it will work...no matter what was the order of your starting sql server.
Related
I'm using Visual Studio 2010 and SQL Server 2012. When I try to connect to SQL Server through Visual Studio, I don't get my server name on Add connection drop down menu.
Go to SQL Server Management Studio to look for the correct Server Name and copy the value. Make all the configurations by yourself at the end just click Test connection button. If the connection is test successfully proceed with your work.
If the database is in your local machine, Just put a . (Dot) in Server Name and select the database.
run services.msc
find " SQL server browser " , it might be disabled , start that service and set it to automatic.
Insert machine_name/SqlServerName
For people using sql server 2014+ and using the local db on your pc. simply set the server name to be (localdb)\ name of your database. It worked for me.
I'm trying to create a SQL Server database from Visual Studio Database Explorer. When I right click on Data Connections, the Create New SQL Server Database option remains grayed out.
I have VS Express 2012 and SQL Server Express 2012 installed in my system. SQL Server instance is up and running.
Do I need to configure anything, so that Visual Studio recognizes the installed SQL Server instance?
You first need to make a connection to the SQL Server before you can create a database.
Click the Add Connection option and connect to your SQL Server instance, then the option will become available on your connected Server.
I am trying to add a SQL Server database item into my ASP.Net website.
I have SQL Server 2012 installed but when I press add in Visual Studio I get the following error
Connection to SQL server database files (.mdf) require SQL Server 2005 Express or SQL Server 2008 Express to be installed and running on the local computer. The current version of SQL Server Express can be downloaded and at the following at the following URL: "
I am wondering if I can get it to work with 2012 in the way it would with 2005/2008 or will I need to download 2005/2008 to get this feature?
I only ask because it seems a little strange that VS2013 is not not compatible with SQL Server 2012...
PS: I am trying to follow the following tutorial and that is why I am hoping to get this to work so I can follow the tutorial as intended. "http://www.youtube.com/watch?v=Tyr1YXpNOrk"
by SQL Server Management Studio create your database, then in vs 2013 asp.net project use this database into web.config file
in vs 2013 and Server Explorer tab and Data Connections with Add Connection or Create new sql server database use from your db or create new sql 2012 db
I am wondering if i can get it to work with 2012 in the way it would with 2005/2008
What for? To my knowledge that was retired for the bad issues it created.
Visual Studio 2013 comes with an ad job user version of MSSQL (localdb) that is non-install-required and used in case.
Otherwise install the normal sql server and reate the db - do not rely on this functionality (like most non-trivial shops anyway) and no problem arises to start.
Yes It can be done through Visual studio and here is the link to guide A-Z
It will IIS to deploy ASP site.
http://www.asp.net/mvc/tutorials/older-versions/models-(data)/creating-model-classes-with-linq-to-sql-cs
Hope this will work as it worked for me
For the first time I am trying to debug a SQL Server 2008 R2 stored procedure being called by ASP.NET web app in Visual Studio 2012; application targets .NET framework 4.0.
I brought up the SQL Server Object Explorer for the first time. I see the system database, but there isn't even a node for the user databases. What am I missing? Hopefully there is a simple answer to this.
Make sure you open the right database. By default, it shows SQL Express so if you use another database, you need to connect to it manually.
I am trying to learn C# and then I hit this roadblock. My Visual Studio 2010 wont let me create a service based database (the .mdf file). (Add>New Item>Service-Based Database)
Everytime I try to add new .mdf it would bring up an error.
A network-related or instance-specific error occurred while
establishing a connection to the 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)
I can create a Local Database (Add>New Item>Local Database) without any problem, but I cant create .mdf
I am running on Windows 7 64bit OS and Visual Studio 2010 (Ultimate).
A service-based database needs to connect to a SQL Server instance. It's not built into Visual Studio, it's a separate application which needs to be running somewhere for you to connect to. That error message is basically telling you it can't find the SQL Server instance you're trying to connect to.
Local Database works correctly because it keeps everything local to your application and doesn't require an external database server to function.
Basic requirements for using these two kinds of databases:
Local Database (.sdf): requires SQL Server Compact. That is, you need only an additional DLL, but no special system service. (If you know SQLite: SQL Server Compact is conceptually the same thing, only more powerful and feature-complete.)
Service-Based Database (.mdf & .ldf log/journal file): requires a running instance of SQL Server or SQL Server Express, both of which are standalone products (as Tim Copenhaver points out in his answer). For development purposes, you'd typically install one of these products on your development machine.
Likely cause of your problem: Guessing from the error message that you posted, you do not have SQL Server, nor SQL Server Express, installed. However, an instance of one of these products is required so that you can "attach" your database to it. This is required in order before you can actually access the .mdf database.
To see whether you have SQL Server installed, you could e.g. open Control Panel → Administrative Tools → Services, and look out for a system service named "SQL Server (.\SQLEXPRESS)", or "SQL Server (YOURCOMPUTERNAME\MSSQLSERVER)", or similar. The name in the brackets is the name of the database instance running on your machine. SQLEXPRESS is the default instance name for SQL Server Express, while MSSQLSERVER is the default instance name for the full version of SQL Server.
If you do not have SQL Server installed, you can download e.g. SQL Server 2012 Express or SQL Server 2008 R2 Express with SP2 for free from Microsoft.
You can try
Go to Command Prompt from Start->Run(type cmd -> press enter)
Check SqlLocalDB by
Sqllocaldb.exe i
You will see version number like (v11.0) otherwise complete the
installation.
Create the sqldb by
sqllocaldb c dbname
You will see like "LocalDB instance "dbname" created with version 11.0."
Then Start the Db
sqllocaldb s dbname
You will see like "LocalDB instance "dbname" started"
See the created Db info
sqllocaldb.exe i dbname
Now try to create service-based database in c#.
To temporarily attach a database file (.mdf) from the Data Connections node
In Server Explorer, open the short cut menu for Data Connections and choose Add Connection.
The Add Connection dialogue box appears.
Choose the Change button.
The Change Data Source dialogue box appears.
Select Microsoft SQL Server Database File and choose the OK button.
The Add Connection dialogue box reappears, with Microsoft SQL Server Database File (SqlClient) shown in the Data source text box.
Choose the Browse button and browse to an existing .mdf file.
If you type a file name that does not exist, a blank .mdf file will be created.
Select either Use Windows Authentication or Use SQL Server Authentication.
For more information on SQL Server database access authentication, see Create New SQL Server Database Dialogue Box.
Choose the OK button.
The database appears in Server Explorer.