Please Note that I have changed address
Go to
Baking Ways / Productive Bytes



Search This Blog

Pages

Tuesday, April 27, 2010

Microsoft.Jet.OLEDB.4.0 provider driver on a 64bit System

Today, I tried to set a connection to an Access 2003 database using ADO.NET  whithin c# 2008 express platform.
After setting the option



Debug -- Exception - Common Language Run Time Excepton - Thrown

This error was thrown

"The Microsoft.Jet.OLEDB.4.0 provider is not registered on the local machine"

After a bit of search, I have realized that the problem was the 32bit OLEDB COM driver that needs to be used in a 32bit process. C# express, by default, on a W64bit system, will compile the project for an x64bit process. To compile for a x86 processor you need:

In visual studio 2008

Tools --> Options --> Projects and Solutions-->General  Check "Show advanced build configurations"

Right click on the Project in the solution explorer folder  - Build - Platform - x86 (the default is Any Cpu)

However c# express does not have this option. You will need to carefully modify the project file using a text or XML editor.

1.    Close the project and/or solution
2.    Select Open File from the File menu
3.    Navigate to the project directory, and highlight the project file
4.    Press the Open button, the project file should open in the XML editor
5.    Locate the first section and add the following line:
x86
6.    Save the project file
7.    Reopen the project and/or solution using Open Project/Solution from the File menu
8.    Continue with development, debugging, and testing


Here you can find the original post by John Wein  which I report here in full for reference

References to 32-bit COM components may not work in VB and C# Applications running on 64-bit platforms

Most existing COM components are only available for 32-bit platforms and will not run in a 64-bit process on a 64-bit platform (although they will run correctly in a 32-bit process on a 64-bit platform). VB and C# applications that reference these 32bit COM components will not run by default on a 64-bit platform because by default the application will launch as a 64-bit process.

The problem appears when a project with one or more COM references is:
1. Migrated to Visual Studio 2005 and executed on 64-bit platforms
-or-
2. Created using Visual Studio 2005 on 64-bit platforms.

In Visual Studio 2005, the VB and C# compilers use the platform target property to determine if the.exe or .dll should run in 32-bit or 64-bit CPU architecture mode. The default setting for this property in Visual Studio 2005 is set to 'AnyCPU', which indicates that the application can run in either 32-bit or 64-bit mode, depending on the host platform. In this situation you may see a message such as "Cannot instantiate class..." when you debug or run these applications.

To resolve this issue
Set the platform target property to 'X86' for your VB or C# projects that have references to COM components.

For C# Projects:
1.    Right click the project in the solution explorer and open 'properties'
2.    Choose the Build tab
3.    Set the Platform Target property to 'X86'

For VB Projects:
1.    Right click the project in the solution explorer and open 'properties'
2.    Choose the Compile tab
3.    Press the Advanced Compile Options... button
4.    Set the Target CPU property to 'X86'

Express Editions:
The VB and C# Express products do not expose the Target property inside the development environment. You will need to carefully modify the project file using a text or XML editor.
1.    Close the project and/or solution
2.    Select Open File from the File menu
3.    Navigate to the project directory, and highlight the project file
4.    Press the Open button, the project file should open in the XML editor
5.    Locate the first section and add the following line:
x86
1.    Save the project file
2.    Reopen the project and/or solution using Open Project/Solution from the File menu
3.    Continue with development, debugging, and testing

Alternatively, if the application is targeted to 64-bit platforms, you can ensure that the COM controls added to the application have 64-bit equivalents on the development and deployment computers.

JohnWein added the following:
Using the above method targets the x86 platform, but it doesn't show the "Configuration:" and "Platform: " boxes on the Properties tabs.  To get this feature, I made a template of one of the projects that shows these boxes.  Now I can target a platform and know what platform I have targeted.

Wednesday, April 21, 2010

Excel Tip of the Day: How to work with Lists

A List is a set of ordered labels. For example the days of the week is an example of list

Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday


Excel has some built-in list:






Let's suppose that you need to list the day of the week in your spreadsheet. Since this is a built-in list, a quick way to achieve this is do to as follow
Just type the fist day in column A as in the figure




Then grab down the handle in the bottom-right corner





This is what you will get. Pretty straightforward isn't it?

The most interesting part is that Excel gives you the options to create custom Lists.
Let see how to do it
In Office 2007 you need to
  • Click the Microsoft Office Button, and then Excel Options.
  • Click Popular, and then under Top options for working with Excel, click Edit Custom Lists.
  • In the Custom lists box, click NEW LIST, and then type the entries in the List entries box, starting with the first entry.
  • Then click OK twice

Once we have build the list, we can use it as if it was a built-in one.
Type Blue in A3, grab down the fill handle and you will have the custom colour list filled in your worksheet




As a side note, if the list is lengthy, you can also import the list from cells.

Sunday, April 18, 2010

Excel Tip of the Day: My favourite shortcuts

In this post I will publish my favourite shortcuts. Shortcuts are overlooked by most users, but I can guarantee you that if you start to learn them you will be as much as 30% faster while using Excel. You will not need to use the mouse anymore, which is very time saving.

Let's get started




These are the most basic ones

Ctrl  +  C                      Copy
Ctrl  +  V                      Paste
Ctrl  +  X                      Cut
Ctrl  +  Z                      Undo
Ctrl  +  R                      Redo

Now let's see some others for copying and pasting

Alt + E + S + V            Copy Values
Alt + E + S + F            Copy  Formulas
Alt + E + S + M           Multiply
Alt + E + S + D            Add
Alt + E + S + E            Transpose



Quick Cell Formatting 

Alt + O + C                 Autofit Column Width
Ctrl + Shift + !             Change Format: two decimal place, thousands separator
Ctrl + Shift + ~            Change Format: General format


Selection ShortCuts


Alt + ;                         Display only visible cells
Shift + Space Bar        Select Rows
Ctrl  + Space Bar        Select Columns
Ctrl  + A                     Select Current Region
Ctrl  + A + A              Select Entire Worksheet
Ctrl  + /                       Select current array formula


While Editing a Formula

Ctrl + A                      Display the formula input box
Ctrl + Shift + A           Print in the formula bar the formula with arguments (not so useful in Excel 2010)

Filtering

Alt + D + F                Dispaly Filter



Grouping
 
Shift + Alt + Righ Arrow     Group
Shift + Alt + Left Arrow      Ungroup



Please feel free to add your most used shortcuts in the comments.

Tuesday, April 13, 2010

Back up software: Allway sync, Syncback pro, Paragon Hard Disk Manager Suite (Part II)

In this post we will have a look at Allway Sync.

This image shows the main screen


Once loaded up in memory, the software takes up 45Mb of RAM.


To set up a job is fairly straighforward
 1) Go to Job - Add a New Job. This will add the "New Job 1" tab
 2) Browse to the left and right sync folder
 3) Left Click on Analyze
 4) Right Click on Synchronize

That's pretty much it.

Clicking on the "Change" button we can define the type of back up we want.

Two-way sync
As an example here we have created a two-way folder sync with propagation of deletions and modifications.



Back-up
This job here instead is similar to a Back up, Files are propageted to the right, with their changes, but no deletion is done



Mirroring
This job set a Mirroring, both deletions and modification are propageted



The sofware has also some versioning capabilties, but they are not great.

To sync 111,440 files it took 2min 02sec and 300Mb of memory, 45Mb for the sofware, 255 for the sync job. Speed wise is a good result, however it takes up a lot of memory too. As an example for 1Mln files we would need 2.33Gb of memory (if we can extrapolate the test result linearly). As you will see in one of my next post Syncback is much better to keep the RAM used low.

The main consequence of this inefficiecy is that it can ran into problem synching several hundreds of thousands files

Another major drawback is that you cannot sync two drives according to their label or serial number, which is a pain when you are using external drives whose letter is assigned by windows each time you plug the drive in a usb port. If windows reassigns a drive letter you need to change the left/right drive path in the Job tab.

Allway sync can also to run the jobs simultaneously, however this creates an ovearheard on the machine and make this feature pretty much useless. I gave it a try once, but had to stop the process.


For these easons I decided that I needed a new sync software and I started to search the web.This is how I end up buying Syncback Pro. As you will see, it sorts out all these drawbacks and gives much more flexibility to the end user.


<< previous

ASCIIMathML formulas test

You will find here some formulas written in MathML


`a = b^2 `

` {(S_(11),...,S_(1n)),(vdots,ddots,vdots),(S_(m1),...,S_(mn))] `



`e^x = 1+x+1/(2!)x^2 + 1/(3!)x^3 + cdots `.

`|x|= {(x , if x ge 0 text(,)),(-x , if x <0.):}`


A `3xx3` matrix,
`((1,2,3),(4,5,6),(7,8,9))`,
and a `2xx1` matrix, or vector, `((1),(0))`.

The outer brackets determine the delimiters e.g.
`|(a,b),(c,d)|=ad-bc`.

A general `m xx n` matrix
`((a_(11), cdots , a_(1n)),(vdots, ddots, vdots),(a_(m1), cdots , a_(mn)))`

Using the quadratic formula, the roots of `x^2-6x+4=0` are

`x = (-6 +- sqrt((-6)^2 - 4 (1)(4)))/(2 xx 1)`

`\ \ = (-6 +- sqrt(36 - 16))/2`

`\ \ =(-6 +- sqrt(20))/2`

`\ \ = -0.8 or 2.2 \ \ \ `to 1 decimal place.

`sum_(k=1)^n k = 1+2+ cdots +n=(n(n+1))/2`



`int_0^1 x^2 dx`


Note how the LaTex parsing has been turned off for this webpage

body {

/*  background:$bgcolor; */ /* old code */
  background:#d0e4fe; /* new code */
  margin:0;
  color:$textcolor;
  font:x-small Georgia Serif;
  font-size/* */:/**/small;
  font-size: /**/small;
  text-align: center;
  }

HTML, CSS, Java script comments

While working on this blog, I have realized that there are at lest three different ways to insert a comment on a HTML web page.

1) HTML comments
<!--This is a comment. Comments are not displayed in the browser-->

The tricky part was to find out how to visualize this comment on the webpage, something that is not supposed to show-up! . The solutions comes down to this table

ResultDescriptionEntity NameEntity Number
non-breaking space&nbsp;&#160;
<less than&lt;&#60;
>greater than&gt;&#62;
&ampersand&amp;&#38;
¢cent&cent;&#162;
£pound&pound;&#163;
¥yen&yen;&#165;
euro&euro;&#8364;
§section&sect;&#167;
©copyright&copy;&#169;
®registered trademark&reg;&#174;

As per above table, the HTML code necessary to show up HTML comments is

&lt;!-- This is a comment. Comments are not displayed in the browser --&gt;

Now the problem is- How do we visualize &lt; ?
In this case we just need to write in the HTML source page:
&amp;lt;



2) CSS comment
    /*  comment here */
3) Java script comment
    // Comment here

Here you can find few examples from my HTML template page

The Jave script is commented becasue is delimited by <!--    -->
Whithin the Jave script code you can find additional comments  //
In the CSS body element, you can find CSS comments /*   */

<-- 

 <script src='http://www.mathjax.org/MathJax/MathJax.js' type='text/javascript'>  //
  //  This script call is what gets MathJax loaded and running
  //
  MathJax.Hub.Config({
    jax: ["input/TeX","output/HTML-CSS"],    // input is TeX and output is HTML-CSS format
    extensions: ["tex2jax.js"],              // use the tex2jax preprocessor
    tex2jax: {
//    inlineMath: [['$','$'],['\\(','\\)']], // uncomment to use $...$ for inline math
      processEscapes: 1                      // set to 1 to allow \$ to produce a dollar sign
    }
  });


-->

body {

/*  background:$bgcolor; */ /* old code */
  background:#d0e4fe; /* new code */
  margin:0;
  color:$textcolor;
  font:x-small Georgia Serif;
  font-size/* */:/**/small;
  font-size: /**/small;
  text-align: center;
  }

Sunday, April 11, 2010

How to customize blogspot

Thanks to a very good friend of mine, Claudio Corsetti, I managed to make some changes to my blog layout

1) To make the main column wider just do this
#outer-wrapper { width: 1000px;}
#main-wrapper { width: 750px;}
#sidebar-wrapper { width: 220px;}

The main-wrapper width added to the sidebar-wrapper one should always be less than the outer-wrapper width.
I made the out-wrapper width to be 1000px taking in to account that most of the current screen are more than 1000px wide


2) To justify the text of the main wrapper
#main-wrapper {text-align:justify;}

3) If you want to add formulas using images, this setting comes useful, it controls their vertical align

.post img, table.tr-caption-container {
vertical-align: -50%;
}

Note that for this blog I will not be using images for formulas but the MathML standard.

4) To make the main column background-colour different from the main page one, we need to change the css body element

With this instruction I change page background color
body { background: #d0e4fe; }

5) the code here makes the outer-wrapper colour adjustable through the custom Layout web interface
#outer-wrapper { background:$bgcolor;}

 
CSS Excerpt
-----------------------------------------------------------------------------------------------

body {
background:$bgcolor;
background:#d0e4fe;
margin:0;
color:$textcolor;
font:x-small Georgia Serif;
font-size/* */:/**/small;
font-size: /**/small;
text-align: center;
}

#outer-wrapper {

  background:$bgcolor; 
  width: 1000px;
  margin:0 auto;
  padding:10px;
  text-align:$startSide;
  font: $bodyfont;

  }

#main-wrapper {
width: 750px;
float: $startSide;
word-wrap: break-word; /* fix for long text breaking sidebar float in IE */
overflow: hidden; /* fix for long non-text content breaking IE sidebar float */
text-align:justify;
}

#sidebar-wrapper {
width: 220px;
float: $endSide;
word-wrap: break-word; /* fix for long text breaking sidebar float in IE */
overflow: hidden; /* fix for long non-text content breaking IE sidebar float */
}


.post img, table.tr-caption-container {
padding:4px;
border:1px solid $bordercolor;
vertical-align: -50%;
}

Back up software: Allway sync, SyncbackPro, Paragon Hard Disk Manager Suite (Part I)

I have been working with a computer for at least the last 15 years (my first computer was an Intel 286) and since my early use I have always been worried about how to safely store my data
My first back up support was just a small box packed with CDs, each of them carefully labelled to keep record of their content.


Fortunately (or unfortunateley depending of the point of view) in those days there was no digital pictures or .mp3 files, so most files did not have enormous size.
After few years I moved to 100MB Yomega Zip drives, which to be honest did not get much use.

Later DVDs and external USB 2.0 hard drives came out, with the latter quickly ranking among my favourite back up support.

The advantages of this data storage device are
1) direct data access, not sequential (I couldn't put up with tapes, do you remember the lengthy loading time of the Commodor 64!)
2) low $/Mb cost
3) Portable and compatible with most of today's computers (at least if you pick up one with an external USB 2.0 interface)

WHAT KIND OF BACK UP STRATEGY TO USE?
After choosing the type of hardware storage device, the next important choice is to select the correct software
to back them up quickly and reliably.
There are mainly two type of back up needs
1) System disk backup
2) Personal data backup

System Disk Back up
For system disk back up, my favourite choice on Wndows XP is BartPE and DriveImage XML, the latter available as an add-in for BartPE.They are free of charge, just google them for additional information.

Recently, I have bought a new Pc with Windows 7 64bit professional edition installed and I have started to look for new software compatible with this OS.
After few days of search I ended up with this final list

1) BootIt Ng
2) Macrium Reflect
3) Paragon HDM 2010.

Without going into much details (I can do it on request) I found the Paragon HDM 2010 to be the best one.
One of the most impressive features of this sofware is its WinPE Recovery ISO image.
If something goes wrong with your system disk (hard disk failure, virus attack, ...) just put the WinPE disk image provided by Paragon on either a DVD or USB pen drive, boot the system and restore your disk. You can create full back up, incremental and differential images.
The Recovery software is very friendly, and impressively easy to use. It looks like the one installed on your  windows machine, so there is no additional effort to learn it.
Tu summarize these are its main strengths::

  • WinPE recovery CD interface is basically the same as the full version one
  • The recovery image can be put on a bootable CD/DVD or USB Pen drive! (Very new capatily in these days)
  • You can restore images on Hard drives whose size is less than the image been restored. However in this case the recovery process is much slower.
  • Partitions can be created, resized (with no data loss) and formateted with just few clicks
  • All the operations can be performed in simulation mode, so there is no risk of making any mistakes


In addition to that, HDM Suite can also create file based differential and incremental backups, and sector based differential backup (very useful for a system recovery strategy).

Personal data backup

Once we have made a system recovery image, we need to turn our attention to create a full back up of our data. In this contest data is: photos, videos, .doc., .pdf, .xls, power point presentation,... anything that you cannot just download from the web.
The first software I have used to create recovery copies of all my data is Allway sync. In a matter of half an hour  I realized how much quicker my backup strategy could have been if I had used it since the beginning.

My first naive strategy was just to copy and past my files from my internal hard drive to the external storage device (DVD/Hard disk) each time. That was fine at the beginning but as the time went by, the overall amount of data to be saved increased and the process was getting time consuming. I wished I had a software that could just spot the differenced between the recovery copy and the new data on the main drive, and just update the new/changed files. The solution was a synchronization software: Allways sync.
The main draw back of this very simple strategy is that if you delete by mistake a file or you need any old file version, you will not be able to restore it. To be honest in more than ten years I have never had the necessity to restore any old copy or deleted file. We will see later how to sort this issue.

The are different stretegies that can be used to make safe copies of your data
Tu sum up the most important
  • Mirroring
  • Backup
  • Differential backup
  • Incremental Backup
  • versioning

MIRRORING
Mirroring is the exact file copy of the source folders to the destination.
If a file is deleted from the source, it will be deleted in the destination. This is called "propagate deletions"
If a file is modified from the source, it will be copied to the destination. This is called "propagate modifications"
So the mirroring is a file copy with propagation of deletions and modifycations. There is no chance to recover
any old/deleted files.

BACKUP

Backup is a copy with only propagation of modifications. This means that deleted files can be recoverd, but there is no chance to recover old file versions

INCREMENTAL BACKUP
Incremental Backup is based on a initial Full Backup, and a series of additional backups that record on the destination only the changes that have occured since the last incremental backup.
This is how it works

1) Full Backup             source: files a,b,c        destination: files a,b,c
2) Incremental backup source: files a,b,c,d      destination :just add "d"
3) Incremental backup source: files a,b,c,d,e   destination: just add  "e"
4) Incremental backup source: files a',b,c,d,e  destination: just add modificatioins to file a, but you will not loose the initial file that is stored in the Full Back.
5) Incremental backup source: files a', ,c,d,e   destination: do nothing

With this strategy, you can recover both old files and deleted ones. In addition if you set the Incremental Backup to run everyday, you can restore the source on a specific day in the past.
The major advantages are
1)You can restore the source at any specific point in time. This is useful if you have hundreds of files that change every day, and you need to restore the system at a specific point in the past.

The major draw-backs are
2) To restore the files as of today, you need to first restore the initial full back-up and then, one by one all the incremental back-up in strict order.
3) It is more difficult to set up and maintain than differential back up and mirroring.

DIFFERENTIAL BACKUP

Differential Backup is based on a initial Full Backup, and a series of additional backups that record on the destination only the changes that have occurred since the First full backup.
 This is how it works:

1) Full Backup:                 source: files a,b,c       destination: files a,b,c
2) Differential backup       source: files a,b,c,d     destination : just add "d" file
3) Differential backup       source: files a,b,c,d,e  destination: just add  "d" and "e" file
4) Differential backup       source: files a',b,c,d,e destination: just add  "d", "e" and "a'" (the original "a" file is stored in the original full backup)

5) Differential backup     source: files a', ,c,d,e  destination: do nothing

In this case to restore the system to the last state only two files are needed - the original Full back up and the last differential back up. The differential back up requires more space the the incremental one, but less space than the Full backup strategy.

VERSIONING

This is my favourite. Versioning stores one or more copies of any files that has been modified or deleted, keeping in memory the modify/delete date. In addition, the final user has the option to restore a specific version on the source drive.
To be more precise I use the mirroring + versoning approach.

The major advantages are

1)  To restore the system to the current state is very easy. This is because, the current state is the default one, Additional steps needs to be taken only if any versioned file needs to be restored.
2) Easy to set up

The major draw-backs are
2) It it difficult to restore the system at a particular point in time, especially if many files are subject to change.

In my opinion for a domestic user, mirroring + versioning is the favourite choice, because it is very easy to set up and keep it running. If you do not have the need to restore the system as it was in a particular point in the past (and this is unusual for a domestic user) this is the preferred solution.

In the rest of this article we will have a look at Allway sync and SynbackPro.