Use SQLXML 3.0 (Web Services, XML Views, Managed Classes)
Mood
2002-5-25
Article Type: Overview
Difficult Level: 5/9
Version: 4.16
Use SQLXML Managed Classes
There are not many Managed classes provided by SQLXML. DOTNET Framework provides MS SQL 2000 Data Provider, which means you can use ADO.NET's Class to execute the query of the for XML clause, but you will not use these Class to do our top The template and server-side XPath commands. So the Managed Classes provided by SQLXML is also focusing on these aspects, gratifying these Classes and ADO.NETs can work well, such as DataSet. From below this picture we can see the object of SQLXML Managed Classes model:
Through these Managed Classes and the original DOTNET Framework, we can access databases through more ways. And we see the form of information flow can be varied. For performance, developers will choose different ways according to specific situations (see SQLXML3.0 documentation: Architecture of Client-Side and Server-Side XML Formatting) However, it may change our original architecture architecture. Some examples of SQLXML 3.0 have turned this, and they also want to prove that SQLXML can have some good processing for some applications. The situation and play the powerful advantages of XML.
The concept of DAL is so popular, and I also draw some code from the Project Track System code, form a DAL component, and I tried to test a simple hypothesis, that is, first define a template (XML VIEW), then perform this template with DAL, remove the data from it, and finally display it with a simple XSLT. Template uses any of our above to display the template of the Employees table, and then we display the results of the execution template in a GRID and make the same result to make an HTML Table display by XSLT. The results of this picture use two different ways, the data in the ASP.NET Grid is displayed like this, first we add a new item: a Dataset, then we copy the Schemas file generated by vs.net. Content, it can be said that both, then we can produce a C # class based on this Dataset, then we drag this Dataset to WebForm design view, will appear in Wizard, select this Dataset. Then we drag into an ASP.NET's DataGrid control, set it DataSource is this DataSet. Then add the following code at Page_Load:
Private Void Page_Load (Object Sender, System.EventArgs E)
{
// put user code to initialize the page
Employees1.readXML (New XMLTextReader ("http://localhost/northwind/templates/emplyeesvs.xml"));
DGEMPLOYEES.DATABIND ();
} So we have completed the display in DataGrid (clear this method does not use new Class, only DOTNET FRAMEWORK). As for the HTML Table display below Grid, it is obtained by performing DAL and an XSLT. The rough code is as follows: public void WriteTable ()
{
String retXMLSTRING;
Xslthelp xslhelp = new xslthelp ();
SQLXMLDAL = New SQLXML ();
Retxmlstring = SQLXMLDAL.ExecuteTempltefile ("SELECTEMPLOYEES.XML");
Retxslstring = xslhelp.Applyxsl (Retxmlstring, Server.MAppath ("Employees.xslt"));
Response.write (retxslstring);
} The last code is to use XPath to access mapping files. I often use the following code to test my mapping files and XPath expressions.
SqlXmlCmdObj = new SqlXmlCommand (SQLDBConnStr); SqlXmlCmdObj.CommandType = SqlXmlCommandType.XPath; SqlXmlCmdObj.CommandText = "Employees"; ResultStream = SqlXmlCmdObj.ExecuteStream ();; SqlXmlCmdObj.SchemaPath = SchemasDir "EmployeesVS.xsd" StreamReader SR = new StreamReader ( ResultString = Sr.ReadToend (); console.writeline (resultString); Ok, I think this simple example will also end our journey, and we will roughly investigate some new features in SQLXML3.0, Although I only opened a head, we have found a lot of content and concepts inside (all in detail, I can write a book "Haha), of course, we only examined a few functions that are very interesting and easy to get started. Many of them have not truly in-depth, but I have already begun to assume that you have used SQL 2000 XML feature before, assume you have a general understanding of XDR, XPath, XSLT and impression. Finally, I have to improve the difficulty level of this article. I think this is my problem. After more than one or two months, it is almost written while writing while writing while writing while writing, so I will ignore some, so that The article is more difficult to read. However, I believe that there is enough feature in SQLXML to make you impressed it, although compared to the Hailstorm model I like, SQXML will still be inferior, but from Microsoft's efforts to SQL Server, SQL Server 2000 And its next version will undertake more features and features, regardless of the XML or data storage itself, SQL Server will not be a simple product, and will move into the direction of development platform, with XML, you will find It can be more closely integrated with other products of Microsoft and easy to reflect their important core roles. (After the article, we may examine some of the features of SQLXML more detail or the latest Microsoft SQL Server Notification Services, I think they will be very specific SQLXML applications and deeper) related files: SQLXML .zip (51K)
Special Note:
This article original, 9CBS signature start, all text and photo copyright. Do not propagate, reprint, or adaptation without authorization.
If you have any questions or suggestions, please email new2001@msn.com