Thursday, June 28, 2007

Windows Vista and Outlook 2003 - mapi32.dll Error Fix

I finally purchased my poor wife a new computer. She's been stuck on my old Pentium III 450 from 1999 for a couple of years now, ever since I upgraded. It's still serviceable and accomplishes what she wants, which is primarily email and some word processing, but man is it slow loading. And it won't even run some of the online flash games the kids like to play - the graphic are all jerky and stuff. Even GMail is slow because of the client side AJAX stuff it needs to do.

So I got her a new small footprint computer from Cyberpower Inc., pretty basic configuration: Socket AM2 Athalon 64 X2 3800, 1GB, 80GB drive, DVD+-RW. Came in a cool square box about the size of four shoe boxes stacked 2x2. And (deep breath) I decided to take the plunge and get it with Windows Vista Home Premium preinstalled.

It arrived in a week and I set it up last weekend. Vista comes with a free 30 day trial of Office 2007, but I already owned Office 2003 standard and I'm not interested in upgrading. So I after stumbling around in Vista for a while, I managed to set it to classic mode so it looked like Windows XP and I could actually find what I was looking for, I (in this order):

1. Installed Office 2003 Standard (Outlook, Word, PowerPoint, Excel)
2. Uninstalled the Office 2007 Trial version

Then I tried to run Outlook 2003 so I could set up her email....
Cannot start Microsoft Office Outlook. MAPI32.DLL is corrupt or the wrong version.
Doh!

Outlook won't even start. All I get it that error. I'll spare you the two or so hours of research, uninstalling, re-installing, repairing and other efforts and just give you the solution that worked for me:
  • Locate the file MSMAPI32.DLL in Program Files\Common Files\System\MSMAPI\1033
  • Rename the file to something like MSMAPI32.XXX or MSMAPI32.OLD
Now restart Outlook. Hopefully you get the same result I got: Outlook showing up all nice and pretty and ready to play.

This doesn't address the further issue of setting up Outlook to work with her free Hotmail account. I know, I know, I've been trying to get her off Hotmail for years.

An aside - so far, Windows Vista has caused me nothing but headaches, mostly (I admit) because I have to fumble around to find things I know inside and out when it comes to XP or 2000. Would you believe some of the system files and folders don't even allow permissions to the Admin account?

If I had it to do over again, I would order the computer with XP Pro.

Tuesday, June 26, 2007

Retro Sneakers

Do you remember these?

Black Chuck Taylor Tennis Shoes

My daughter bought me some for Father's Day. We'd recently purchased her a pair of custom Chuck Taylor's for her birthday (xtra-high); we'd gone online and designed them ourselves (www.Converse.com, click on the 'pencil' icon on the navigation compass). They took about 3 weeks to arrive.

When she asked for a Father's Day gift suggestion, I mentioned a pair of black high-top Chuck Taylors. With my wife's kind assistance, they were easily aquired (size 10). I opened the gift on Father's Day.

This weekend I wore them on the family outing to the YMCA. As we hiked across the parking lot towards the car, hearing the screams of the children still playing in the pool, we passed over a bit of sand. I looked back and saw my footprints, the distinctive diamond shapes from the soles of my Chucks. I was reminded of long summer days and grass stains, the smell of pine. I remembered how the fronts of the shoes would get worn smooth, the crisp white rubber fading to a washed-out gray. I would draw deisgns on the rubber, black pen usually, peace signs being in vogue at the time. Others would write the names of their favorite bands - Kiss, Rush, Led Zepplin, Supertramp....

For a the barest flicker of time I was 12 again, a new pair of sneakers on my feet, the summer wind warm on my face and my friends yelling at my side. Running so fast I didn't feel my feet touch the earth, the wind whipping my hair, watering my eyes, my breath burning in the back of my throat. For that smallest moment of time, I was there.....

Friday, June 22, 2007

SQL Server 2000 - Get Most Recent Record ID

If you're like me, you've probably wanted to get the record id of the record you just inserted. There are a few different methods of doing so depending on what database you're using, but this one is specific to SQL Server 2000. You'll have to try it yourself to see if it works on other databases. I THINK it works on Access 2000 or higher, but didn't test it. Should also work on SQL Server 2005 and 2005 Express Edition.

When you call a SQL statement, you can call multiple statements separated by a semicolon. The following is an example of a SQL statement that inserts a new record and then gets the ID assigned to that record, be it an autonumber or guid:
INSERT INTO TheTable (Field1, Field2) VALUES ('Value1','Value2'); SELECT @@IDENTITY AS NewestID
An example of how to use this would be (this assumes you've already set up your database connection and named it dbConn):
rID = ""
strSQL = ""

strSQL = "INSERT INTO TheTable (Field1, Field2) VALUES ('Value1','Value2'); SELECT @@IDENTITY AS NewestID"
set rs = dbConn.Execute(strSQL)
rID = rs("NewestID")
Now you have the record ID of your newest record in a variable!

Thursday, June 21, 2007

ASP "Save As" Dialog

Have you ever wanted to give a visitor to your web site an easy way to download a file without having to do a right click/save as? Or a way to bypass the way IE and other browsers autoload content into the browser when it recognizes the file type?

Here's a script to launch the "Save As" dialog box (teste din IE and FF). I created a file named 'save.asp'; all you do is feed it the name of the file you want to save.
<%
qFile = ""
qFile = Request.Querystring("file")

Response.ContentType = "application/x-unknown" ' arbitrary
fn = qFile
FPath = "c:\Place\To\Save\The\File\" & fn
Response.AddHeader "Content-Disposition","attachment; filename=" & fn

Set adoStream = CreateObject("ADODB.Stream")
adoStream.Open()
adoStream.Type = 1
adoStream.LoadFromFile(FPath)
Response.BinaryWrite adoStream.Read()
adoStream.Close
Set adoStream = Nothing

Response.End
%>
Simply pass in the name of the file you want the user to download as a querystring variable.

I'm calling it with a button instead of a link:
<input type="submit" value="Save it" onClick="window.location.href='save.asp?file=FileName'">
If you wanted to use a link, all you'd do is: <a href="save.asp?file=FileName">Save it</a>

It doesn't spawn a new browser window. It simply brings up the Save As dialog.

I've got it in action on my AddCaption site to allow visitors to easily save the image after they've added their text to it.

Monday, June 18, 2007

Wednesday, June 13, 2007

Generate a Random Letter in ASP

Generating a random number in ASP is easy; generating a random letter is just as easy.

Simply use the random number generater to generate a number between 26 and 97. This number cooresponds to the character (CHR()) of the letters a - z.

If you want to use other characters, here's a chart (use the decimal column).

Here's the function to generate a number between 2 numbers:
Function RandomNumber(LowNumber, HighNumber)
RANDOMIZE
RandomNumber = Round((HighNumber - LowNumber + 1) * Rnd + LowNumber)
End Function
Assign the function to a variable and pass in the LowNumber (26) and the HighNumber (97) and convert the value returned to the character it represents:
RandomLetter = CHR(RandomNumber(97,122))
That's it!

Monday, June 11, 2007

I Got the Monday Working Song Blues, Vol. 1

Thought it might be fun to post a song that pretty much sums up how I felt this a.m., sitting in my cube, staring at the long road ahead and the dirt hole it leads to...

WARNING - contains mature lyrics!

Rage Against the Machine, Do What You Tell Me

If you have suggestions for songs about working, let's here them!

Wednesday, June 06, 2007

More on Microsoft and Web Development

If you read my recent post on Microsoft, you know my position on how they are becoming less and less of a factor in the web development community. If you're interested in seeing how Microsfot treats a hobbyist developer, check it:

Microsoft threatens its Most Valuable Professional

A sad tale of woe about a poor guy who had the nerve to try to make something for Visual Studio Express. I think, all along, most of us have had a distrust of Microsoft (and more other big corps for that matter), but it's disheartening to read they go after a guy like this.

Golly gee Microsoft, is it any wonder why CRAP.NET, and your company, is regarded with such disdain and distrust?

Tuesday, June 05, 2007

AddCaption Update

Last night I added the capability to load an image from a URL, so now you can cut and paste the URL for an image on any site, AddCaption will go get it, and then you can add a text caption to it!

AddCaption

Monday, June 04, 2007

Microsoft and Web Development: In Decline and Staying that Way

I got to thinking about the nature of the web this weekend as I built yet another web site in classic ASP. I started in the Internet industry in 2000 as a "web site coordinator" for an ecommerce web site. I was eager to learn dynamic programming, but wasn't getting the opportunity on the job, so I bought a book and taught myself. The first site I ever built (SFReader) is up and going strong.

As I became more adept at ASP, I began asking for opportunities to contribute on the programming side of the house at my job. Despite my developing skills and eagerness to learn more, my requests to contribute above and beyond my "web site coordinator" role went unheeded. Finally tiring of my initiative and motivation, my manager took me aside one day and said, "Dave, we hired you to be a web site coordinator, not a developer. You need to keep your focus on your main job responsibilities."

It took me three weeks to find another job. My manager seemed surprised when I turned in my resignation. Go figure....

Now, 6 years and 3 companies later, my official job title is 'Software Engineering Manager'. So in that time, I went from a hobbyist web developer to manager level. I supervise a team of 9 software engineers who develop web and database applications for a company Intranet. When I came on board in 2005, they were developing in .Net 1.1. We've since to the 2.0 framework.

Now here's the kicker: I don't know .Net.

Oh, I've got the books and know the best sites with tutorials and all that, but I've never typed a lick of .Net code. Occasionally, the realization that I need to learn .Net surfaces, not because I need it for my current job (I don't, I'm a pointy haired manager now), but because if I ever lose this sweet gig, I'll probably have to go back to programming and jobs for ASP coders are few and far between these days.

I still do web development on the side, and I still build everything I do in ASP. As far as .Net versus ASP for web development, Microsoft, IMO, went in the wrong direction. Sure, you can 'rapidly build and deploy dynamic web application', but put a .Net site out there and see how well it get crawled by the search engines with all that post back and web form and page state crap it uses.

Classic ASP was powerful and easy to learn. .NET is powerful, but certainly not easy to learn, even for experienced ASP developers. Look around the web and you'll see many of the biggest sites out there still use ASP (or PHP) and their stuff runs very well. .Net is an environment best suited for developers building object oriented web and database applications, not weekend code warriors, and it's the weekend code warriors and freelancers out there who built and are still building most of the web.

The penetration of .Net into this demographic ended up being much lower than Microsoft ever expected. A year ago, Microsoft put out Visual Web Developer, which is a free, light-weight version of Visual Studio 2005. Change the name and give it away - a cunning recruitment strategy to get people using .Net? Or a company desperate to bring hobbyist developers back into the fold?

Consider:
1. Thousands of web developers have been using classic ASP for years. There's a ton of stuff developed in it and ton of resources on how to develop stuff in it. A lot of it is free. Just go to Aspin.com or HotScripts.com to see all that's available.

2. All you need to start developing in ASP is a text editor. Microsoft web servers already have ASP installed, you can have an ASP page up and running in an instant, and there are no extra configuration settings or developing environment to mess with.

3. Doing a quick fix on an ASP web site is incredibly easy. If you've the cajones, you can even edit the page right on the the web server and view your results instantly. Try that on a compiled .NET web site. No fun, my programming friend. Fire up your development environment, start Visual Studio, load the project, make your edits, recompile, test. Did it work? Then redeploy the full application to the web site, restart IIS, and check the site. Did it work? Meanwhile, the ASP guy is talking to the new cute graphic artist over by the water cooler.

So by going to .Net, what Microsoft did was abandon an easily learned and implemented web development language that needed no special development environment to a much more complex, object oriented methodology that requires special tools. By doing so, they have pretty much cut out the hobby coder from the equation. The traditional webmaster now has to be a full blooded programmer just to be able to open up a user control's code-behind file to add another item to a DropDownList.

Most 'organic' developers (people who taught themselves) tend to be younger and just out of school. They have a ton of time, but not much money. They get interested in the web, what do they do? Buy Visual Studio and a computer with Windows XP for a couple of grand, or get an empty box for a few hundred dollars, load it with Linux and MySQL, and start typing PHP?

There are two types of programmers who work for me: ones like myself who, some years ago (usually 5 or more) taught themselves to program in ASP (or PHP). The demands of employment eventually forced them to .Net. The other type tends to be younger, maybe a few years out of college, but the difference is that they actually STUDIED programming, and specifically studied .Net. What I don't run into very much any more are job candidates who came up into .Net on their own.

When a neighbor or friend tells me they (or their kid, or their neighbor, or whomever) is interested in getting into web development and how should they get started, I ask what kind of web programming they envision themselves doing. If they reply, "I'd like to do stovepiped, enterprise class, scalable, Intranet applications designed to Service Oriented Architecture standards for a company Intranet" I tell them to start classes in .Net. If they say "web sites and stuff" I tell them to go buy a book on PHP and a book on MySQL.

So what's my point? Ever since Microsoft moved away from ASP to the .Net offering, there has been a continuing downward trend in programmers working in the Microsoft development environment. Newbies find .Net too hard to learn and too expensive to get started with, so they aren't picking it. ASP developers are declining as well, since the perception is that sooner or later Microsoft will stop supporting it. That leaves PHP, which continues to grow as a web development language and gain more and more programmers.

Microsoft screwed the pooch in a big way when they moved away from an easy to understand, inline coding language. The very essence that started the dynamic web is missing in .NET because it is too difficult. The hobby web developers and the newcomers face a much steeper learning curve and a more expensive startup, which usually leads them to choose another platform.

Microsoft's weak attempt to ignite .Net interest in weekend coders with their free offering of Visual Web Developer is too little and too late. As time passes, Microsoft and .Net will become less and less of a player in the open Internet community, relegated instead to the moribund development shops of major corporations, where mostly middle-aged men (who reminisce fondly about the good old days of ASP) and a few recent grads (mislead by their guidance counselors to study .Net) will grind out stovepiped OOP applications for an Intranet.

Sunday, June 03, 2007

Add Text to Image

I had an idea after reading a news article about lolpresidents, a site where people post pictures of presidents and presidential candidates with (sometimes) funny captions. I thought: "Wouldn't it be cool if there was a site where you could upload and add the text to the image right online?"

So this weekend I built it.

www.AddCaption.com
Add a Text Caption to an Image

You can resize images too.

Check it out....