Skip to content

Commit ca48919

Browse files
authored
Merge pull request #755 from MicrosoftDocs/master
merge to live
2 parents cee47e4 + 5788111 commit ca48919

13 files changed

+371
-321
lines changed

docs/data-tools/TOC.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# [Accessing data in Visual Studio](accessing-data-in-visual-studio.md)
22
# [Installing database systems, tools, and samples](installing-database-systems-tools-and-samples.md)
3-
## [Create a SQL database by using a script](create-a-sql-database-by-using-a-script.md)
43
## [Upgrade .mdf files](upgrade-dot-mdf-files.md)
54
# [Visual Studio data tools for .NET](visual-studio-data-tools-for-dotnet.md)
65
## [Create a simple data application by using ADO.NET](create-a-simple-data-application-by-using-adonet.md)

docs/data-tools/create-a-simple-data-application-by-using-adonet.md

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,32 @@ When you create an application that manipulates data in a database, you perform
5555

5656
- Visual Studio Community Edition.
5757

58-
- SQL Server Express LocalDB.
59-
60-
- The small sample database that you create by following the steps in [Create a SQL database by using a script](../data-tools/create-a-sql-database-by-using-a-script.md).
61-
62-
- The connection string for the database after you set it up. You can find this value by opening **SQL Server Object Explorer**, opening the shortcut menu for the database, selecting **Properties**, and then scrolling to the **ConnectionString** property.
58+
- SQL Server Express LocalDB. If you don't have SQL Server Express LocalDB, you can install it from the [SQL Server Editions download page](https://www.microsoft.com/en-us/server-cloud/Products/sql-server-editions/sql-server-express.aspx).
6359

64-
This topic assumes that you're familiar with the basic functionality of the Visual Studio IDE and can create a Windows Forms application, add forms to that project, put buttons and other controls on those forms, set properties of those controls, and code simple events. If you aren't comfortable with these tasks, we suggest that you complete the [Getting Started with Visual C# and Visual Basic](../ide/getting-started-with-visual-csharp-and-visual-basic.md) before you start this topic.
60+
This topic assumes that you're familiar with the basic functionality of the Visual Studio IDE and can create a Windows Forms application, add forms to the project, put buttons and other controls on the forms, set properties of the controls, and code simple events. If you aren't comfortable with these tasks, we suggest that you complete the [Getting Started with Visual C# and Visual Basic](../ide/getting-started-with-visual-csharp-and-visual-basic.md) topic before you start this walkthrough.
6561

6662
## <a name="BKMK_setupthesampledatabase"></a> Set up the sample database
67-
The sample database for this walkthrough includes the Customer and Orders tables. The tables contain no data initially, but you can add data when you run the application that you'll create. The database also has five simple stored procedures. [Create a SQL database by using a script](../data-tools/create-a-sql-database-by-using-a-script.md) contains a Transact-SQL script that creates the tables, the primary and foreign keys, the constraints, and the stored procedures.
63+
Create the sample database by following these steps:
64+
65+
1. In Visual Studio, open the **Server Explorer** window.
66+
67+
2. Right-click on **Data Connections** and choose **Create New SQL Server Database...".
68+
69+
3. In the **Server name** text box, enter **(localdb)\mssqllocaldb**.
70+
71+
4. In the **New database name** text box, enter **Sales**, then choose **OK**.
72+
73+
The empty **Sales** database is created and added to the Data Connections node in Server Explorer.
74+
75+
5. Right-click on the **Sales** data connection and select **New Query**.
76+
77+
A query editor window opens.
78+
79+
6. Copy the [Sales Transact-SQL script](https://raw.githubusercontent.com/MicrosoftDocs/visualstudio-docs-pr/master/docs/data-tools/samples/sales.sql?token=AXuuSupVbF1bjJoN2_Pq5wP2zzL1iwq-ks5ZwrcBwA%3D%3D) to your clipboard.
80+
81+
7. Paste the T-SQL script into the query editor, and then choose the **Execute** button.
82+
83+
After a short time, the query finishes executing and the database objects are created. The database contains two tables: Customer and Orders. These tables contain no data initially, but you can add data when you run the application that you'll create. The database also contains four simple stored procedures.
6884

6985
## <a name="BKMK_createtheformsandaddcontrols"></a> Create the forms and add controls
7086

@@ -127,7 +143,7 @@ This topic assumes that you're familiar with the basic functionality of the Visu
127143
## <a name="BKMK_storetheconnectionstring"></a> Store the connection string
128144
When your application tries to open a connection to the database, your application must have access to the connection string. To avoid entering the string manually on each form, store the string in the App.config file in your project, and create a method that returns the string when the method is called from any form in your application.
129145

130-
You can find the connection string in **SQL Server Object Explorer** by right-clicking the database, selecting **Properties**, and then locating the ConnectionString property. Use Ctrl+A, Ctrl+C to select and copy the string to the clipboard.
146+
You can find the connection string by right-clicking on the **Sales** data connection in **Server Explorer** and choosing **Properties**. Locate the **ConnectionString** property, then use Ctrl+A, Ctrl+C to select and copy the string to the clipboard.
131147

132148
1. If you're using C#, in **Solution Explorer**, expand the **Properties** node under the project, and then open the **Settings.settings** file.
133149
If you're using Visual Basic, in **Solution Explorer**, click **Show All Files**, expand the **My Project** node, and then open the **Settings.settings** file.
@@ -136,8 +152,7 @@ This topic assumes that you're familiar with the basic functionality of the Visu
136152

137153
3. In the **Type** list, select **(Connection String)**.
138154

139-
4. In the **Scope** list, select **Application**.
140-
155+
4. In the **Scope** list, select **Application**.
141156

142157
5. In the **Value** column, enter your connection string (without any outside quotes), and then save your changes.
143158

Lines changed: 2 additions & 277 deletions
Original file line numberDiff line numberDiff line change
@@ -1,278 +1,3 @@
11
---
2-
title: "Create a SQL database by using a script | Microsoft Docs"
3-
ms.custom: ""
4-
ms.date: "11/04/2016"
5-
ms.reviewer: ""
6-
ms.suite: ""
7-
ms.tgt_pltfrm: ""
8-
ms.topic: "article"
9-
ms.assetid: 36f913c0-f5a7-4831-83a0-baba721ac95c
10-
caps.latest.revision: 14
11-
author: "gewarren"
12-
ms.author: "gewarren"
13-
manager: "ghogen"
14-
translation.priority.ht:
15-
- "de-de"
16-
- "es-es"
17-
- "fr-fr"
18-
- "it-it"
19-
- "ja-jp"
20-
- "ko-kr"
21-
- "ru-ru"
22-
- "zh-cn"
23-
- "zh-tw"
24-
translation.priority.mt:
25-
- "cs-cz"
26-
- "pl-pl"
27-
- "pt-br"
28-
- "tr-tr"
29-
---
30-
# Create a SQL database by using a script
31-
In this walkthrough, you use Visual Studio to create a small database that contains the sample code for [Create a simple data application by using ADO.NET](../data-tools/create-a-simple-data-application-by-using-adonet.md).
32-
33-
**In this topic**
34-
35-
- [Create a script that contains a database schema](../data-tools/create-a-sql-database-by-using-a-script.md#CreateScript)
36-
37-
- [Create a database project and import a schema](../data-tools/create-a-sql-database-by-using-a-script.md#CreateProject)
38-
39-
- [Deploy the database](../data-tools/create-a-sql-database-by-using-a-script.md#DeployDatabase)
40-
41-
## Prerequisites
42-
To complete this walkthrough, you must have SQL Server Express LocalDB, or another SQL database, installed.
43-
44-
## <a name="CreateScript"></a> Create a script that contains a database schema
45-
46-
#### To create a script from which you can import a schema
47-
48-
1. In [!INCLUDE[vsprvs](../code-quality/includes/vsprvs_md.md)], on the menu bar, select **File** > **New** > **File**.
49-
50-
The **New File** dialog box appears.
51-
52-
2. In the **Categories** list, select **General**.
53-
54-
3. In the **Templates** list, select **Sql File**, and then select the **Open** button.
55-
56-
The Transact-SQL editor opens.
57-
58-
4. Copy the following Transact-SQL code, and then paste it into the Transact-SQL editor.
59-
60-
```
61-
PRINT N'Creating Sales...';
62-
GO
63-
CREATE SCHEMA [Sales]
64-
AUTHORIZATION [dbo];
65-
GO
66-
PRINT N'Creating Sales.Customer...';
67-
GO
68-
CREATE TABLE [Sales].[Customer] (
69-
[CustomerID] INT IDENTITY (1, 1) NOT NULL,
70-
[CustomerName] NVARCHAR (40) NOT NULL,
71-
[YTDOrders] INT NOT NULL,
72-
[YTDSales] INT NOT NULL
73-
);
74-
GO
75-
PRINT N'Creating Sales.Orders...';
76-
GO
77-
CREATE TABLE [Sales].[Orders] (
78-
[CustomerID] INT NOT NULL,
79-
[OrderID] INT IDENTITY (1, 1) NOT NULL,
80-
[OrderDate] DATETIME NOT NULL,
81-
[FilledDate] DATETIME NULL,
82-
[Status] CHAR (1) NOT NULL,
83-
[Amount] INT NOT NULL
84-
);
85-
GO
86-
PRINT N'Creating Sales.Def_Customer_YTDOrders...';
87-
GO
88-
ALTER TABLE [Sales].[Customer]
89-
ADD CONSTRAINT [Def_Customer_YTDOrders] DEFAULT 0 FOR [YTDOrders];
90-
GO
91-
PRINT N'Creating Sales.Def_Customer_YTDSales...';
92-
GO
93-
ALTER TABLE [Sales].[Customer]
94-
ADD CONSTRAINT [Def_Customer_YTDSales] DEFAULT 0 FOR [YTDSales];
95-
GO
96-
PRINT N'Creating Sales.Def_Orders_OrderDate...';
97-
GO
98-
ALTER TABLE [Sales].[Orders]
99-
ADD CONSTRAINT [Def_Orders_OrderDate] DEFAULT GetDate() FOR [OrderDate];
100-
GO
101-
PRINT N'Creating Sales.Def_Orders_Status...';
102-
GO
103-
ALTER TABLE [Sales].[Orders]
104-
ADD CONSTRAINT [Def_Orders_Status] DEFAULT 'O' FOR [Status];
105-
GO
106-
PRINT N'Creating Sales.PK_Customer_CustID...';
107-
GO
108-
ALTER TABLE [Sales].[Customer]
109-
ADD CONSTRAINT [PK_Customer_CustID] PRIMARY KEY CLUSTERED ([CustomerID] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF);
110-
GO
111-
PRINT N'Creating Sales.PK_Orders_OrderID...';
112-
GO
113-
ALTER TABLE [Sales].[Orders]
114-
ADD CONSTRAINT [PK_Orders_OrderID] PRIMARY KEY CLUSTERED ([OrderID] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF);
115-
GO
116-
PRINT N'Creating Sales.FK_Orders_Customer_CustID...';
117-
GO
118-
ALTER TABLE [Sales].[Orders]
119-
ADD CONSTRAINT [FK_Orders_Customer_CustID] FOREIGN KEY ([CustomerID]) REFERENCES [Sales].[Customer] ([CustomerID]) ON DELETE NO ACTION ON UPDATE NO ACTION;
120-
GO
121-
PRINT N'Creating Sales.CK_Orders_FilledDate...';
122-
GO
123-
ALTER TABLE [Sales].[Orders]
124-
ADD CONSTRAINT [CK_Orders_FilledDate] CHECK ((FilledDate >= OrderDate) AND (FilledDate < '01/01/2020'));
125-
GO
126-
PRINT N'Creating Sales.CK_Orders_OrderDate...';
127-
GO
128-
ALTER TABLE [Sales].[Orders]
129-
ADD CONSTRAINT [CK_Orders_OrderDate] CHECK ((OrderDate > '01/01/2005') and (OrderDate < '01/01/2020'));
130-
GO
131-
PRINT N'Creating Sales.uspCancelOrder...';
132-
GO
133-
CREATE PROCEDURE [Sales].[uspCancelOrder]
134-
@OrderID INT
135-
AS
136-
BEGIN
137-
DECLARE @Delta INT, @CustomerID INT
138-
BEGIN TRANSACTION
139-
SELECT @Delta = [Amount], @CustomerID = [CustomerID]
140-
FROM [Sales].[Orders] WHERE [OrderID] = @OrderID;
141-
142-
UPDATE [Sales].[Orders]
143-
SET [Status] = 'X'
144-
WHERE [OrderID] = @OrderID;
145-
146-
UPDATE [Sales].[Customer]
147-
SET
148-
YTDOrders = YTDOrders - @Delta
149-
WHERE [CustomerID] = @CustomerID
150-
COMMIT TRANSACTION
151-
END
152-
GO
153-
PRINT N'Creating Sales.uspFillOrder...';
154-
GO
155-
CREATE PROCEDURE [Sales].[uspFillOrder]
156-
@OrderID INT, @FilledDate DATETIME
157-
AS
158-
BEGIN
159-
DECLARE @Delta INT, @CustomerID INT
160-
BEGIN TRANSACTION
161-
SELECT @Delta = [Amount], @CustomerID = [CustomerID]
162-
FROM [Sales].[Orders] WHERE [OrderID] = @OrderID;
163-
164-
UPDATE [Sales].[Orders]
165-
SET [Status] = 'F',
166-
[FilledDate] = @FilledDate
167-
WHERE [OrderID] = @OrderID;
168-
169-
UPDATE [Sales].[Customer]
170-
SET
171-
YTDSales = YTDSales + @Delta
172-
WHERE [CustomerID] = @CustomerID
173-
COMMIT TRANSACTION
174-
END
175-
GO
176-
PRINT N'Creating Sales.uspNewCustomer...';
177-
GO
178-
CREATE PROCEDURE [Sales].[uspNewCustomer]
179-
@CustomerName NVARCHAR (40),
180-
@CustomerID INT OUTPUT
181-
AS
182-
BEGIN
183-
INSERT INTO [Sales].[Customer] (CustomerName) VALUES (@CustomerName);
184-
SET @CustomerID = SCOPE_IDENTITY();
185-
RETURN @@ERROR
186-
END
187-
GO
188-
PRINT N'Creating Sales.uspPlaceNewOrder...';
189-
GO
190-
CREATE PROCEDURE [Sales].[uspPlaceNewOrder]
191-
@CustomerID INT, @Amount INT, @OrderDate DATETIME, @Status CHAR (1)='O'
192-
AS
193-
BEGIN
194-
DECLARE @RC INT
195-
BEGIN TRANSACTION
196-
INSERT INTO [Sales].[Orders] (CustomerID, OrderDate, FilledDate, Status, Amount)
197-
VALUES (@CustomerID, @OrderDate, NULL, @Status, @Amount)
198-
SELECT @RC = SCOPE_IDENTITY();
199-
UPDATE [Sales].[Customer]
200-
SET
201-
YTDOrders = YTDOrders + @Amount
202-
WHERE [CustomerID] = @CustomerID
203-
COMMIT TRANSACTION
204-
RETURN @RC
205-
END
206-
GO
207-
CREATE PROCEDURE [Sales].[uspShowOrderDetails]
208-
@CustomerID INT=0
209-
AS
210-
BEGIN
211-
SELECT [C].[CustomerName], CONVERT(date, [O].[OrderDate]), CONVERT(date, [O].[FilledDate]), [O].[Status], [O].[Amount]
212-
FROM [Sales].[Customer] AS C
213-
INNER JOIN [Sales].[Orders] AS O
214-
ON [O].[CustomerID] = [C].[CustomerID]
215-
WHERE [C].[CustomerID] = @CustomerID
216-
END
217-
GO
218-
```
219-
220-
5. On the menu bar, select **File** > **Save SqlQuery_1.sql As...**.
221-
222-
The **Save File As** dialog box appears.
223-
224-
6. In the **File Name** box, enter `SampleImportScript.sql`, note the location where you'll save the file, and then select the **Save** button.
225-
226-
7. On the menu bar, select **File** > **Close Solution**.
227-
228-
Next, create a database project, and then import the schema from the script that you've created.
229-
230-
## <a name="CreateProject"></a> Create a database project and import a schema
231-
232-
#### To create a database project
233-
234-
1. On the menu bar, select **File** > **New** > **Project**.
235-
236-
The **New Project** dialog box appears.
237-
238-
2. Under **Installed**, expand the **Templates** node, expand the **Other Languages** node, select the **SQL Server** category, and then select the **SQL Server Database Project** template.
239-
240-
> [!NOTE]
241-
> The **Other Languages** node doesn't appear in all installations of Visual Studio.
242-
243-
3. In the **Name** box, enter `Small Database`.
244-
245-
4. Select the **Create directory for solution** check box if it isn't already selected.
246-
247-
5. Clear the **Add to source control** check box if it isn't already cleared, and then select the **OK** button.
248-
249-
The database project is created and appears in **Solution Explorer**.
250-
251-
Next, import the database schema from the script.
252-
253-
#### To import a database schema from a script
254-
255-
1. On the menu bar, select **Project** > **Import** > **Script**.
256-
257-
2. On the **Welcome** page, review the text, and then select the **Next** button.
258-
259-
3. Select the **Single File** option button, and then select the **Browse** button.
260-
261-
The **Import SQL Script** dialog box appears.
262-
263-
4. Open the folder where you saved the SampleImportScript.sql file, select the file, and then select the **Open** button.
264-
265-
5. Select the **Finish** button to close the **Import SQL Script** dialog box.
266-
267-
The script is imported, and the objects that the script defines are added to your database project.
268-
269-
6. Review the summary, and then click the **Finish** button to close the **Import SQL Script File** dialog box.
270-
271-
7. In **Solution Explorer**, expand the Sales, Scripts, and Security folders of your project, and verify that they contain .sql files.
272-
273-
8. In **SQL Server Object Explorer**, verify that the database appears under the **Projects** node.
274-
275-
At this point, the database contains only system objects, such as tables and stored procedures. After you deploy the database, it will contain the user tables and stored procedures that the scripts define.
276-
277-
## <a name="DeployDatabase"></a> Deploy the database
278-
When you press the **F5** key, you deploy (or publish) the database to a LocalDB database by default. You can deploy the database to a different location by opening the properties page for the project, selecting the **Debug** tab, and then changing the connection string.
2+
redirect_url: https://msdn.microsoft.com/en-us/library/hh864423(v=vs.103).aspx
3+
---

docs/debugger/includes/remote-debugger-requirements.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ The remote computer must be running one of the following operating systems:
4343
- DirectX 9-capable video card running at 1024 x 768 or higher display resolution
4444

4545
### Network configuration
46-
The remote computer and the Visual Studio computer must be connected over a network, workgroup, or homegroup, or else connected directly through an Ethernet cable. Debugging over the Internet is not supported.
46+
The remote computer and the Visual Studio computer must be connected over a network, workgroup, or homegroup, or else connected directly through an Ethernet cable. Debugging between two computers connected through a proxy is not supported. Debugging over a high latency or low bandwidth connection, such as dialup Internet, or over the Internet across countries is not recommended and may fail or be unacceptably slow.

docs/debugger/remote-debugging-aspnet-on-a-remote-iis-7-5-computer.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,14 @@ To debug an ASP.NET application that has been deployed to IIS, install and run t
3737
This guide explains how to set up and configure a Visual Studio 2017 ASP.NET MVC 4.5.2 application, deploy it to IIS, and attach the remote debugger from Visual Studio. To remote debug ASP.NET Core, see [Remote Debug ASP.NET Core on an IIS Computer](../debugger/remote-debugging-aspnet-on-a-remote-iis-computer.md). You can also deploy and debug on IIS using Azure. For more information, see [Remote debug on Azure](../debugger/remote-debugging-azure.md).
3838

3939
These procedures have been tested on these server configurations:
40-
* Windows Server 2012 R2 and IIS 10 (For Windows Server 2008 R2, server steps are different)
40+
* Windows Server 2012 R2 and IIS 10 (For Windows Server 2008 R2, the server steps are different)
41+
42+
## Requirements
43+
44+
The remote debugger is supported on Windows Server starting with Windows Server 2008 Service Pack 2. For a complete list of requirements, see [Requirements](../debugger/remote-debugging.md#requirements_msvsmon).
45+
46+
> [!NOTE]
47+
> Debugging between two computers connected through a proxy is not supported. Debugging over a high latency or low bandwidth connection, such as dialup Internet, or over the Internet across countries is not recommended and may fail or be unacceptably slow.
4148
4249
## Create the ASP.NET 4.5.2 application on the Visual Studio computer
4350

@@ -134,13 +141,6 @@ In this tutorial, we are using Visual Studio 2017.
134141

135142
> [!TIP]
136143
> In some scenarios, it can be most efficient to run the remote debugger from a file share. For more information, see [Run the remote debugger from a file share](../debugger/remote-debugging.md#fileshare_msvsmon).
137-
138-
## Requirements
139-
140-
The remote debugger is supported on Windows Server starting with Windows Server 2008 Service Pack 2 and is also supported on Windows 7 and newer. For a complete list of requirements, see [Requirements](../debugger/remote-debugging.md#requirements_msvsmon).
141-
142-
> [!NOTE]
143-
> The remote computer and the Visual Studio computer must be connected over a network, workgroup, or homegroup, or else connected directly through an Ethernet cable. Debugging over the Internet is not supported in this scenario.
144144

145145
## <a name="BKMK_setup"></a> Set up the remote debugger on Windows Server
146146

0 commit comments

Comments
 (0)