1. Trang chủ
  2. » Công Nghệ Thông Tin

Introducing Windows Azure- P53 potx

5 243 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 5
Dung lượng 240,71 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Close SQL Server Management Studio and reopen it by following the steps shown in Figure 8-4 to establish a connection to the AzureForDotNetDeveloper database in the cloud.. Error Message

Trang 1

258

4 Click Next SQL Server Management Studio will generate the scripts in a new SQL

script edit window Figure 8-14 shows a successful generation

Figure 8-14 The scripts were successfully generated

5 Log in to the Azure platform portal at https://lx.azure.microsoft.com/ and

create a database AzureForDotNetDeveloper from SQL Azure in the cloud (recall

that the screenshot shown in Figure 8-3 shows the created database)

6 Copy the previously generated script to the clipboard or save it into a file Close

SQL Server Management Studio and reopen it by following the steps shown in

Figure 8-4 to establish a connection to the AzureForDotNetDeveloper database in

the cloud

7 If you run the generated script without any modification, then you will get an

error message as Listing 8-8 shows

Listing 8-8 Error Message from Running Scripts Generated by SQL Server Management Studio Against SQL Azure Without Modification

Msg 195, Level 15, State 5, Line 2

'ANSI NULLS' is not a recognized SET option

Msg 40512, Level 16, State 1, Procedure InsertInstanceState, Line 3

Deprecated feature 'Data types: text ntext or image' is not supported in this«

version of SQL Server

Msg 195, Level 15, State 5, Line 2

Trang 2

259

'ANSI NULLS' is not a recognized SET option

Msg 40512, Level 16, State 1, Procedure InsertCompletedScope, Line 5

Deprecated feature 'Data types: text ntext or image' is not supported in this«

version of SQL Server

Msg 195, Level 15, State 5, Line 2

'ANSI NULLS' is not a recognized SET option

Msg 195, Level 15, State 5, Line 2

'ANSI NULLS' is not a recognized SET option

Msg 40517, Level 16, State 1, Line 16

Option 'pad index' is not supported in this version of SQL Server

8 Modify the output script as follows

a Delete all:

SET ANSI NULLS ON

GO

b Delete all:

PAD INDEX = OFF,

c Delete all:

ALLOW ROW LOCKS = ON, ALLOW PAGE LOCKS = ON

d And, replace it with the following:

ALLOW ROW LOCKS = OFF, ALLOW PAGE LOCKS = OFF

e Delete:

SORT IN TEMPDB = OFF

f The first release of SQL Azure does not support partitions The KEY constraint

statement for all table-creation scripts needs to be removed and replaced with

a separate script For example, the original script for creating a data table

generated by SQL Server Management Studio should look like Listing 8-9 The

highlighted parts need to be removed and replaced with a separate KEY

constraint statement as Listing 8-10 shows:

Listing 8-9 Table-creating Script Generated by SQL Management Studio

CREATE TABLE [dbo].[UserTable](

[UserID] [int] IDENTITY(1,1) NOT NULL,

[Password] [nvarchar](100) NULL,

[FirstName] [nvarchar](100) NOT NULL,

[LastName] [nvarchar](100) NOT NULL,

[Timestamp] [timestamp] NOT NULL,

PRIMARY KEY CLUSTERED

(

[UserID] ASC

)WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]

GO

Trang 3

260

Listing 8-10 Replace the KEY Constraint Statement from Listing 8-9 with a Separate ALTER TABLE Script

to Assign a Key to a Table

ALTER TABLE [UserTable]

ADD CONSTRAINT ID PK PRIMARY KEY (UserID)

g Remove the boldface lines in the CREATE NONCLUSTERED INDEX scripts generated

by SQL Server Management Studio as shown in Listing 8-11

Listing 8-11 Remove Code from All Index-creating Scripts

CREATE NONCLUSTERED INDEX [IX UserTable FirstName] ON [dbo].[UserTable]

(

[FirstName] ASC

)WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF,«

ONLINE = OFF) ON [PRIMARY]

GO

9 Try to resolve all issues if there are other complaints from executing the

generated scripts, and you will successfully run the script against the SQL Azure

cloud database You can run a query to verify that the expected tables have been

created as shown in Figure 8-6

SELECT * FROM sys.databases

SQL Azure Application Developing Tool: SQLAzureConnect

In this section I am going to present a Windows application designed and developed for NET developers

to access SQL Azure services This project will show you how to use ADO.NET to create a connection to SQL Azure services to execute SQL queries and stored procedures just as you do from SQL Server Management Studio The major added value provided by this tool are detailed below They make this application a very handy tool for SQL Azure or on-premises SQL application development It provides:

• A quick way to switch back and forth between SQL Azure cloud services and

traditional on-premises SQL Server environments

• A SQL data access component class that can be used for both SQL Azure and

on-premises SQL application development

• XML data-driven SQL query and stored procedure composition, editing, and

executing, and UI dynamic factoring A SQLAccessHelper class makes SQL query and

stored procedure execution from C# extremely easy All scripts and parameters

needed for a stored procedure can be put into an XML data file or added on the fly

and executed using this tool

Trang 4

261

Functions of SQLAzureConnect

A screenshot of SQLAzureConnect is shown in Figure 8-15 Two radio buttons can be found to the left

of the button Test Connection, which allows users to quickly switch the connection back and forth

between the SQL Azure cloud service and on-premises SQL workstation environments A new SQL

service can be added by clicking the Add Service button The script box is below the text box Description

Figure 8-15 Screenshot of SQLAzureConnect

There are two ways to execute a script One way is to click the Execute button, and the other way

is to select and highlight the text and press F5 If there is a script selected, the caption of the Execute

button turns to Execute Selected, and the background color of the button changes, as Figure 8-16 shows

Trang 5

262

Figure 8-16 The caption of the Execute button turns to Execute Selected, and the background color turns to gold

There are two SQL execution options selected from a pair of radio buttons, Query and

Storedprocedure When Storedprocedure is selected, you can add and delete parameters required by a stored procedure A specific SQL Azure service execution can be navigated using the tabs of the tab control in the window The results of executing the SQL service are displayed in the bottom window, along with the error report Figure 8-17 shows the results of the connection test

All the newly created service configuration data can be saved as an XML data file and played back later (You also can manually create an XML data file and load it into this tool to execute.) Next we are going to go over the XML schema and data file that are the driving force of this tool

Figure 8-17 Connect to SQL Azure test results

Ngày đăng: 05/07/2014, 01:20