Friday, May 16, 2008

UFOs - I love this stuff

I just read in Swedish techie newspaper Ny Teknik that British Department of Defense has released all their previously secret UFO reports since 1978. They have now made them publicly available on the web because all requests for them amounted to too much xeroxing work... :)

Labels:

Thursday, May 15, 2008

Exchange Session Failed Communication Interrupted

Yesterday I went ahead and bought the new Sony Ericsson z770i that I blogged about some time ago. I have been waiting a few weeks to get it in black instead of silver and during that time they announced another model - z780i - that should be all that the z770i is but also with a built in GPS. It seems there is always another model being announced, so even if I would have preferred the z780i I wasn't prepared to wait any longer. I also hear that it will not be sold on the Swedish market for some reason (maybe because they just started shipping the z770)

Last night after I put the children to bed I played around with it and tried to get ActiveSync to work. I filled out the info in the Synchronization settings and connected but only got "Exchange Session failed Communication interrupted" (or since I have Swedish selected as language: "Exchange Sessionen misslyckades Kommunikationen avbröts")

I searched the Sony Ericsson Support Knowledge base - not a single hit for neither Exchange, ActiveSync nor Active Sync! :(

Thanks to Google and this thread by dmwood at Microsoft Technet, Goran at my Hosted Exchange 2007 provider managed to solve this for me late last night. In my Hosted Exchange Control Panel the ActiveSync Policey "Allow Non-provisionable devices" was unchecked. Once Goran checked that option for me everything started to work. Thanks Goran for working late and helping me out!

I also sent an email to Sony Ericsson support and this is their reply this morning:

Confirm with your IT staff that device security settings on the server allow access to devices that do not fully support password settings. This option is available in:

Exchange System Manager > Global Settings > Mobile Services > Device Security

If this checkbox was unchecked, you will get a connection failed, although a Windows Mobile device would still sync properly.

The following security settings are supported:
Wipe: PIM data and settings are supported.
Exchange 2003 Device security Settings: NOT supported.
Exchange 2007 Additional Security settings: NOT supported.


I will probably get back with a post on the differences between using Windows Mobile ActiveSync and non-Windows Moible/Sony Ericsson ActiveSync, there are a few.

Labels: , , ,

Monday, April 28, 2008

Office 2003 menu in Office 2007 ribbon?

I know Microsoft says that the new Office 2007 ribbon is more productive than the old menus. I for one don't buy it, I still spend way too much time in Word or Excel 2007 trying how to figure out how to do the simplest thing that I've always known how to do in previous versions...

I have yet to find the function where you turn on the old Office 2003 menus in Office 2007 but I have finally found the next best thing - the reference that maps Office 2003 menu commands to the Office 2007 ribbon!

Excel 2003 to 2007 version here and Word 2003 to 2007 version here


Bookmarked, blogged and to be used many times!

Labels: ,

Friday, April 18, 2008

Find an Active Sync Mobile Phone

How do you find a new cell phone that can sync well with Exchange?

I love my Qtek 8500 (HTC StrTrk). Even though it has now been over two years since I first got it I haven't been able to find anything like it to replace it. And it needs to be replaced. Not only because I like new gadgets but also because the front panel came off and I had to glue it back on myself, the extra memory card has stopped working, the signal fails all the time, it hangs and last week a sat on it so the external display is now broken.

So what's so great about it? I would say three things
  • Exchange synchronization, i.e. Email, Calendar, Contacts and Tasks
  • The small clam shell/flip flop form factor. Before this phone I had never had one but now I would never want to go back
  • Windows Contacts navigation - I love the way results show up as you type. This must be a Microsoft patent as no one else uses this great navigation/look up functionality
Why is it so hard to find a replacement? Well, first of all I want it to be a Windows Mobile which directly limits the choice. Then add that I want it to be clam shell and this limits the choice to almost nothing.

There has been rumors of a 8500 successor, a 3G version - the HTC S420 Erato. But the rumor has been going for over a year and the expected release date has been postponed time after time after time... And there is yet to be an official announcement from HTC.

So, I have decided to give in on it having to be a Windows phone as long as it has good Exchange Synchronization.

But why is it so hard to find out what phones are Windows Mobile or support Active Sync?


  • On Microsoft's Windows Mobile Homepage you can search for devices but it is far from complete (at least for Sweden)
  • Samsung have Windows Mobile phones, but I cannot find a way to find out which from their home page (Swedish market)
  • I know Nokia has phones with Active Sync but how can I find out which?
  • It is the same with Sony Ericsson, they have Active Sync support for some phones, but how can I find them? They have also announced their first Windows Mobile phone, the Xperia X1 which should be available later this year.
I emailed Sony Ericsson and got a reply where they in fact confirm that this information cannot be found for all models on their home page. But they also gave me a list of current phones with Active Sync:
That last one - the z770 - looks like something I might actually want.

The only question that remains - is Active Sync on other brands as good as it is on Windows Mobile?

Labels: , , ,

Friday, February 29, 2008

Import Excel Data into MySQL in 5 Easy Steps

This is probably nothing new to many, but I spent quite some time to figure it out so I thought I'd post my notes on it.

To import data from Excel (or any other program that can produce a text file) is very simple using the LOAD DATA command from the MySQL Command prompt.
  1. Save your Excel data as a csv file (In Excel 2007 using Save As)

  2. Check the saved file using a text editor such as Notepad to see what it actually looks like, i.e. what delimiter was used etc.

  3. Start the MySQL Command Prompt (I'm lazy so I usually do this from the MySQL Query Browser - Tools - MySQL Command Line Client to avoid having to enter username and password etc.)

  4. Enter this command:
    LOAD DATA LOCAL INFILE 'C:\\temp\\yourfile.csv' INTO TABLE database.table FIELDS TERMINATED BY ';' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' (field1, field2);

  5. Done!

Very quick and simple once you know it :)


Some notes from my own import - may not apply to you if you run a different language version, MySQL version, Excel version etc...
  • TERMINATED BY - this is why I included step 2. I thought a csv would default to comma separated but at least in my case semicolon was the deafult

  • ENCLOSED BY - my data was not enclosed by anything so I left this as empty string ''

  • LINES TERMINATED BY - at first I tried with only '\n' but had to add the '\r' to get rid of a carriage return character being imported into the database

  • Also make sure that if you do not import into the primary key field/column that it has auto increment on, otherwhise only the first row will be imported

Labels:

Wednesday, February 06, 2008

Facebook Photos to your Windows Mobile Cell Phone

I just stumbled over this cool tool - OutSync - from Mel Sampat who's a Windows Mobile Program Manager at Microsoft.

It allows you to sync the photos of your Facebook contacts to Outlook and then on to your Windows mobile cell phone (or other phone if you have sync software that synchronizes photos)

I always wanted to have some photos in Outlook and my phone but never really got around to trying it out. Also it would be too much work to get photos of everyone but this tool solves that quite nicely - at least if you use Facebook.

It's easy to install and worked right away for me on my Vista and Outlook 2007 setup.

There are some things that I would like to see improved, mainly that it only matches on name so your contact has to have the exact same spelling in Outlook as in Facebook. It should be able to match on email (but I think the problem here is that the Facebook API does not allow this) or let you do a manual match. A feature that is listed as "coming soon" is birthday synchronization.

I also wish there was a similar tool for syncing Outlook and Live Messenger, but maybe there already is?

Labels: ,

Friday, January 04, 2008

Partial Restore of Mysqldump Backup

Just recently I started making backups of my MySQL databases using mysqldump.
I have a small batch/command file running on my Windows based MySQL Server, scheduled to every night backup all of my databases to a file named backup_all_dbs.sql:

"C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqldump" --all-databases -u username --password="password" > c:\backup\%DATE%\Backup_MySQL\backup_all_dbs.sql


A few weeks ago I finally upgraded my MySQL server from 4.1 to 5.0. For once I did everything by the book which included backing up all my databases using the backup tool in MySQL Administrator, installing the new server version and then restoring all databases.

Today however I just realized that somehow two tables in one of the databases did not get backed up and hence not restored. Fortunately I still had the nightly backup from the day before upgrading.

So I thought I'd just do a selective restore from the mysqldump file using MySQL Administrator (part if the MySQL GUI Tools) Turns out MySQL Administrator does not read files created with mysqldump.
And worse: a quick Google reveals that mysqldumps cannot be partially restored :(


My next couple of hours I spent installing and uninstalling various text editors that could open my 500+MB backup file from mysqldump. I finally found one that could, even though it took a while... (using a Windows Vista machine with 2GB RAM) - NoteTab Light 5.5 (freeware)

Using this I opened the backup file created with mysqldump and sure enough it was a text file containing SQL statements (too bad MySQL Administrator could not open it, hopefully it will in a future version).
I simply deleted the SQL statements for all databases except the one I wanted to partially restore. Then I restored it on my development machine using this command:

"C:\Program Files\MySQL\MySQL Server 5.0\bin\mysql.exe" -uusername -p dbname < c:\backup\2007-12-13\backup_all_dbs.sql


Important note: If you have backed up full databases (not just tables) then it seems the dbname parameter doesn't matter, it still restores to the original database name - lucky me I did it on my development machine!

After the restore I did a partial backup using MySQL Administrator. Moved that backup file to my production server and did a restore using MySQL Administrator on that machine. Voìla!


So, to sum up:
1) Open your dump file in a large file text editor and delete everything except what you want to restore.
2) On a non-production machine (recommended) do a restore.
3) Make a partial backup using MySQL Administrator from your non-production machine
4) Restore the partial backup using MySQL Administrator on your production server.


Job done, finally I can get back to work!

Of course you can skip step 2 and 3 (and/or just restore the specific tables you want) if you like living dangerously ;)

Happy New Year!

Labels:

Monday, October 15, 2007

IE7 performance problems

I have been having some serious performance problems with my Windows XP laptop the last 6+ months. This is a few years old machine, 1GB RAM and Celeron processor.
I did a lot of upgrading around that same time - Office 2007 incl. Groove 2007 and the new Desktop Search and also upgraded to Internet Explorer 7 (IE7). Ever since, I've been trying to figure out which upgrade is draining my performance (or if it was just time for the annual Windows format at reinstall...)
They are all great upgrades feature wise but I wish Microsoft would focus a bit more on performance and not only features.

A few weeks back I switched from IE7 to Firefox 2 as my default browser and almost all of my performance problems are gone!

On my Vista machine I have had a problem with IE7 that when a popup window opens IE7 crashes. I haven't researched this enough but I get a feeling that this occurs when using javascript to open a new window.
Changed from IE7 to Firefox 2 on my Vista machine too and problem gone. No big change in performance on this machine though.

One thing I like about Firefox is the crash recovery feature - if Windows crashes (Firefox itself has not yet crashed on me) or your laptop runs out of batteries etc, when you restart Firefox it asks you if you want to restore all tabs the way they were before the crash. Excellent feature!!

One thing I dislike - or at least have not yet learned to like - is the way Firefox handles drop down menus. In IE I am used to just type the first few letters of whatever I want to navigate to in the drop down. Then I can navigate using the keyboards up and down arrow to navigate the previous or next entry in the list. This keyboard navigation does not work in Firefox, I have to use the mouse to scroll up and down in the list. Also it's not enough to select an entry in the list to trigger changes to the page (Javascript onBlur not triggered?) but I have to either hit the Enter key or navigate to another field.
Also Firefox does not seem to be able to open pdf files/Acrobat Reader in a browser window which is a bit annoying.

Anyway so far there are more positive things than negative with Firefox and I'm happy I finally made the move from IE.

Labels: ,

Friday, July 27, 2007

Outlook Consumes 100% CPU and Stuck at 99% Send/Recieve

For a long time I had a problem where my Outlook client would get stuck at 99% Send/Recieve and at the same time consume 100% (or as much as it can) CPU.

I have two different computers (XP and Vista) running Outlook 2007 against Exchange 2007 (Hosted Exchange) wich had the exact same problem.

When I looked at the Send/Recieve Details it usually said something like "Synchronizing Hierarchy" or just "Updating Inbox". If I did Cancel Send/Recieve the CPU went down to normal.

After looking at the Synchronization Log messages in the Sync Issues folder I found a zillion messages like this:

08:46:56 Synchronizer Version 12.0.4518
08:46:56 Synchronizing Mailbox 'Max Flodén'
08:46:56 Synchronizing Hierarchy
08:47:09 Synchronizing server changes in folder 'Inbox'
08:47:09 Downloading from server 'ex2.myisp.se'
08:48:02 69 item(s) added to offline folder
08:48:04 Synchronizing server changes in folder 'Deleted Items'
08:48:04 Downloading from server 'ex2.myisp.se'
08:48:05 Done
08:48:20 Microsoft Exchange offline address book
08:48:20 Not downloading Offline address book files. A server (URL) could not be located.
08:48:20 0X8004010F


So, the problem seemed to be with the Offline Address Book (OAB).

To make a long story short - after working back and forth with my Hosted Exchange ISP, Googling, creating and recreating Outlook profiles etc - the solution turned out to be that I needed to add a DNS entry for my domain in order for Outlook to Autodiscover which was the problem all along.

Autodiscover CNAME autodiscoverredirect.myisp.se

After adding this DNS entry for my domain it did not even take a minute before I got a dialog box asking me "Allow this website to configure max.floden@mydomain.se server settings?"


And that was it - no more stuck at 99% and no more Outlook consuming all CPU. Finally!

[Update: Found a Microsoft Knowledge Base article that describes this in more detail: A new feature is available that enables Outlook 2007 to use DNS Service Location (SRV) records to locate the Exchange Autodiscover service ]

Labels:

Wednesday, July 25, 2007

Word as Editor in Lotus Notes

I have just started a new project at OpenNTF, the Lotus Notes Open Source community.

The base is a project that I in part developed together with SKF about 18 months ago. Thanks to SKF and Gunilla Darrell for agreeing to donate this code to the OpenNTF community.

The aim was to enhance current functionality when using Word as editor in Notes and be able to use Microsoft Word 2003 functionality such as the Research Pane and Smart Tags (but also simpler things such as the spell checker) to boost user productivity.
Other practical things were addressed, for example that in current functionality Notes sends an email created with Word both as Rich Text and as an OLE object which increases email size by a factor 10-100.

There is one Word as Editor template for OpenNTF Mail Experience and one for standard R6 mail.

Notes uses OLE Automation for it's Word integration and this of course has its limitations. I did manage to work around many of them but I'm sure others will emerge that will need to be addressed.

Development was done using Microsoft Word 2003 and Lotus Notes 6.
Notes 7 and Notes 8 (currently in public beta) together with Word 2007 will with all certainty add new possibilities yet to be explored.

I hope other organizations will find the project interesting and maybe even useful :)

I am looking for an OpenNTF "co-chef" for this project as I currently don't have that much time to spend on it. Let me know if you want to contribute to this project.

Click here for the Word as Editor projects homepage at OpenNTF.

Labels: , ,

New blog design

For you who have visited before you will notice that I've changed my blog design from an all grey to all white...

It's difficult to change and find design templates for Blogger. I'm thinking maybe I picked the wrong blog system and should have chosen Word Press or one of the others instead.

I've spent the last hour trying to get my new template to work. I did not realize I had made that many changes to my old template. I went in to the office today even though I'm on holiday to do some important "can't wait" stuff and this is what I spend my time doing. And it's not even the template I want. I wanted one of these cool designs where the comments pop up like in the comic books.

Well, I guess I'll just have to keep searching.

Labels:

Outlook and outgoing SMTP servers

I have just moved and changed my ISP to one that not only blocks port 25 but also only allows their SMTP relay server to be accessed from within their own network.

When I'm at home with my laptop I have set my outgoing SMTP server as smtp.myhome-isp.com and all is fine. But when I want to work out of my office I have to change it (for all my seven accounts) to smtp.myoffice-isp.com.

I looked and asked around for some smart solution to this problem but found none except the advice to setup my own mailserver or subscribe to a mailserver service.

So, I did the same thing that I did years back when I had the same ISP (and the same problem) - I created two hosts files where I put the IP adresses to respective ISP's SMTP relay servers. (The hosts file is where your computer goes before it goes out to the DNS to lookup an ip adress.)
  1. Goto c:\windows\system32\drivers\etc and make two copies of the hosts file and call them for example hosts.myhome-isp and hosts.myoffice-isp


  2. Edit the files and add an entry to each file for your home and office isp's SMTP relay servers and add the hostname as mailout. You have to enter the IP address of the SMTP relay server (eg 10.10.10.1 not smtp.myhome-isp.com) if you don't know it do a ping or nslookup to find out.


  3. On the desktop (or a location of your choice) create two new batch files, eg. MyHome ISP SMTP.cmd and MyOffice ISP.cmd and add these three lines of code to each:

    cd c:\windows\system32\drivers\etc\
    copy hosts.myhome-isp hosts
    pause

    (Line two above should read "copy hosts.myoffice-isp hosts" for MyOffice ISP.cmd)


  4. In Outlook set outgoing SMTP server to mailout

Whenever you move from home to the office run MyOffice ISP.cmd and vice versa. It may not be the ultimate solution but it works (at least for Outlook 2003 and 2007)

Labels:

Thursday, April 19, 2007

Windows DNS fails with SPF/TXT too long

I run my own DNS for some of my domains. My primary DNS is the built-in DNS service in Windows 2003 SP1 and as backup/secondary DNS I'm using a free service from Twisted4Life. I've been using SPF for a couple of years and it has been working fine.
(SPF - Sender Policy Framework - is way to prevent spam by entering into your DNS what SMTP servers are allowed to send email for your domain. Some email systems such as Hotmail rely in part on SPF when deciding if your email should be placed in the recipients Inbox or Junk mail folder.)

My ISP has been recommending me to use a new SMTP server when sending out email from one of my email lists. So two days ago I added a few new SMTP servers to my SPF record in my DNS (by updating the DNS file in my \Windows\System32\DNS directory and then doing Reload from the DNS console, dnsmgmt.exe) A quick look and everything seemed just fine.

Normally when sending my email list, which contains a bit over 20k recipients, it takes about 10-20 minutes to actually send the batch and then during the next 10 minutes I get about 4-500 error emails telling me stuff like "user is over quota", "no such user" (I use these to clean my email list after each batch).
This time I only got about 15 error messages per hour and it took 36 hours before all had arrived in my inbox!
During this 36 hour period I called my ISP and told them there has to be something wrong with the new SMTP server that they had recommended I switch to. I also did send a test batch using the old SMTP server and it was lightning fast as always.

Today I noticed that I had not recieved any emails from a colleague who is using another email system than me. He told me that he sent me several emails yesterday and this morning and had not recieved any error messages. I told him to call his ISP because my email was working fine, I had emailed back and forth with several people and had no problem.

Then this evening it struck me - I had completely forgot that I made changes to my DNS records. Could I have put something wrong in my SPF records? But why would that effect my incoming email?

First I just did a nslookup using centralops.net online nslookup. This tool reported "Name server failed" for my domains! I quickly tried another online nslookup tool from network-tools.com and this tools reported no errors, it worked fine.

I went in to my server and opened the DNS console. And there, on the line showing the TXT record I use for my SPF string there was a blank space about ten characters into the string, in the middle of one of my SMTP server entries. At the end of the string there was some kind of special character, represented by a "square box". I then looked at the DNS data file at \Windows\system32\DNS but that still looked exactly like it should, without any blank spaces or special characters. Strange...

I then updated the data file from the DNS console (instead of the other way around that I usually do).
When I checked the DNS data file, my TXT record was split into several lines, with line breaks between them, each line starting and ending with a quotation mark. However some characters were missing at the line breaks so I reverted back to the original errornous case, ie where the DNS data file looks fine but in the DNS console there is a blank space and a special character.

Then I went to kitterman.com's SPF validation tool to validate my SPF string. The actual string validated fine. But then, using the same tool, I asked it to validate my domain using a DNS lookup it failed.

Finally, I deleted a few old SMTP servers from my SPF string in the DNS data files and did Reload on the DNS console. Ran my checks again and everything worked fine. And as I'm typing this blog post emails up to 48 hours old have started to enter my inbox.

My conclusion is that using a string that is too long (I have not done any extensive search on this problem, so I don't know how long a string is allowed to be) in a TXT record corrupts the string. This is obviously a bug Windows DNS server.
But the thing that is strange to me is that to some DNS clients, the answer my DNS server sent them was ok and to some unacceptable. I also don't understand why the SMTP servers reacted this way - no delivery I could understand, but extremely slow delivery?

Well, I'm a novice at both DNS and SMTP, so to others this may be crystal clear - please enlighten me!

Labels:

Monday, April 16, 2007

SQL Server 2005 SP2 killed my web sites

A few days ago I was visiting my web server (running Windows 2003). Windows Update prompted me to install the SQL Server 2005 Service Pack 2 update so I went ahead and clicked ok to do that.

Yesterday I was surfing thru my web sites and realized that some of my web sites running on that server did not work as they were supposed to do, ie they only gave an error screen :-(

It turns out the update had stopped my SQLServer service and some of my web sites had been down or partially down for several days.

I know this is my own fault, that I should have checked the server after running a major update, but I was so sure that anything coming thru Windows Update would not stop anything critical on a server. Well, lesson learned... (I hope)

Labels:

Unable to convert MySQL date/time value to System.DateTime

After switching from MySQL ODBC driver to the .NET connector I have been getting this error: Unable to convert MySQL date/time value to System.DateTime.

This is when a DATETIME or DATE field contains an invalid value. It turns out that 0000-00-00 which I have used as default value in a DATE column is considered an invalid date. Instead NULL should be used when date/time is not set.

The one solution I found is to add Allow Zero Datetime=True to the connection string, this allows for 0000-00-00 00:00:00 in a DATETIME column. Just add it at the end of your connection string so it looks something like this:
<add key="connectionString" value="Database=your_db;Data Source=localhost;User Id=root;Password=password;Allow Zero Datetime=True;"/>


This however did not seem to work 100% for my code.
In VB.NET I was using this piece of code to check if the valid_until field (of type DATE) is set or not:
If ("" & myDataReader("valid_until")) = "" Then ...

I was concatenating to an empty string istead of using .ToString() because this (if I remember it correctly) would catch both NULL and 0000-00-00 values (both would evaluate to empty string).
Now instead I got this error message: Conversion from type 'MySqlDateTime' to type 'String' is not valid.

With ODBC, 0000-00-00 used to evaluate to empty string, but using the .NET connector with the connection string work around it returns the actual value, so I have to check for the zeroes instead. So, the solution to my problem is of course to use the proper .ToString function and check for both "0000-00-00" and empty string returned for null value (or even better - use the proper IsDBNull function).

Another way besides using the connection string workaround is of course to fix the data.
  • First check the data definitions in your databases to make sure it does not default to 0000-00-00 (for data type DATE) or 0000-00-00 00:00:00 (for data type DATETIME). I'm still running MySQL server version 4 but I think that on version 5, using 0000-00-00 as default value is no longer valid.

  • Then update the data. An SQL statement to update a column of type DATE would typically look like this for a column named valid_until:
    UPDATE your_table SET valid_until=null WHERE valid_until LIKE '0000-00-00';

Labels: ,

Friday, April 06, 2007

Vista and World Community Grid

I haven't been able to get the World Community Grid (WCG) client (United Devices UD.EXE) to run well on my Vista machine. It has been running for awhile then giving me messages like "Unable to process Task data. Backing-off."

I have Googled but not found a solution. Then today I went directly to the World Community Grid forum, it seems the forum is not indexed by Google for some strange reason.
Anyway I after reading the forum it seems to be a security issue when running on Vista.

Two solutions that seem to be working well:

1) Change security settings for C:\Program Files\World Community Grid (or wherever you installed) so that the group USERS have Full Control.

2) This I have not tried myself but is confirmed by many forum postings: Try to install outside C:\Program Files, e.g. C:\WCG, or even on a different partition than your
system, i.e. not on C:


I also tried running the WCG client (UD.EXE) using the Run as administrator option in Vista (right click the program icon and select Run as administrator). It seems to be working even if I for some reason at first got the logon screen in WCG client. This will not work if you have WCG run at startup.

You would think this problem/solution is something that should be
1) Hilited on the WCG homepage (at least the download section)
2) Fixed in the client or install program

By the way - If you're not already running WCG, why not start today. Let your computer help solve world problems while you don't use it yourself, e.g. when you're on your coffee break.
I recieved this email the other day, this is truly great stuff!
World Community Grid is pleased to announce that the Help Defeat Cancer (HDC) project is finished. The last work units have been sent out and when the final results are returned, the project will come to an end. This project, which launched on July 20, 2006, will have run for just over 9 months by the time the last results are returned. During this time 88,000 members will have donated 2,900 years of computer time on 138,000 different computers. This is a significant contribution to cancer research.

Labels:

Thursday, April 05, 2007

.NET and MySQL in Five Easy Steps

I've been using the MySQL ODBC driver for a long time now in my ASP.NET projects (as posted about here). But today when I was about to start a new project on my new Vista machine I thought I'd check if anything new had emerged the last years when it comes to MySQL drivers for .NET - and not too surprisingly there is now (probably been there for a loooong time) an ADO.NET driver called ADO.NET Driver for MySQL Connector/NET.

So this post is on how to get it going, it's very straight forward.
This is tried on Vista with Visual Studio 2005 SP1 and the Visual Studio 2005 Service Pack 1 Update for Windows Vista using the ADO.NET Driver for MySQL (Connector/NET) version 5.0.6.

1) Download and install (using the included installer) the ADO.NET Driver for MySQL Connector/NET.

2) Create or open a project in Visual Studio 2005. I'm using a VB.NET console project in my example.

3) Go to Project + Add Reference...
On the .NET tab find and hilite MySQL.Data and then click Ok.
(It seems this step can be skipped sometimes...)
[Update: In an ASP.NET project go to Website + Add Reference]

4) Go to Project + YourProject Properties... + References Tab
Under Imported Namespaces check MySql.Data.MySqlClient and MySql.Data.Types and save.
[Update: In an ASP.NET project open web.config and add as namespace under configuration - system.web - pages - namespaces]

5) Write your code and run it. Here is an example to get you started:

Dim myConnectionString As String = "Database=TestDB;Data Source=localhost;User Id=TestID;Password=TestPwd"
Dim myConnection As New MySqlConnection(myConnectionString)
Dim myCommand As New MySqlCommand("SELECT * FROM testtable", myConnection)
Dim myDataReader As MySqlDataReader
myConnection.Open()
myDataReader = myCommand.ExecuteReader
While myDataReader.Read
Console.WriteLine(myDataReader("testcolumn"))
End While
myDataReader.Close()
myConnection.Close()

More examples can be found in the manual from MySQL.

Note: If your accessing your MySQL server on another machine, i.e. not as localhost, you need to make sure the firewall on the server allows access on TCP port 3306. If the server is using Windows firewall just simply go into Control Panel - Windows Firewall - Exceptions Tab click Add Port. (Just make sure you remember to disable the port again after you are done testing!)

Labels: ,

Thursday, March 29, 2007

Loan a stranger your hard earned money without interest or payback guarantee (no kidding!)

This is great - keep reading!

As you may or may not know Muhammad Yunus and his Grameen Bank was awarded the 2006 Nobel Peace Prize for their efforts with micro credits (or microloans or microfinance) in Bangladesh.

Now you too can support a small business in the developing world! Just go to www.kiva.org and select a business you would like to support.

You will be paid no interest and there is no guarantee that you will ever get your money back, even though chances are high:

So far, Kiva has experienced a 100% repayment rate on all businesses with completed loan terms.

Prior to Kiva, our Field Partners have historically experienced a >96% repayment rate with the poor they serve.

In the past 30 years, over 100 million of the world's poor have received a micro-loan and demonstrated a >95% repayment rate.

You can lend from USD 25 (with credit card or bank transfer through PayPal) and up and you will recieve status reports on how your investment is going.

I loaned $25 to Sophia Nasoro from Tanzania who wants to borrow a total of $1000 to grow her catering business.

So what are you waiting for? Go ahead and loan some money today!



Labels:

Tuesday, March 27, 2007

Things I can and cannot get to work in Vista and Office 2007

I just upgraded my laptop running XP to Office 2007 and I've also started using my new desktop computer running Vista and Office 2007.

These are a few things that have bugged me and how I made them work (or not):

1) I could no longer run my macros in Outlook 2007.
Whenever I went in to Tools - Macro - Macros, selected my macro and hit run I would end up in the Visual Basic editor with an error message saying "The macros in this project are disabled. Please refer to the online help or documentation of the host application to determine how to enable macros."
I went in to Tools - Macro - Macro Security and first changed from the default "Warnings for signed macros; all unsigned macros are disabled" to "Warnings for all macros" and finally to "No security check for macros" but I still could not get the macros to run.
In spite of a lot of Googling I found nothing. Then I realized I hadn't tried trick no 1 in the book: Restart Outlook. And of course that was the solution. ;-)
(Note to Microsoft: Please add a "Outlook needs to be restarted" message. Note to myself: Don't be so stupid next time around)

A good thing in Outlook 2007 is that I no longer get the "A program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this? ... Allow for x minutes". I assume they have gotten rid of this annoying message and replaced with some security feature that does not require user intervention.

2) Desktop Search 3.0 had my hard drive indicator constantly lit up for 24 hours
After installing Office 2007 on my laptop I activated the built-in search functionality which requires me to download and install Windiows Desktop Search (WDS) 3.0.
After installing WDS my hard drive starts working overtime with the hard disk indicator constantly lit. Needless to say working with any programs is very slow or does not work at all.
I Googled the processes searchindexer.exe and searchprotocol.exe and get the advice to shut down the Windows Search service but it restarts after awhile. After trying various things I figure that maybe it just needs to finish indexing and almost 24 hours later the hard drive indiciator finally goes blank and my 85000+ documents (according to the WDS Indexing status window) are indexed.

So the problem was that 1) the indexing is slow, and 2) it takes up too much resources when you're using the computer (in my case a Celeron laptop running XP with 1.5GB memory).

As I remember it, WDS 2 it only ran when you were not using the computer at all. WDS 3 runs all the time even though the Indexing status window says "Indexing speed is reduced while you use your computer". There really should be more settings when you want WDS to run.

Big plus for WDS 3 though: It works! :-) At least this far. WDS 2 did not (see previous posts).

3) I cannot Copy and Paste files to/from Remote Desktop (RDC) when I'm running Vista
Copy and Paste of text works fine. My remote server is running Windows 2003. My guess is this has to do with some new fancy security setting in Vista but I have not yet found a solution. Any tips are greatly appreciated.
[Update: I got it working, and I think this is actually the way it works in XP too: You need to share a drive to make drag/drop or copy/paste of files work. When you start Remote Desktop, before you connect, click Options - Local Resources - More and then check Drives.]

Labels: , ,

Sunday, March 25, 2007

Summer time is here! But not for Kiss...

Summer time is here. At least for your clock.
Up north in Stockholm, Sweden where I live, there will be at least two more months before summer. We have had a very short winter this year and the last snow melted away a couple of weeks ago. Today the sun came out and it's about 10 degrees celcius - if not summer then at least spring is here!

But no summer time for Kiss DP-558, my favourite piece of hitech equipment ;-)
You have to manually go into setup and change time zone from CET to CEST. New this time however (maybe thanks to firmware 1.1.7?) is that I don't have to reschedule any recordings, they change automatically.

Labels:

Sunday, March 04, 2007

BC30456: InitializeCulture is not a member of xxx

Lately I've been getting this error on one of my ASP.NET 2.0 web sites: BC30456: 'InitializeCulture' is not a member of xxx

I've been getting it intermittently, ie. sometimes the page works fine and sometimes all I get is this error. I've been troubleshooting it for awhile but it finally looks like I have gotten a grip on it, much thanks to this MSDN thread.

This is what worked for me:
  • Deleted a "Backup" folder that I kept in Visual Studio (but never copied to my production Web Server). In the Backup folder I kept copies if various apsx pages. Apparently you should not have multiple aspx pages referencing the same code file.
  • Deleted the Bin folder on the Web Server before copying a new precompiled version there. Turned out I had lots of outdated bin files on the Web Server.

I have not yet installed Visual Studio 2005 SP1 (Service Pack) maybe this is something that is also solved there.

Labels:

Friday, February 23, 2007

Regedit - Cannot create value: Error writing to the registry.

I guess this is your typical newbie mistake on Windows Vista, but even so I had a hard time finding the solution on Google so I thought I'd post about it.


When I was trying to add a key in the Registry Editor, regedit.exe, I got an error message saying "Cannot create value: Error writing to the registry."
I have never seen this on XP (but then again I don't edit the registry that often), but since this is Vista with UAC (User Account Control) I thought it might have to do with permissions so I tried to run regedit.exe as Administrator but to no avail.



Finally I figured out that I did not have the right permissions in the registry tree.
The solution is simply to right click on the folder and select Permissions. You may not even have the right to change the permissions, if this is the case then first you have to take ownership - click Advanced and then the Owner tab.


Funny thing about my folder is that the owner was a group called "TrustedInstaller". After I had taken ownership, I wanted to change it back to the "TrustedInstaller" group but it was nowhere to be found. Apparently you can't change it back - it is not a group but a service and part of Windows Resource Protection (WRP) as noted by Richard Civil and others in this TechNet post.


Two other useful newbie things I found out - thanks to this post by Tim Sneath of Microsoft - when trying to figure out how to run a regedit.exe as Administrator in Vista was this:

  1. Run from the XP Start menu is now replaced with Start Search bar in Vista. Simply type regedit.exe (or cmd.exe etc.) in the search bar and hit Enter and it will run.
  2. To run an application with Administrator privileges using this method, instead of hitting Enter you hit Ctrl+Shift+Enter.

Labels:

Thursday, February 15, 2007

Newsletter Unsubscribe and Delivery Failure in Outlook

I have a web site from which I weekly send out newsletters to 15-20.000 members. The sending of the newsletters is fully automated but I use two VBscript Macros in Outlook to handle Delivery Failures (eg. User Unknown, Domain not Found, Mailbox Full) and the manual Unsubscribe Requests I get. I know I can buy or subscribe to tools that automate this for me but I find it easy enough to handle it manually in Outlook using these two Macros. Nothing fancy or hitech but maybe it helps someone else out.

The Macros are written in VBscript and used in Outlook 2003. I have not yet tested them in Outlook 2007 but I expect they will work there too. (I have just installed a new computer with Windows Vista and Office 2007 but have not yet had the time to move everything there)

How I use the Macros:
  1. Newsletters are automatically sent to members
  2. Delivery Failures and Unsubscribe emails land in my Outlook Inbox and I move them to a Errors and Unsubscribe folder respectively (I could/should create an inbox rule that based on recipient automatically move them to the correct folder)
  3. I run the Macros to extract email addresses
  4. I paste the extracted email addresses into a admin page that I have created for my site that remove them from the database, send a confirmation email etc.
Script 1 - GetEmailSender:
Extracts email sender. Runs on all mailitems in current folder that are unread. This is the Macro I run on Unsubscribe emails.
[Update: Download this macro as a text file here.]

Script 2 - GetEmailFromBody:
Extracts first found email address from body. Runs on all items in current folder. This is the Macro I run on Delivery Failure emails.
[Update: Download this macro as a text file here.]


(To add the Macros in Outlook: Copy code from below, goto to Tools - Macros - Visual Basic Editor - and paste the code there)

Sub GetEmailSender()

' ------------------------------------------------
' --- You may use and/or change this code freely
' --- provided you keep this message
' ---
' --- Description:
' --- Extracts email sender
' --- Runs on all mailitems in current folder that
' --- are unread
' ---
' --- By Max Flodén 2006 - http://www.tjitjing.com
' ------------------------------------------------

Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace

Dim mySelection As Selection

Dim myItem As Object
Dim myMailItemLog As Outlook.MailItem

Dim myFolder As Outlook.MAPIFolder

Dim strContactFolderName As String 'Directly under Public Folders\All Public Folders
Dim strNewsletterCategoryName As String
Dim strMailItemSender As String
Dim strMailTo As String
Dim intMessageCount As Integer
Dim bolDebug As Boolean 'If true error messages will be shown
Dim strTemp As String

Set myNameSpace = myOlApp.GetNamespace("MAPI")

'Debug settings
bolDebug = True

'Ask to continue - start warning
intRes = MsgBox("This macro will go thru all items in folder." & vbCrLf & "Would like to continue?", vbYesNo + vbQuestion, "Get Email Sender")
If Not intRes = vbYes Then Exit Sub

'Create a new email to use as log file
Set myMailItemLog = myOlApp.CreateItem(olMailItem)
myMailItemLog.Recipients.Add (myNameSpace.CurrentUser)
myMailItemLog.Subject = "Email from Body - " & Now()
myMailItemLog.BodyFormat = olFormatPlain
myMailItemLog.Body = Now() & " Starting..." & vbCrLf & vbCrLf

'Go thru all items in folder
intMessageCount = 0
intMsgCount_Error = 0
For Each myItem In myOlApp.ActiveExplorer.CurrentFolder.Items

If Not TypeName(myItem) = "MailItem" Then
'Errorlog
If bolDebug Then myMailItemLog.Body = myMailItemLog.Body & "ERROR - MESSAGE TYPE IS NOT MAILITEM." & vbCrLf
myItem.UnRead = True
intMsgCount_Error = intMsgCount_Error + 1
ElseIf myItem.UnRead Then
myMailItemLog.Body = myMailItemLog.Body & myItem.SenderEmailAddress & vbCrLf
myItem.UnRead = False
myItem.FlagStatus = olFlagMarked
intMessageCount = intMessageCount + 1
End If

Next

'Done - write to log and show done message
myMailItemLog.Body = myMailItemLog.Body & vbCrLf & Now() & " Done. Email addresses extracted: " & intMessageCount & ". Email addresses NOT extracted: " & intMsgCount_Error & "."
myMailItemLog.Display
MsgBox Now() & " Done. Email addresses extracted: " & intMessageCount & ". Email addresses NOT extracted: " & intMsgCount_Error & ".", vbInformation, "Done"

End Sub



Sub GetEmailFromBody()

' ------------------------------------------------
' --- You may use and/or change this code freely
' --- provided you keep this message
' ---
' --- Description:
' --- Extracts first found email address from body
' --- (used to extract email address from
' --- error messages/returned email)
' --- Runs on all items in current folder
' ---
' --- By Max Flodén 2006 - http://www.tjitjing.com
' ------------------------------------------------

Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim mySelection As Selection
Dim myItem As Object
Dim myMailItemLog As Outlook.MailItem
Dim myFolder As Outlook.MAPIFolder

Dim strContactFolderName As String 'Directly under Public Folders\All Public Folders
Dim strNewsletterCategoryName As String
Dim strMailItemSender As String
Dim strMailTo As String
Dim intMessageCount As Integer
Dim bolDebug As Boolean 'If true no emails will be sent
Dim bolOnly550 As Boolean 'Only extract email addresses that are 'user not found' (#550) etc.
Dim strTemp As String

Set myNameSpace = myOlApp.GetNamespace("MAPI")

'Debug settings
bolDebug = True

'Ask to continue - start warning
intRes = MsgBox("This macro will go thru all items in folder." & vbCrLf & "Would like to extract only addresses that have 'user not found'?", vbYesNoCancel + vbQuestion, "Get Email from Body")
If intRes = vbCancel Then
Exit Sub
ElseIf intRes = vbYes Then
bolOnly550 = True
Else
bolOnly550 = False
End If

'Create a new email to use as log file
Set myMailItemLog = myOlApp.CreateItem(olMailItem)
myMailItemLog.Recipients.Add (myNameSpace.CurrentUser)
myMailItemLog.Subject = "Email from Body - " & Now()
myMailItemLog.BodyFormat = olFormatPlain
myMailItemLog.Body = Now() & " Starting..." & vbCrLf & vbCrLf

'Go thru all items in folder
intMessageCount = 0
intMsgCount_Error = 0
For Each myItem In myOlApp.ActiveExplorer.CurrentFolder.Items

If Not TypeName(myItem) = "ReportItem" And Not TypeName(myItem) = "MailItem" Then
'Errorlog
If bolDebug Then myMailItemLog.Body = myMailItemLog.Body & "ERROR - MESSAGE TYPE IS NOT REPORTITEM OR MAILITEM." & vbCrLf
myItem.UnRead = True
intMsgCount_Error = intMsgCount_Error + 1
Else

'Check type is 550 - user not found/inactive etc
If bolOnly550 And _
(InStr(myItem.Body, "550") = 0) And _
(InStr(myItem.Body, "554") = 0) And _
(InStr(myItem.Body, "unknown user") = 0) And _
(InStr(myItem.Body, "user unknown") = 0) And _
(InStr(myItem.Body, "no mailbox here by that name") = 0) And _
(InStr(myItem.Body, "no such user") = 0) And _
(InStr(myItem.Body, "bad address") = 0) And _
(InStr(myItem.Body, "Host or domain name not found") = 0) And _
(InStr(myItem.Body, "e-mail account does not exist") = 0) Then
If bolDebug Then myMailItemLog.Body = myMailItemLog.Body & "ERROR - NOT 550 OR Host or domain name not found MESSAGE." & vbCrLf
myItem.UnRead = True
intMsgCount_Error = intMsgCount_Error + 1
Else

'Extract email address from body
intPos = InStr(myItem.Body, "@")
If intPos = 0 Then
'No email address found
If bolDebug Then myMailItemLog.Body = myMailItemLog.Body & "ERROR - NO EMAIL ADDRESS FOUND IN MESSAGE." & vbCrLf
myItem.UnRead = True
intMsgCount_Error = intMsgCount_Error + 1
Else
'Get right of @
intPos_Space = InStr(intPos, myItem.Body, " ")
intPos_Bracket = InStr(intPos, myItem.Body, ">")
If (intPos_Space < intpos_bracket =" 0)" intpos_temp =" intPos_Space" intpos_temp =" intPos_Bracket" strtemp =" Left(myItem.Body," intpos_space =" InStrRev(strTemp," intpos_bracket =" InStrRev(strTemp,"> intPos_Bracket) Or (intPos_Bracket = 0) Then
intPos_Temp = intPos_Space
Else
intPos_Temp = intPos_Bracket
End If
strTemp = Mid(strTemp, intPos_Temp + 1)
'Write to log
myMailItemLog.Body = myMailItemLog.Body & strTemp & vbCrLf
myItem.UnRead = False
intMessageCount = intMessageCount + 1
End If
End If
End If

Next

'Done - write to log and show done message
myMailItemLog.Body = myMailItemLog.Body & vbCrLf & Now() & " Done. Email addresses extracted: " & intMessageCount & ". Email addresses NOT extracted: " & intMsgCount_Error & "."
myMailItemLog.Display
MsgBox Now() & " Done. Email addresses extracted: " & intMessageCount & ". Email addresses NOT extracted: " & intMsgCount_Error & ".", vbInformation, "Done"

End Sub

Labels:

Monday, February 12, 2007

Google Wildcards and Personalized Search

After setting my own personal blog posting record in October I have been silent for a few months... ;-)

Just stumbled across this today - it has probably always been there and most of you probably already know about it, but I thought I'd mention it anyway. You can use wildcards in Google, for example search for "IBM acquired * in 1995" on Google.

This is just another typical example of how you (ie. me) think you know a product and are "happy enough" with it to stop learning more about it. (More in the Google Help Search Basics...)

Speaking of Google I read in one of their offficial blog posts that they will now provide personalized search results when you are logged in:

Keep in mind that personalization is subtle—at first you may not notice any difference. But over time, as the search engine learns your preferences, you'll see it. For example, I (Sep) am an avid Miami Dolphins fan (no joke). Searching for [dolphins] gives me info about my favorite football team, while a marine biologist colleague gets more information about her salt-water friends.

This sounds great to me, but of course it again raises important questions on privacy - I'm not too sure that I want all searches I'm making stored somewhere, available to who knows who.
Living in a pretty well developed democracy I'm not too worried about government finding out stuff about me but it's not hard to imagine that a country like China can leagally force Google to give out information about its citizens. And it's not too hard to imagine a future bug that by mistake will give the whole world access to your searches if they now your email address (that you use to logon to Google) - all of a sudden your employer knows that you're looking for a new job, your wife that you been searching for xxx, etc...
Not to mention all the new work this will bring to all SEOs (Search Engine Optimizers) out there ;-)

Labels:

Friday, October 27, 2006

Things I miss from Notes in Outlook + Desktop Search for Lotus Notes released

I used Lotus Notes as email client for many years, starting with Notes R2 up to R6, and for the last 3 years I've been using Outlook 2003. Both have their pro's and con's. When I started using Outlook I loved the UI and the Office integration. But there are (at least) two things I miss from Notes:

1) The All view
This is the view where you see ALL your emails - recieved, sent, drafts. With this view you don't really need your inbox, sent folder etc (though Notes have these too).
What I miss is for example when you email someone back and forth, you want to delete everything but the last email since you already keep the email history in each email. With Outlook you have to switch between the inbox and the sent folder. Of course you can't bother to do so, so your sent folder gets full of thousands and thousands of useless emails that should have been deleted.
You can probably build this view yourself in Outlook, I did give it a quick try a year or two ago but failed. If you know how to do this please let me know...!

2) Full-text indexing
This is my all time favourite, Notes have had this ever since I started using it in R2 (at least I think so). Anyone who uses Google Desktop or Microsoft Windows Desktop Search (WDS) knows what I'm talking about. No more looking through folders and scroll thousands of emails in search for that email about that thing from that guy who's name you can't really remember...
The big difference is that Notes full text indexing works and is superfast. I don't know what's wrong with Google Desktop and Desktop Search but it just does not index all my email no matter how I rebuild indexes, reinstall and follow various other tips and tricks found on the net.
For exampel if I search for any email containing the word "logo" (of which I have many) Desktop Search just keeps telling me "Nothing found in All locations for query "logo". While other searches seems to be working fine. It's just unreliable which Notes full text search never was.

I haven't looked that much at Office 2007 yet so maybe these things will be solved there (but somehow I doubt that). The thing about Office 2007 that I personally look forward to the most is the improved use of tasks in Outlook 2007, where tasks will show up on your daily calendar. If they just fix tasks in Windows Mobile Smartphone edition everything will be great ;-) (as blogged about elsewhere...)

Windows Desktop Search Add-in for Lotus Notes
Speaking of full text indexing I just saw that Microsoft released a Lotus Notes add-in for Desktop Search. It should work for Notes R5 and up but only seems to index selected Notes databases:

The Windows Desktop Search Add-in for Lotus Notes is a protocol handler that allows you to index the conent of Lotus Notes email, contacts, calendar items, and journal items stored on your computer.


Ps: Three blog posts in two days! This is a new record for me :-)
I was going to write about my wife's brand new Sony Ericsson Z610 which seems to be a great phone but we can't figure out what some of the icons on the screen mean and the manual does not have a single page explaining what is going on on the screen(!) Also the external screen does not show when a new text/SMS message has arrived for more than a few seconds. After that you have to open the phone to check the internal screen to see if there were any messages while you were gone. Or maybe it's just a setting but I cannot find it... Well, that will have to be in another post.

Labels: ,