
Using (SqlDataReader reader = command.ExecuteReader())Ĭonsole.WriteLine("", reader.GetString(0), reader.GetString(1)) Ĭonsole.WriteLine("\nDone. Using (SqlCommand command = new SqlCommand(sql, connection)) String sql = "SELECT name, collation_name FROM sys.databases" Using (SqlConnection connection = new SqlConnection(builder.ConnectionString))Ĭonsole.WriteLine("\nQuery data example:") Ĭonsole.WriteLine("=\n") SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder() The string, set your username and password.īuilder.ConnectionString="" using System Setting the server, database, username, and password with the line below.

To use an ADO.NET connection string, replace the 4 lines in the code Replace the contents with the following code and add the appropriate values for your server, database, username, and password. Insert code to query the database in Azure SQL Database In a text editor, open sqltest.csproj and paste the following XML between the tags. This command creates new app project files, including an initial C# code file ( Program.cs), an XML configuration file ( sqltest.csproj), and needed binaries. Navigate to this folder and run this command.

Open a command prompt and create a folder named sqltest. You can use one of these quickstarts to create and then configure a database: Action NET Core SDK for your operating system installed.
DOT NET DEVELPMENT USING DOT NET CORE AND SQL SERVER ON MAC FOR FREE
The following Microsoft Learn module helps you learn for free how to Develop and configure an ASP.NET application that queries a database in Azure SQL Database PrerequisitesĪn Azure account with an active subscription.
