An Azure relational database service.
@Руслан Савченков Welcome to Microsoft Q&A forums.
We have plenty of code samples here to help you get started.
Here is a code snippet from one of the sample.
using System;
using System.Text;
using System.Data.SqlClient;
namespace AzureSqlSample
{
class Program
{
static void Main(string[] args)
{
string sql;
// Build connection string
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
builder.DataSource = "your_server_name.database.windows.net"; // update me
builder.UserID = "your_user"; // update me
builder.Password = "your_password"; // update me
builder.InitialCatalog = "your_database_name"; // update me
// Connect to Azure SQL
using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
{
try
{
Console.WriteLine("Connect to Azure SQL and demo Create, Read, Update and Delete operations.");
// Connect to Azure SQL
Console.Write("Connecting to Azure SQL ... ");
connection.Open();
Console.WriteLine("Done.");
// READ demo
Console.WriteLine("Reading data from table, press any key to continue...");
Console.ReadKey(true);
sql = "SELECT Id, Name, Location FROM Employees;";
using (SqlCommand command = new SqlCommand(sql, connection))
{
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
Console.WriteLine("{0} {1} {2}", reader.GetInt32(0), reader.GetString(1), reader.GetString(2));
}
}
}
}
catch (SqlException e)
{
Console.WriteLine(e.ToString());
}
finally
{
Console.WriteLine("Cleaning up table.");
using (SqlCommand command = new SqlCommand("DROP TABLE IF EXISTS Employees", connection))
{
command.ExecuteNonQuery();
}
}
}
Console.WriteLine("All done. Press any key to finish...");
Console.ReadKey(true);
}
}
}
Please let us know if you face any issues.
----------
If an answer is helpful, please click on
or upvote
which might help other community members reading this thread.