Ajax|xml
Remote management Technology of database
An important link in the modern application of Internet based WAN is the remote monitoring of database. First of all, a brief review of the Internet Database Remote management technology development process and mode:
Early by writing Cgi-bin program module for database remote management. But the cgi-bin is slow to run, maintenance is inconvenient, now has been basically discarded.
The use of Component object models (Component object model, COM) over the years has been very useful and effective. However, if you are using a Third-party server (the author's web site is built on a third party virtual host), the server side often does not allow users to register their own components for confidentiality or other business reasons.
Introduced in recent years by Microsoft Corporation. NET platform and Sun Company's Java EE platform are very high-end database remote management and service platform. can provide high quality multi-layer (n-tier) application services. of which,. NET (Simple Object access Protocol, SOAP) using Hypertext Transfer Protocol (hypertext Transfer Protocol, HTTP) and Extensible Markup Language (extensible Markup Language, XML technology enables communication services across systems (such as windows-linux) that have been widely accepted and used by developers. Many large applications, such as Enterprise resource planning (Enterprise resource Planning, ERP), are built on such a large platform. But for small and medium-sized applications, such as the construction and maintenance of a website, this large-scale application platform is somewhat cumbersome, the overhead is too large.
Microsoft, once a laggard in Internet technology and Java technology, is in the forefront of XML application development. The XMLHTTP protocol in her XML parser (MSXML) is a very convenient and practical customer/service communication conduit. The comprehensive use of XMLHTTP and ActiveX Data Objects (ActiveX Objects, ado/adox) can easily and conveniently implement remote database management.
Second, the database remote management system
The task flow of database remote administration is:
1, the client sends the database structure and the data query or the modification instruction to the service end.
2, the server accepts and executes the instructions and returns the results to the client.
3, the client accepts and displays the results of the instructions returned by the server.
The two key links to implementing remote database management are:
1, the client and the server between the instruction upload and the results of the data channel, by the XMLHTTP protocol implementation.
2, the service end and the database between the direction of the transfer and results returned by the role of the middle-tier Ado/adox interface completed.
Third, the use of XMLHTTP
As the name suggests, XMLHTTP is a Hypertext Transfer protocol that transmits XML-formatted data.
In fact, the XMLHTTP data transfer process is more flexible:
The instructions it uploads can be XML format data, or it can be a string, a stream, or an unsigned integer array. It can also be a parameter of a URL.
The result can be an XML-formatted data, a string, a stream, or an unsigned integer array.
Please refer to the link at the end of this article.
The process of invoking XMLHTTP by the client is simple, with only 5 steps:
1. Create XMLHTTP objects
2, open the connection with the service side, at the same time define instructions to send the way, the Service page (URL) and request permissions.
The client opens a connection to the Service Web page of the server through the Open command. As with normal HTTP instructions, you can use the "get" method or the "POST" method to point to the Service Web page of the server.
3, send instructions.
4, waiting for and receiving the processing results returned by the service side.
5. Release XMLHTTP Object
xmlHTTP method
Open Bstrmethod, bstrURL, Varasync, Bstruser, Bstrpassword
Bstrmethod: Data transfer mode, i.e. get or post.
bstrURL: URL of the Service Web page.
Varasync: Whether to execute synchronously. The default is true, which is synchronous execution, but can only be implemented synchronously in the DOM. It is generally set to false in the application, that is, asynchronous execution.
Bstruser: User name, can be omitted.
Bstrpassword: User password, can be omitted.
Send Varbody
Varbody: Instruction set. can be XML format data, or it can be a string, a stream, or an unsigned integer array. You can also omit the instruction by substituting the URL parameter for the open method.
setRequestHeader Bstrheader, Bstrvalue
Bstrheader:http Header (header)
Value of Bstrvalue:http header (header)
If the open method is defined as post, you can define the form to upload Xmlhttp.setrequestheader "Content-type", "application/x-www-form-urlencoded"
XMLHTTP Property
onReadyStateChange: Gets the event handle that returns the result in the synchronous execution mode. Can only be invoked in the DOM.
Responsebody: The result returns an array of unsigned integers.
Responsestream: The result is returned as a IStream stream.
ResponseText: The result is returned as a string.
Responsexml: Results are returned as XML format data.
Here is an example of an application in the source program attached to this article:
Function GetResult (URLSTR)
Dim xmlHttp
Dim Retstr
Set xmlHttp = CreateObject ("Msxml2.xmlhttp") ' Create object
On Error Resume Next ' ERROR handling
Xmlhttp.open "Post", Urlstr, False ' opens the connection by post and executes asynchronously.
Xmlhttp.setrequestheader "Content-type", "application/x-www-form-urlencoded" ' upload form
Xmlhttp.send ' Send instructions
If Err.Number = 0 Then ' If the connection is correct
Retstr = Xmlhttp.responsetext ' Wait and get the result string returned by the server
Else
Retstr = "Url not found" ' Otherwise error message returned
End If
Set xmlHttp = Nothing ' Frees objects
GetResult = Retstr ' return result
End Function
The GetResult () function takes the URL parameter of a service Web page and places the uploaded instruction on the parameter following the URL, such as:
Urlstr = "server.asp?cmd=" & cmd & "&db=" & DB & "table=" & Table
CMD: execution methods, such as queries, modifications, deletions, and so on.
DB: Server-side database name
Table: Service-side table name
The instructions are then submitted, waiting for and receiving the returned processing results. The result is returned as a string. Finally, the function caller handles and displays the result.
Original source: http://javatm.blog.ccidnet.com/blog/ccid/do_showone/tid_38357.html