Skip to content

Commit 4da98fd

Browse files
author
stevestein
committed
sqldb - move connection.open
1 parent 6ac7e8f commit 4da98fd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

articles/sql-database/sql-database-connect-query-dotnet-visual-studio.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ms.topic: quickstart
1010
author: stevestein
1111
ms.author: sstein
1212
ms.reviewer:
13-
ms.date: 03/25/2019
13+
ms.date: 12/31/2019
1414
---
1515
# Quickstart: Use .NET and C# in Visual Studio to connect to and query an Azure SQL database
1616

@@ -95,7 +95,6 @@ Get the connection information you need to connect to the Azure SQL database. Yo
9595
Console.WriteLine("\nQuery data example:");
9696
Console.WriteLine("=========================================\n");
9797

98-
connection.Open();
9998
StringBuilder sb = new StringBuilder();
10099
sb.Append("SELECT TOP 20 pc.Name as CategoryName, p.name as ProductName ");
101100
sb.Append("FROM [SalesLT].[ProductCategory] pc ");
@@ -105,6 +104,7 @@ Get the connection information you need to connect to the Azure SQL database. Yo
105104

106105
using (SqlCommand command = new SqlCommand(sql, connection))
107106
{
107+
connection.Open();
108108
using (SqlDataReader reader = command.ExecuteReader())
109109
{
110110
while (reader.Read())

0 commit comments

Comments
 (0)