Deploy ASP.NET MVC app on Azure portal with SQL database - c#

How I can move my local database in project in order that I can deploy this database to Azure? Know on Azure when I login I get an error:
Error: an error occurred while processing your request
It is because I have no connection to my database. I have created the database on Azure portal but it's empty. How can I connect to my database from my app so that it works?
This is the complete error:
[Win32Exception (0x80004005): The system cannot find the file specified]
[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.)]
....
[EntityException: The underlying provider failed on Open.]
The solution:
When you deploy app click 'Publish' - > 'Create new Profile' -> In field 'Explore additional Azure Services' click - > 'Create a SQL Database'

According your comment, you problem turned to be deploy database to Azure.
There are many ways you can to that.
Since you have created the database on Azure portal, the easiest way is that you can using SSMS Deploy Database wizard:
For more details, you could reference this tutorial: Learn how to Migrate a SQL Server database to SQL Azure server.
Once the database is deployment to Azure SQL database successfully, you could get the connection string on Azure SQL database page on Portal:
Ref:Get ADO.NET connection information (optional)
hope this helps.

Related

Publish application and include .dbo and tables?

I am trying to publish my Windows forms application which uses a data connection (.dbo) for tables that run my application. However, when I publish the application, I get errors saying the application cannot access the SQL database.
I have looked through YouTube videos and read on the Windows website but I cannot really find anything that solves my problem. The server is a local server named after my laptop name. All of them talk about .mdf databases but I can only see a .dbo under data connections which includes all the tables I created for my application.
I get the following error:
"Unhandled exception has occurred in your application...
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 the instance name is correct and that SQL Server is configured to allow remote connection. (provider: Named Pipes Provider. error: 40 - Could not open a connection to SQL Server)"
It works fine when I run the .exe file on my computer where I built the application but the above error is given when I run the application on another computer.
Can anybody help me publish my application to include the .dbo and all tables?

How to Attach a database file with application so that it can work on a client pc in c#?

Can anyone tell me which database type should use in C# programming to store some data locally? I have used SQL Server database file and built a simple application but when I put this to another PC, it says
Could not connect to SQL Server Client
System.Data.SqlClient.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.)
System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
You could use a JSON file or sqlite, both of them do not requiere any installation on the client machine.
You have to install SQL Server in the other PC to run it local.
Another option is use some portable database, like sqllite, or access.
Or, try to use database server and access your database remotly.

Unable to publish ASP.NET database to external server

I'm trying to publish my ASP.NET MVC application to my server running Windows Server 2008.
I have installed IIS
I have created a database in on the (LocalDb)\v11.0 server on the destination server (The DB is named TestPublishWebApp).
I've clicked publish and have set the connection (and validated the connection):
And I have set the settings as well:
However whenever I publish the application I and go to the URL 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: 50 - Local Database Runtime error occurred.
Cannot create an automatic instance. See the Windows Application event
log for error details.
This is the very first time I'm trying to publish an application to an external server. What could I be doing wrong?
And yes, I have verified that the SQL server is running.

permission and timeout issues connecting to local northwind database in C# entity data model

i am trying to connect to the northwind database in a C# project (entity data model). i am running on my own machine as admin, and have permissions both as admin and as user Gary\PC-Gary
In the Connection Properties dialog box , when i locate the northwind datbase, and double click it
i get the following error message:
Northwind
you don't have permission to open this file.
Contact the file owner or an administrator to obtain permission
i detach the database from SQL Server (on the understanding that C# 2010 will not allow a user instance to connect to a database that is currently in use)
I seem to be making progress, because now, when I browse to the database file, i seem to get past the connection issues, and CAN pull up the filename.
HOWEVER, when i attempt to test the connection (or create the EDMX model), i get the following error message. i am using windows authentication.
a network-related or instance-specific error occured 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)
i have verified that the instance is running in SQL Server Configuration manager and in SSMS. does sql server have to be configured to allow remote connections to access a database on your own machine?? how would this be done?
Found a suggestion here by Peja Tao. Maybe that will help.
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/8cdc71eb-6929-4ae8-a5a8-c1f461bd61b4/provider-sql-network-interfaces-error-26-error-locating-serverinstance-specified

Cannot connect to attached SQL database

I'm using linq to sql with Microsoft SQL Server Database File (SqlClient) as a data source.
The db file was created by Visual Studio 2010 while adding the connection (Database Explorer -> Add Connection).
Using this method I was unable to create a db with SQL auth, so I'm using Windows Authentication.
EDIT: Note that it's not a connection to a database, it's a connection to a database file.
1) Is it possible to create a database file with sql authentication? (I assume it is the root of the problem).
2) Connection works fine on my computer under different acocunts. However, running the release on other machine results in an exception being thrown.
Exception details:
System.Data.SqlClient.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)
I've tried to set the db path manually, but I guess it's not the issue.
What am I doing wrong?
EDIT2: the connection string I'm using:
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\OperatorResults.mdf;Integrated Security=True;Connect Timeout=10;User Instance=True"
First of all, how was SQL Server installed? With Windows Authentication only or Mixed Mode authentication. If it was just Windows Authentication that explains why you were unable to use SQL Server authentication. If mixed mode authentication is enabled then you need an account that has sysadmin or CREATE DATABASE privileges.
As for your second question, did you modify connection string to match the connection configuration of another machine? If not, try doing that. From the exception above it seems that your connection string is connecting to a wrong server or the server instance is not running.
You want Microsoft SQL Server Express
It allows a file based connection.

Categories