Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (52.02 KB, 13 trang )
Accessing SQL Server Using HTTP
You can access SQL Server using HTTP (Hypertext Transfer Protocol). This allows you
to run SQL statements from a browser. For example, you can run a SELECT statement
that returns XML, and SQL Server will display the results in your browser. You can use
XPath statements to locate data in the returned XML, and use XSL stylesheets to format
the returned XML. I'll show you how to do all of these things in this section.
Warning You can even run INSERT, UPDATE, and DELETE statements-but you'll need
to be careful about restricting the ability to run these types of statements
because an errant user could easily wreck your database.
Before you can access SQL Server using HTTP, you'll need to configure SQL XML
support for IIS (Internet Information Server).
Configuring SQL XML Support for IIS
To configure SQL XML support for IIS, select Start ➣ Programs ➣ Microsoft SQL
Server ➣ Configure SQL XML Support in IIS. This starts the IIS Virtual Directory
Management for SQL Server console, as shown in Figure 16.6
. You use this console to
define a virtual directory through which you access SQL Server via HTTP.
Figure 16.6: The IIS Virtual Directory Management for SQL Server console
To define a virtual directory, expand the node for your computer using the + icon (I've
expanded the node for my computer-which is named JMPRICE-DT1-in Figure 16.6
).
Next, right-click on Default Web Site and select New ➣ Virtual Directory from the pop-
up menu. You'll need to set the properties for your virtual directory using the New
Virtual Directory Properties window. This window contains six tabs, the first of which is
named General, which you use to set your Virtual Directory Name (the name through
which you access SQL Server) and Local Path (the actual directory in your computer's
file system where you store files, such as XML and XSLT files). I've set my Virtual
Directory Name to Northwind and my Local Path to F:\Northwind, as shown in Figure
16.7.