This simple sample
When you run the sample the form in Figure B-7 appears, displaying only one enabled button: Connect. If you click this button, the sample invokes the Data Link Properties dialog box to prompt you for a connection string.
Figure B-7. The No Chunks sample on initial startup.
Once you've built a valid connection string, the sample connects to your database, disables the Connect button, and enables the Create Table button. Clicking this button creates in your database a table that's designed to store the contents of files. I wrote the sample to work with SQL Server, which calls its large binary data type "image." If you're using a database program other than SQL Server, this query might fail; you'll need to check the documentation for your database software and change this query in order to properly create the table. As long as you don't change the field
NOTE
Don't try to store files in text fields. I don't believe I've ever seen this clearly stated in product documentation, but it needs to be said. Even text files contain binary data. Most database systems have separate data types for large amounts of text and binary data. Binary data is not subject to internationallocalizations or ANSI/Unicode conversions, but text data is. So give unto text data types what is text and give unto binary data types what is binary, and there will be much rejoicing.
Once the sample creates the table in which it can store file contents, you'll see the Move File button enabled. Click this button, and the sample will prompt you for a file to move. Select the file, and the code uses the Stream object to move the contents of the file into your database.
Once this operation completes, the code deletes your file and displays a dialog box that lets you know the file has been deleted. At this time you can
Take a look at the code in the
Click
event for the Move File button. The ADO code is much simpler than any sample code using the
AppendChunk
and
GetChunk
methods. (See Chapter 4 for a description of these
The My Web Site sample shows how you can use the ADO object model—
I built this sample to communicate with Internet Information Services (IIS) 5 running on Windows 2000 Server, but I was able to use the sample with Internet Information Server 4 running on Microsoft Windows NT 4.0 Server as well, and with Personal Web Server running on Windows NT 4.0 Workstation. The OLE DB provider uses WebDAV—a standard that most web servers support—to communicate with the web server.
For security reasons, web servers
When you run the sample, it immediately displays a simple dialog box prompting you for the location of the web site you want to manage. The sample then connects to that web server using the OLE DB Provider For Internet Publishing and displays the contents of the web site in tree view.
From there you can copy, delete, move, and download files by right-clicking them and selecting the appropriate action from the context menu. You can also upload new files by right-clicking a folder and selecting Upload File. Right-clicking a folder also lets you copy, delete, or move that folder and all its contents.
The code in this sample is simple and straightforward—which is why I created it. Using ADO and the OLE DB Provider For Internet Publishing, you can manage the contents of your web servers with some very simple code.