Deploying SQL Server & Web App to Azure - c#

Can someone please tell me how to create my own SQL server database, & host it on Microsoft Azure?
I've followed this tutorial: https://learn.microsoft.com/en-us/azure/sql-database/sql-database-get-started-portal
But, it just shows you how to make essentially a copy of Microsoft's template database.
Can you please tell me how to deploy an SQL server database to Azure?
I know how to create a local web app, & then add a database to that later on, but I don't know how to deploy it to Azure?

Go to portal.azure.com
1) create sql server
2) after that, select the newly created sql server and then click on New Database
3) when the database is created, select the sql server again, go to properties, note admin login and server name
4) add your ip in sql server firewall settings
5) remotely connect to the server using your sql server management studio by providing server name and admin login noted in step#3
6) run create database script

Related

SQL Express Connection Error When Connecting to Database

I've been trying to connect my Visual basic to SQL because this is what we are taught off but when I execute it, it shows this. How do I fix this?
This Windows user needs to be granted access to SQL Server and that specific database. It is usually configured during installation process of SQL Server. You can still do it by opening SSMS and adding this user under Security -> Logins node from Object Explorer panel.
Of course, to be able to do above, you need to connect to your SQL Server Express first. You may need to use another Windows user or a SQL Server user. The latter would be possible only if SQL Server Authentication has been enabled during installation process by choosing Mixed Mode for authentication (Windows + SQL Server).
You need to get full permission in SQL Server.
Open SSMS there is a Security folder then => Logins.
In Logins you will find your PC's username which is connected to Sql service
Right-click on your username => Properties
Check Windows Authentication Mode

Why can't I connect to the SQL Server database when I create setup file in Visual studio?

I create application using C# windows forms which uses local SQL Server database server to store / read data using this connection string:
SqlConnection cn = new SqlConnection("Data Source=localhost;Initial Catalog=mydb;Integrated Security=True");
After that I created a setup file (exe) then I installed the setup file in same PC and the application works well and can read data from the SQL Server database.
Now the problem came when I went to another PC I installed SQL Server and I manually attached the same database (mydb) and installed my application and it did not work. The error is shown in the screenshot:
I have different SQL Server name in the other PC but I specified in the connection string that the SQL Server is Localhost so I don't know why it didn't work. Please help me how to fix this error. Thank you
Make sure Sql Server is set to allow Tcp/Ip connections and that it's set to allow integrated security logins. Then, make sure the user on that machine is granted the correct access to the database. You may have better luck using Sql authentication over Windows Authentication here, if you want to be able to distribute this application and have it "just work".
Finally, if Sql Server here is meant to be a simple datastore for a typical local desktop application, it's probably overkill. Full Sql Server (including Express Edition) is a server engine. It works best when it's the only thing running on the machine and can use up all of the resources on the machine in order to cache data and handle requests from many remote machines. If you just want a local data store for a typical desktop application, an in-process engine like Sql Server LocalDb, Sql Server Compact Edition, Sqlite, or even MS Access would be a much more appropriate choice.
You need to set up Windows authentication for the user that's logged in on the other computer. Because you are using Integrated Security, it will attempt to connect to SQL Server using the windows login of the current user. This will be a different login on different computers, so the SQL Server on the other computer needs to have that user added.
You need to start SQL Server Browser Service. It lets your app connects to SQL Server:
SQL Server Browser listens for incoming requests for Microsoft SQL
Server resources and provides information about SQL Server instances
installed on the computer.
To enable it:
In SQL Server Configuration Manager, go to Properties => Service tab => Start Mode = Automatic.
Or
This computer => Manage => Services and Applications => Services => SQL Server Broswer
Note: You need a sql specific user for connect to it, you can not go with Integrated Security for every machine.
Create a Sql Server user and allow it to access the Database:
--//Creates the login AbolrousHazem with password '340$Uuxwp7Mcxo7Khy'.
CREATE LOGIN AbolrousHazem
WITH PASSWORD = '340$Uuxwp7Mcxo7Khy';
GO
--//Creates a database user for the login created above.
CREATE USER AbolrousHazem FOR LOGIN AbolrousHazem;
GO
Reference

Read database from SQL Server - WP8 Application in C#

I have an database in my MS SQL Server and I want to create a WP8 App which can log in and can read over sql query or update the database.
In c# there is it easy to connect to a SQL Server, but in WP8 its more complicated. Can anybody help me? I want to connect to a database over a username and a password and I want to read and edit the database.
you can develop a web service talking to your database, deploy it to IIS on your Azure instance and then consume it from your Windows 8 application (by adding a web reference to your web service in Visual Studio)

Bulk insert unable to access file on network

I have a c sharp application in one server and sql server database on different server. When I try to run bulk insert through C Sharp application, I am getting
"Cannot bulk load because the file operating system error code 5
(Access is denied)"
When i tried the same in sql server on the database server manually, it worked for windows authentication but not for sql authentication.
What should I do in order to make sql authentication work. Please help.
The SQL Server uses security profile of SQL Server service account to access the file if SQL Server authentication was used. OTOH with windows authenticatin, the authenticated windows account must have acces to the file. That's why it worked for you in one case and not in the other one. Give SQL Server service account access to the file.
The other point here is delegation. See this article for the explanation (and a remedy):
http://blogs.msdn.com/b/dataaccesstechnologies/archive/2010/10/29/sql-bulk-copy-error-operating-system-error-code-5-access-is-denied.aspx
To resolve this error, use SQL Server Authentication and specify a SQL Server login that uses the security profile of the SQL Server process account, or configure Windows to enable security account delegation.
Plese go through these references also BulkInsert ,SecurityAccountDelegation
Hope this will help.

Connecting to SQL Server with a username and password

I am writing a C# application to be deployed on another machine. The deploy machine is a clean Windows 7 install.
On my development machine (A Windows 7 32 bit Virtual Machine) I have installed SQL Server 2008 R2 and Visual Studio Express 2010. I would like to create a new database and have it require authentication from an application to connect. All the tutorials that I find mention breeze over the connection string part, I cannot find this explained anywhere. In fact, I cannot even figure out how to add a new user and password to SQL Server in SQL Server Management Studio.
How do I add a new user and password to SQL Management Studio 2008 R2 such that I can easily install another SQL Server instance on another machine and move the database to it?
Thanks.
first check the authentication mode of your DB:
connect to your DB on SSMS, right click it, go to "properties" and then "security". Make sure that "SQL Server and windows authentication mode" is selected. That will allow you to create logins.
Then create your login:
connect to your DB on SSMS, expand your database then go to "security" and right click on logins and then click "new login"
then create your user:
go to the security folder inside your DB, right click users and "new user". Inform the user name and the login name you previous created.
Dont forget to add the necessary permissions
About connection strings, this is a very good website as already pointed:
http://www.connectionstrings.com/
To create a SQL Server Login:
http://msdn.microsoft.com/en-us/library/aa337562.aspx
For Connection strings:
http://www.connectionstrings.com/

Categories

Resources