Sunday 28 September 2014

Currency field type in VFP9

VFP9 stores currency data as Int64 (8 bytes). The original value is multiplied by 10,000, then rounded to 0 decimal places, and then stored in a table. For example, 12.4301 is stored as 124301.

Currency field type has 4 fixed decimal places.

Normally this knowledge is irrelevant because the VFP converts numbers to currency and backwards implicitly. Only if you need to access tables on a lower level, you need to know this.

Friday 26 September 2014

WPF DataGridColumnHeader cuts off first underscore character

In my WPF project I populate a data grid from a random source (a table in a database), so the number of columns and the column names vary each time the grid is filled. The column names of a table are used as grid headers. During testing I found that every grid header with underscore characters always has the 1st one cut off. The reason is that WPF uses the underscore character for marking accelerator keys.

If left as is, it will certainly confuse a small number of end-users. The majority of course will not notice, which still cannot excuse the developer from fixing the issue. Declaring it a feature in user manual is even more laughable because nobody ever reads user manuals except for searching a phone number to call and swear at support.

So I need a solution. First I decided to choose a complex path. No, first of course I started to Google. And then the second step, I decided to try either an event handler or to start messing up with DataGridColumnHeader's style and template. The results were as ugly as unsatisfactory.

But then, bingo, came a solution. If this guy, the DataGridColumnHeader, likes to have underscores for breakfast then make sure it has one every time. So now I simply prefix headers with the underscore. The issue is resolved.


FixieBreaky: when purging database records keep the transaction log in mind

The space on a database server was shrinking. That was not a danger level yet, though the trend left no mistakes: in about two month it would be over. A colleague of mine decided to delete a large amount of obsolete records in a database on the server.

Neither he nor anybody else around did not give a second thought about the transaction log growth caused by the deletions. That included me, even though I stepped into same trap a year ago.

Lessons:
Database backup is extremely important.
Heroic actions is not a substitute for planning.
No matter how large and expensive a storage is, one day it'll be filled
No magic software tool is a substitute for planning
Stay alert, whatever comes to you, look into your previous experience
Blaming and punishing is not a substitute for planning

Sunday 3 August 2014

Importing data from DBF files in Excel

In addition to exporting worksheet data to DBF files (see my previous post) the add-in that I'm developing can also import data from DBF files to Excel worksheets.


After selecting a source file, user can adjust import settings.


And preview the data.


Export/Import functions can also be accessed in VBA.



Friday 11 July 2014

Exporting Excel worksheets to DBF files

I am working on development of Excel Add-in that exports data to DBF files. No data provider (ODBC, OLE DB, ADO.NET etc.) is required. Planned release date: August 2014.


  • Supported Excel versions: 2007 to 2013.
  • Supported DBF formats: dBase III Plus (0x03), FoxPro (0x30) (free tables, Memo support is yet to be decided upon). DBase IV support is yet to be decided upon.
  • Data types supported: Character, Logical, Date, DateTime, Numeric, Integer, Double, no Memo support yet.
  • Exports either whole worksheet or a rectangular contiguous range.
  • Automatically skips hidden columns and rows filtered out.
  • Determines the most suitable data type for each exported column. Data types can be manually overridden.
  • Allows to modify output table structure: names, data types, width, decimals; selected columns can be skipped
  • Allows to set code page mark.
  • The setup may request installing run-times for .NET 4.0 and VS2010 Tools for Office.









Useful tools: Remote Desktop Connection Manager

Remote Desktop Connection Manager -- free tool from Microsoft, quite useful if you need to connect to more than one computers remotely. Organizes sessions in compact window, allows storing credentials (though not always a good thing but often a time saver).

Wednesday 2 July 2014

Visual FoxPro Memo file format uses big-endian convention

Contrary to the little-endian convention used across DBF file format, and generally across the Windows, VFP Memo file format uses the big-endian one.

A screen shot below displays the header record of a memo file. The first four bytes define the location of next free block. Bytes 6 to 7 (0x00, 0x40) defines the size of a block -- 64 bytes, VFP default value (SET BLOCKSIZE). Clearly the big-endian convention is used.



In no way this is an obstacle had you decided to parse or modify Memo files, but of course needs to be taken into account.

As I found after completing this post, Visual FoxPro MSDN page states exactly the same: [for offset, length, and size fields in Memo File Structure (.FPT)Integers stored with the most significant byte first.

Thursday 26 June 2014

Using PrivateObject class for unit testing of private methods in .NET

Whether private members should be unit tested or not, I should say that the PrivateObject class serves its purpose nicely.

Useful tools: Kleopatra for file and email encryption

Kleopatra of Gpg4Win for file and email encryption.

Will add some comments later.

Useful tools: Beyond Compare for file and folder comparison

Beyond Compare of Scooter Software for file and folder comparison.

Will add some comments later.

Using SQL Server aliases vs messing with configuration files

For creating SQL Server aliases use either SQL Server Configuration Manager or cliconfg.exe utility. The utility apparently exists on virtually any Windows computer. Safe way would be creating same aliases for 32-bit (System32) and 64-bit environments (SysWow64).

With aliases properly set there is no need to modify connection strings in project's configuration file when switching between different environments, e.g. development and production.