Professional Ado 2.5

Professional Ado 2.5

by SUSSMAN, McCarthy, Ian Blackburn, Brian Matsik
     
 

The release of ADO revolutionized data access by providing a universal means of accessing data from both relational and non-relational sources. ADO has been growing steadily in functionality since its inception: ADO 2.1 added extensions for data definition and security, and support for multi-dimensional data. ADO 2.5, to be released with Windows 2000, adds even more… See more details below

Overview

The release of ADO revolutionized data access by providing a universal means of accessing data from both relational and non-relational sources. ADO has been growing steadily in functionality since its inception: ADO 2.1 added extensions for data definition and security, and support for multi-dimensional data. ADO 2.5, to be released with Windows 2000, adds even more functionality, including two completely new objects for manipulating streams of text or binary data, and for managing objects within the file system. It also includes a new data provider for accessing web resources. This book provides in-depth coverage of all aspects of programming with ADO 2.5, and provides you with all the information necessary to fully exploit this exciting new technology in your data-centric applications.

Product Details

ISBN-13:
9781861002754
Publisher:
Apress
Publication date:
12/01/1999
Series:
Professional Series
Edition description:
2000
Pages:
971
Product dimensions:
(w) x (h) x 0.08(d)

Read an Excerpt

Chapter 8

This manuscript is an abridged version of Chapter 8 from the Wrox Press book Professional ADO 2.5 Programming. Chapter 8 covers the OLE DB Provider for Internet Publishing. This provider was released with ADO 2.1, but had very limited functionality, and it is only with the 2.5 release that its full potential has been realized. What it gives us is the ability to access data remotely from suitable Web sites and from Exchange 2000 through ADO. So, in this chapter we're going to look at reasons why this management is necessary, how the Record and Recordsets are used together, URL management, file manipulation, updating flies remotely, and where all this will lead us in the future.

The release of ADO revolutionized data access by providing a universal means of accessing data from both relational and non-relational sources. ADO has been growing steadily in functionality since its inception: ADO 2.1 added extensions for data definition and security, and support for multi-dimensional data. ADO 2.5, to be released with Windows 2000, adds even more functionality, including two completely new objects for manipulating streams of text or binary data, and for managing objects within the file system. It also includes a new data provider for accessing web resources. Professional ADO 2.5 Programming will cover in depth all aspects of programming with ADO 2.5, and provide you with all the information you need to exploit this exciting new technology to the full in your data-centric applications. For further details about the book, and other books in our range, visit the Wrox Press Web Site.

  • Resource Management >
  • The Record and Recordset Objects >
  • TheFields of a Record >
  • Adding URLs >
  • Files >
  • Streams >
  • Security >
  • Related Areas and Summary

Internet Publishing

Let's get one thing correct from the start. This chapter isn't about how to create Web sites or the why and how of document publishing on the Internet. It does have some of those elements in it, but as you've been told several times already, this is an ADO book. So what we are really concerned with in this chapter is the OLE DB Provider for Internet Publishing.

This provider was released with ADO 2.1, but had very limited functionality, and it's only with this 2.5 release that its full potential has been realized. What it gives us is the ability to access data remotely from suitable Web sites and from Exchange 2000 through ADO. So, in this chapter we're going to look at:

  • The reasons why this management is necessary.
  • How the Record and Recordsets are used together.
  • How the provider manages URLs.
  • How we can manipulate files remotely.
  • How we can update files remotely.
  • Where this will lead us in the future.

All in all it's a pretty exciting area, so let's dive in.

Resource Management

This whole chapter is really about the management of resources. I'm using the term resource as a generic description for a file or directory on a Web server. This is an important point because although files provide the content for Web sites, it's the directories that make up the structure, and managing the structure of your site is just as important as the content.

Having established the term resource, what do we mean by management? Isn't that done through some special tool, like the MMC for Microsoft IIS? Yes it is, but only to a certain degree. The IIS snap-in certainly allows the creation of site and virtual directories, how applications run within those sites, and certain permissions, but it really doesn't deal with the structure or content of the site once it's created. It can, but that's not its central role.

The Problem

So, once a site is created we are faced with several questions:

  • How can I manage the resources within the site?

  • How can I allow other users to manage the resources in a controlled way?

  • How can I access the resources if I'm not in the office?

These are questions I'm sure many site administrators have asked themselves, and they are quite reasonable questions. Not only does the Web have a huge amount of data available, but it's also growing at an alarming rate. We're constantly reading about information overload. I for one have enough trouble managing my own hard drive, let alone a Web site exposed to the world.

Let's look at these questions in relation to a fictional Web site, based around the Greek gods. Zeus has decided that the Pantheon of Gods is going online, with a main Web site, which he will control, and sub-sites for several of his friends. He would like a structure similar to this:

...

Notice that Hera doesn't have a directory - she was always arguing with Zeus, and he isn't going to help her unless she asks nicely!

One important point is that this is a completely normal Web site. It is not set up to use the FrontPage Server Extensions.

How Can I Manage the Resources Within the Site?

"Managing the resources," said Zeus, "what does that really mean?"

Well, there are several things to think about:

  • You need to control the main site and the general structure, but you don't want your friends messing with the main pages.

  • You want to be able to create new pages and edit the existing ones, move them around, delete them, and so on.

  • You need to create the main pages to provide links to your friends' pages.

  • You don't want to rely on a single tool, and you'd like to use a combination of tools to edit these pages - an image editor, HTML editor, and so on.

These aren't particularly complex issues, but it clarifies what the site management means.

How Can I Allow Other Users to Manage the Resources in a Controlled Way?

"I want my friends to create their own pages," said Zeus. "I'll give them a helping hand and start them off, but I'd like them to manage their own set of pages in the same way that I do. I only want them to be able to edit their own pages, and not anyone else's."

As with the main site, each of the sub-sites needs the same management control as the main site, but this time with a different user. So what you need is access control and namespace control. Each user can only edit their own section of the site.

How Can I Access the Resources If I'm Not in the Office?

"I don't want to be stuck in the office all of the time," Zeus chimed, "so how can I manage the site remotely? Can I have the same management facilities as though I was in the office?"

You could use a dedicated tool that is integrated with the Web server (such as FrontPage and the FrontPage Server Extensions), but this is a proprietary solution. What happens if you want to move your Web site to another machine, or use a different editing tool? Or perhaps you're away and you've only got a browser. What you really need is the same functionality as though you were sitting in front of the server. You need to be able to create files, edit pages, and so on.

The Solution

The solution to all of these problems is to use Web Distributed Authoring and Versioning, or WebDAV for short. So what exactly is it? WebDAV is a W3C standard that extends HTTP 1.1 to include a set of new commands allowing the management of web resources. One of the reasons for the great success of the Web is the large-scale adoption of HTTP. If WebDAV is adopted to a similar degree, this will add a whole new set of functionality to the Web.

If you look at the way HTTP works at the moment, then it's pretty simple. From your browser you request a file (using GET), and that file is sent back to you. You can also send data back to the Web browser using POST, or use DELETE to delete the file, but that's about it - HTTP doesn't allow you to do anything else with that file.

However, if we build support for WebDAV into your web server, then we automatically get a new set of commands, some of which are shown below:

  • PROPFIND, to allow the retrieval of properties.

  • PROPPATCH, to allow the updating of properties.

  • MKCOL, to allow the creation of new collections (resources that contain other resources, such as folders).

  • COPY and MOVE, to allow the copying and moving of resources within a namespace.

  • LOCK, to lock a resource.

You can immediately see what sort of opportunities these give you. For example, PROPPATCH allows you to update values in a file on the server. COPY and MOVE allow you to manage files, and LOCK allows you to perform lock management. With just a few new HTTP commands we've suddenly answered many of those questions about resource management. Version management is still an issue, but we'll come to that later.

The real problem of course, is how you use these new commands. The first thing you need is a Web server that supports them, and luckily IIS5 fully supports the standard (there's a list of other servers at the end of this chapter). The second thing you need is a client to make these command requests, and since not many people use HTTP commands directly, Microsoft has created OLE DB Provider for Internet Publishing.

The Internet Publishing Provider

The whole idea behind this provider is that it's built on top of WebDAV, and uses the native HTTP commands. The great advantage of this is that you don't have to learn how to do all the nasty HTTP stuff, because ADO does it all for you.

To illustrate the use of this provider, we'll build a management tool using HTML and scripting. We could just as easily build this in Visual Basic (or any other COM-compliant language), but using HTML and scripting languages gives us a thin client approach. This tool only needs IE5 and ADO 2.5 installed on the client machine, whereas a Visual Basic application would require installation (with a setup program).

We're not going to detail every aspect of how the tool was built, because much of it is just the HTML side of things. What we'll concentrate on is the ADO usage. The full tool is well commented and available for download on the Wrox web site, along with a Visual Basic example.

Just so you can see what the final tool looks like, there's a screen shot below:

...

What we have is a list of files and directories on the left of the screen. A menu gives us options for managing those files, and the right-hand side of the screen displays the details for the selected option.

Because this is a web-based tool, the examples in this chapter will be in JavaScript, but they are extremely easy to translate into other languages. I'll gloss over some of the purely HTML and scriptlet-based parts of this tool, because they aren't really relevant to the ADO discussion.

If you'd like to emulate the site, then everything is downloadable from the Wrox site. I created a new web site on an existing machine for this, but you could just as easily use a virtual directory.

As a word of warning, you might have trouble using some of the Record and Stream methods from ASP. At the time of writing I (and several other people) hit some security problems where URLs failed to open from ASP, but similar code worked fine in Visual Basic. As a workaround, I added the IUSR_ account to the Administrators group, and this stopped the errors. Remember, though, that this is not a solution you should take on an exposed Web server, since this could lead to a security breach. However, this solution should be fine for testing the code on a local server.

Read More

Customer Reviews

Average Review:

Write a Review

and post it to your social network

     

Most Helpful Customer Reviews

See all customer reviews >