Connect to SQL Database by using .NET (C#)

Step 1: Configure Development Environment

Configure development environment for ADO.NET development

Step 2: Create a SQL database

See the getting started page to learn how to create a sample database. It is important you follow the guide to create an AdventureWorks database template. The samples shown below only work with the AdventureWorks schema.

Step 3: Get Connection String

Obtain the connection string from the Azure portal

Use the Azure portal to obtain the connection string necessary for your client program to interact with Azure SQL Database:

  1. Click BROWSE > SQL databases.

    Select SQL

  2. Enter the name of your database into the filter text box near the upper-left of the SQL databases blade.

    Select Database

  3. Click the row for your database.
  4. After the blade appears for your database, for visual convenience you can click the standard minimize controls to collapse the blades you used for browsing and database filtering.
  5. On the blade for your database, click Show database connection strings.
  6. If you intend to use the ADO.NET connection library, copy the string labeled ADO.NET.

    Copy the ADO.NET connection string for your database

  7. Paste the connection string information into your client program code. You will need to replace the {your_password_here} with your real password.

For more information, see: Connection Strings and Configuration Files.

Step 4: Run sample code

Next steps

Additional resources