23. Access Microsoft SQL Server from the Internet
Internet program design concept
Access SQL Server using ISAPI
Access SQL Server using ASP
Access SQL Server using XML
Summary of this chapter
Using Microsoft SQL Server 2000 on the Microsoft Windows 2000 job system platform, we can easily publish the SQL Server Database "publish (Publish)" to the Internet. The combination of Windows 2000 and Microsoft Internet Information Server (IIS) provides inclusive components and interfaces, and interact with SQL Server 2000 database. This chapter describes the basic concepts of accessing Microsoft SQL Server from the Internet. Since this book is not a special book development, only an overview of several different access methods. The details of the relevant format design, there are many good books on the market for reference.
This chapter will begin from the concept of internet program design and introduce the internet access interface design interface in Windows 2000. Then introduce the basic concept of ODBC programming and ADO, and several ways to access SQL Server, including ISAPI and ASP. Finally, we will discuss XML, understand what is XML and how to use. This chapter covers many themes, and believes that it should help understand the basic tools for internet access design.
Internet Code Design Concept This section will learn the basic concepts of SQL Server and Internet Application. These applications must contain two different interfaces to perform different tasks: one interface is used for users, and the other is used for SQL Server. This section describes the connection between the application and SQL Server, including IIS and ODBC. With Windows 2000 and IIS 5 as an internet platform, Windows 2000 and IIS 5 use Windows 2000 and IIS 5 as a platform for internet applications, allowing program developers to access various functions of SQL Server. Programmed developers can utilize the function of integrating data inventory, Open Database Connectivity, ODBC) Source, OLE DB (a powerful component object model for accessing universal data) (Component Object Model, COM) interface), and a web application architecture called Internet Server API (ISAPI), the last architecture is a powerful competitor of traditional CGI (Common Gateway Interface, common gate interface) application. ODBC is undoubtedly the best choice for the database interface using the ODBC data source. Through ODBC, program developers can access the source type of information, which is widely available from the most simple text file to Microsoft Excel data sheet, and even Microsoft Access and SQL Server libraries can access. ODBC provides a library program designer a universal and powerful abstract level. Development of internet access using SQL Server does not require any special means. To access SQL Server through a Web Server, ODBC data source has provided some other methods. They can do this through an OLE DB COM item collection called ActiveX Data Objects (ADO). ADO provides an object-oriented-interface to access ODBC data sources, which is simpler than using ODBC C API. With ADO, program developers can initialize some simple objects to represent database wirings, commands (such as SQL statements or pre-depreciation programs), and data recording (RECORDSETS), which is similar to the client data indicator and has a near servers Document library data indicators function. All of these database objects and interfaces make us developed on the Internet using SQL Server, especially in ODBC, some powerful features, such as connectivity purposes. An ODBC-based web application, how to properly use the connection to one of the most important issues. Connection Sharing allows a mid-term application to maintain and share connectors with the SQL Server repository. The shared wiring will remain open in the specified time period and share to several users. Establishing a connection is usually a resource-intensive job and causing the burden on the database server. Since the Web Server and the associated Internet application manipulates the vast majority of traffic, the connection to the establishment connection and (especially) reconstruction connection is minimized through the database wiring. As a result, the user's connection time can be faster and also reduces the resource consumption of the database server. In the preset situation, IIS 5.0 will dynamically allocate the database connection.
Note When using an ODBC data source and ADO, an ADO connection article should be used based on each page. Compared to the use of the entire working stage object, the connection item is established when it is required, and it is immediately released immediately, the database connection can release the common state faster so that other wirings are used. This can greatly reduce the time of the Internet application user waiting for the connection. Select a network program library
Although SQL Server can support several different network program libraries such as Banyan Vines, you should use the TCP / IP network program library when you deploy a SQL Server database on the Internet. In many options in the SQL Server network program, TCP / IP provides excellent network adaptability, connection speed and efficiency. (The network program is explained in Chapter 11.)
If TCP / IP is used as a network program library, SQL Server security mode will be limited to only standard security can be used. This mode is verified using SQL Server login. TCP / IP does not support integrated security, which uses Windows 2000 account to verify that provides better security and more efficient methods to maintain centralized management of accounts in the SQL Server system. However, the use of integrated security is also deteriorating the performance of the system on certain levels.
First, if the integrated security is used, the effectiveness of the ODBC connection is seriously limited. When integrated security is taken, the user who enters the database server that enters the database server must be used through the Web Server. As a result, the benefits of the connection can be provided completely, because the shared connection will be rejected, and the same login and password as the existing wiring must be used.
Second, more than half of the connection-based security lines are used with integrated security, which will generally be slow. The use of a list of tubes will also cause some of the issues shared. You can use an anonymous account to log in to a valid SQL Server, which is used in a list of channels, but most web servers will take challenges and respond to verification mode or basic verification mode to force a separate connection. SQL Server. The result is whether orientation of any effectiveness improvement available for the connection.
If the SQL Server and the Web Server are split on different machines, using integrated security will also limit the selection of the verification mode. Challenge and Response Verification Mode will not be available, and only basic verification modes and anonymous verification modes can be selected. On the Internet, let a security system allow anonymous verification by unwise, and basic verification, as you have just said, will make the connection to play unable to play.
Access SQL Server ISAPI using ISAPI is a set of sets of auto calls, which are designed to provide a powerful tool that can extend IIS functionality to internet application developers. The ISAPI application provides superior performance and low-order control. In fact, the ISAPI application will be more efficient than other web applications on IIS. In addition, through ISAPI, program developers can apply all of the Win32 APIs. The Dynamic Library (DLL) of the ISAPI application has two categories: Extension and Filter. Since DDL is a typical compiled program code, the execution speed is much faster than the transpredational code or Script language. If your internet application is high in execution speed and ductility, it will take advantage of the best choice even in programming and modification, the ISAPI expansion program and filters are still the best choice. In the next few sections, we will detail the ISAPI expansion program and filter, then explain the design and use of the ISAPI application. The implementation of the ISAPI expanded program ISAPI expansion is the same as DLL, which will be loaded into an IIS processing space or another processing space separate from it. When you install the ISAPI expansion program on a Web Server, you can choose to load. If the application is not stable, the expansion program should be loaded into a separate processing space to avoid an error of the ISAPI expansion to ruin the entire Web server. This is likely to happen if the ISAPI expansion program is also in the test phase or has not been fully tested. To call an ISAPI expansion, you can use the virtual path of .dll in the URL, for example: http://www.mydomain.com/sampleisapi.dll.
When we use this way to call the ISAPI expansion program, if it has not been loaded, this ISAPI expansion program will be loaded into the memory and control the entire requirements, and IIS turns into server and user browser. A vector of a simple transfer material. An example of this application is the self-reserve search engine on the Internet station.
ISAPI filter
The implementation of the ISAPI filter is also the same as DLL, but they load into IIS processing space when the web server is started, and remains in the memory until the server stops. The ISAPI filter can be set to receive any number of filter event notifications, which will appear when IIS processing each HTTP requirement and generating an HTTP response. When an ISAPI filter is loaded, the filter will communicate with IIS, and the event should be notified of the filter will be transmitted through a special structure. Whenever there is a similar event occurs, the event registration (registered) will receive an event notification message to the filter that should be notified.
ISAPI is a powerful tool that can be used to perform compression or encryption, custom verification, web traffic logs and analysis, and even servers Scripting Engine. You can create an ISAPI filter check each of the web page settings that are transferred to the user, search for special labels, and modify them to have a consistent look, just as an ASP page.
The ISAPI filter can check each of the information flow coming in and going, this ability makes it a good and very flexible tool. However, if there are too many ISAPI filters, the performance and ductility of the entire website will be completely reduced. For example, if each single input and output web pages need to be filtered, it is possible to cause serious burden on the system due to excessive activities of the filter. Special attention should be paid to how to minimize its work when you decide the filter to be performed. For example, in a customized encryption structure, the filter should only be read from the user end from the client or write the data to the client in IIS. This can reduce the number of works that the ISAPI filter should do. ISAPI limit
Although ISAPI technology can provide the best effective performance, it also has some shortcomings. Since the writing isapi expansion program and the filter use C or C , the development ISAPI expansion program and the filter will be more difficult to consume more than the development of the Script web page. When the ISAPI expansion program is modified with the filter, the entire application needs to be recompiled, not just replacing the file. Furthermore, even if the ISAPI expansion program and the filter execution speed generally comes fast than the servo end Script similar to its function, they cannot guarantee the ideal ductility. Finally, some programming abstraction process (most server-side Script program developers think that this), especially Session objects, surprisingly no in the ISAPI program design. The ISAPI program design can be said to be quite low-order than the program of the servo-end Script.
Access SQL Server ASP using ASP is a server-side Script environment, program developers can use it to create interactive, dynamic webpages, and develop powerful web applications. An ASP file is a plain text file named .ASAP, which can contain any text combination, HTML tag, and server-side Script. Although ASP is purely executed by the server, program developers can still include user-end script in their HTML code, and perform through the user's browser instead of transmitting the Web server. When the web server receives a request for the ASP file, the web server performs the files contained in the specific label SRIPT and create a web page. The result of output is a pure HTML file, which may include the user-end SRIPT element just mentioned. This file is then transferred to the user-end browser, and the browser executes or expresses these components on the screen. No ASP original code is transferred to the user. Their analysis and implementation are all completed on the server. The user does not see the script command to establish a web page, and they see what these commands are established. In addition to including the server-side Script, the ASP file can also include a call to the COM component to perform many different tasks, including information inventory. In addition, commercial logic objects across several different development environments can be performed. ASP is quite neutral in language. Program developers can use the Script language they are familiar with, such as Microsoft Visual Basic Scripting Edition (VBScript), Microsoft JScript or Perl to develop ASP files, and discovering that the development process is not difficult. ASP web pages can use Script languages that have been installed in a web server and compatible with COM. Scripting Engine is a program that can be used to handle commands written in a specific language. IIS included Scripting Engine support common VBScript (based on Visual Basic) and the Microsoft version of the JScript (European Computer Manufacturer Manufacturers Association, ECMA) 262 language specifications. From the workforce manufacturer, you can get Scripting Engine like the language of Perl. The ASP has some advantages that transcends traditional CGI applications. Previously, the program developers who have been familiar with VBScript or JScript will not need to learn new program languages, like C or Perl. The ASP provides some objects for the user's working phase, requires and responses, which makes the ASP's function more powerful and makes personalization of content easier. In addition, the ASP can process and collect HTML forms only compared to the CGI application developed and compiled with C language, and the ASP only needs to handle the HTML form information and store it in the database. Since all ASP program is embedded in an HTML file, the ASP maintenance is also very easy.
Access SQL Server XML using XML is an abbreviation of Extensible Markup Language, but XML is not actually a language. It is actually a system that can be used to define other languages, and the general syntax of the expression structure. Unlike the HTML tag language that is only used to specify the web file rendering method, XML specifies the content and structure of the file. The so-called structured data refers to information marked according to its content or use. XML is born with an extendable property. Program developers use XML to define data within the web page, and limit the level of the details according to their needs. For example, program developers can use the