Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 128,860 times

Contents

Related Categories

Uploading Files with ASP - The VB Component

The VB Component

Now, we can get started on the VB portion of this tutorial. Create a new ActiveX DLL project in VB, and set the Project's name to 'ASPUploadComponent'. Next, create two Classes to the project, and call them cUpload and cFormItem respectively. cUpload's Instancing property should be set to 5 - MultiUse, and cFormItem's should be set to 2 - PublicNotCreatable.

Finally, you need to add a reference to the ASP Type Library. To do this, go to Project|References, and check the box next to Microsoft Active Server Pages Object Library, and the Microsoft Scripting Runtime (so we can use the FileSystemObject). Now we can get coding...!

Debugging an ASP Component
I think you should be warned at this stage that debugging a VB component used in an ASP script is notoriously difficult. You can't simply press F5 to run the component, as it isn't a stand alone executable. Nor can you use the 'Wait for component to be created' option, as IIS isolates any ActiveX components created in your ASP script for security reasons. Unfortunately, this means VB can't gain any debugging information either.

Therefore, your only option is to compile your component each time you make a change. However, it gets worse... When your script accesses the component for the first time, it locks the file. Your OCX file is not unlocked again until the IIS service stops, meaning that each time you want VB to re-compile the component you have to restart IIS (and not just the web you are using either... all of IIS!). To restart IIS, go to Services, select World Wide Publishing Service, and click Restart.

One last thing... if you would prefer to skip the VB coding section, you can download the source code and binaries here. Then, you can skip to this step.

James first started writing tutorials on Visual Basic in 1999 whilst starting this website (then known as VB Web). Since then, the site has grown rapidly, and James has written numerous tutorials, articles and reviews on VB, PHP, ASP and C#. In October 2003, James formed the company Developer Fusion Ltd, which owns this website, and also offers various development services. In his spare time, he's a 3rd year undergraduate studying Computer Science in the UK. He's also a Visual Basic MVP.

Comments

  • Invalid class string error

    Posted by selvass on 19 Apr 2005

    When i call to component in asp, when i run the uploaddemo.asp, i choose one file, once i press uploading
    showing at Invalid class string error. please help me this how to solve this.

  • A progress Bar for the Upload Component

    Posted by haguila on 12 Apr 2005

    Hi:
    The component is really good, the code works fine and it has not any problem when is impersonated via MTS.
    So, congratulations.
    From my ignorance the problem is the Event Blindness: I cannot mo...

  • Doubt

    Posted by livinvarghese on 03 Dec 2004


    Hello,

    how i can upload an Excel file which having the file Size 6MB by ASP.NET to the database.

  • ASP and VB DLL Debuggubg

    Posted by sunnysuku on 01 Apr 2004

    Please Help me !!
    How can I debug ASP pages and VB compenets . Ie I have ASP pages in Visual Interdev. These pages talking with few DLLS. I have the VB Source code for these dlls also. Please tell me...

  • what are the components of ASP?

    Posted by preetha on 01 Mar 2004

    What are the components of ASP and VB? Pls help me.