The COM Course - Part 2
Instead of testing our application within Visual Basic this time, I'd like you to compile it.
- Click 'File', 'Make Project1.exe'
- Choose a memorable directory and click 'OK'
- Close Visual Basic
- Run the .EXE file you just compiled
In the Form that appears, try opening a customer, changing the details, then clicking OK. Next, try reopening that customer. Are the details you entered still there? They should be because your ActiveX DLL saved them to the database.
Now sit back for a few moments and think about what you've just done. You've created your very own database application with update facilities... all in just a few simple lines of code. The COM bit took a little more effort, but your final using-application was a doddle.
And that's the power of COM. It's make your life harder before making it one heckuva lot easier.
- When you've finished testing your application, close it
If you thought things were running too sweetly, I've got news for you they were. So here I am with a great big spanner to throw into the works:
- Open your Northwind project
Now just pretend you've made a few changes and need to recompile. Righto, let's do that now:
- Click 'File, 'Compile Northwind.dll'
- Choose the same directory as your last Northwind.dll (one will overwrite the other), then click OK
Top Tip: If you get errors compiling, it's probable that something else is accessing your program. Attempt to close all running applications then try again.
- After compiling, close Visual Basic
- Attempt to run your 'Project1.exe' again
What's that? You got an error message? Class doesn't support expected interface or something like that? Oh dear.
Well, that's my great big spanner. When you recompiled your ActiveX project, the program that used it just fell to pieces.
How can you fix this? Well, one way is to reopen your Project1 files and do a recompile. But just imagine all two hundred people in your office use Project1. That means you have to completely recompile the project and roll both it and the new DLL out smoothly to over two hundred people with minimum disruption.
Can you spell impossible?
No, what we need to do is find out why this error has occurred. Why can't your project see and work with your newly-compiled DLL? The answer is compatibility and we'll be dealing with this and more next time on the COM Course!
Page 8 of 9