A property of a custom control is not shown in the Properties pane

If you are creating a custom control and it has a property that is not shown in the Properties pane in Visual Studio IDE, ensure the property is not write-only.

Write-only properties are not shown in the Properties pane.
Read-and-write as well as read-only properties are shown in the Properties pane.


Maximum column name length in SQL Server 2005

I was asked about this problem today and I could find it neither in SQL Server documentation nor online, so I checked it experimentally.

The name
is invalid because it is empty, contains invalid characters, or contains
more than 128 characters.

Maximum allowed column name length in SQL Server 2005 is 128 characters.


As phorku wrote in his comment, the maximum column name length can also be determined by checking properties of the sysname data type:
sysname is a system-supplied user-defined data type that is functionally equivalent to nvarchar(128) and is used to reference database object names


Installing Ubuntu on ASUS A6RP-AP069 notebook

There were three problems that me and my girlfriend encountered while installing Ubuntu 6.10 (Edgy Eft) on ASUS A6RP-AP069 notebook.
  1. Starting the installation
    There was no problem to boot the laptop from the Ubuntu CD, it showed the available option, but after choosing any of them it... froze after a few seconds.
    We tried 3 or 4 different version of Ubuntu and Mandriva. Every time it hung as soon as Using hpet for high-res timesource message showed. (It is worth noticing that Ubuntu 6.10 does not show such information to the user by default, while its older version do.)
    We found the solution here - adding hpet=disable to the kernel parameters worked like a charm.
  2. Connecting to the wireless network
    Ubuntu correctly detected the wireless card. We entered all necessary configuration parameters (SSID, key, etc.), activated the card and... it couldn't connect to the network no matter how many time we re-checked its configuration and restarted it.
    Finally, we found this post. It's really great! We followed the instructions and the WiFi network was up and running in no time.
  3. Enabling sound
    That was the hardest part. Everything looked fine - Ubuntu detected the sound card, Amarok looked like it was playing a song, but... there was no sound. We tried to play files in different formats, we checked the headphones, we found countless posts telling to uncheck some External Amplifier option in KMix, but we found no such option.
    Late at night after a lot of googling I (my girlfriend went to sleep earlier) found this post. Another great post! I recompiled alsa-driver, alsa-lib and alsa-utils packages and the sound problem was gone.
  4. Headphones
  5. WPA

HOWTO: Configure SQL Server 2005 to allow remote connections

I know it doesn't seem a very hard task, but it really took me quite a lot of time to configure a SQL Server 2005 instance running on Windows XP SP2 machine to allow remote connections.

This KB article describes step by step what you have to do to be able to connect remotely to a SQL Server 2005.

In my case, there were two problems:
  1. I disabled SQL Server Browser service (which has to be running if you want to use a named instance),
  2. I didn't know that in Windows Firewall you can create exceptions for particular applications (and not only ports).


Calling an SSIS package from a SQL Server Agent job step

If possible, always use Operating system (CmdExec) SQL Server Agent job step and DTExec.exe utility to call an SSIS package from a SQL Server Agent job step. The gives you much more verbose output information than SSIS Package step and makes troubleshooting much easier.

Just compare this:

Executed as user: DOMAIN1\sqlagent2005.
Microsoft (R) SQL Server Execute Package Utility
Version 9.00.1399.06 for 64-bit
Copyright (C) Microsoft Corp 1984-2005. All rights reserved.
Started: 10:12:30 AM
Error: 2006-10-27 10:12:30.83
Code: 0xC0014060
Source: {9D739ECB-C57C-4A4D-9DFE-80183F7B7002}
Description: Failed to decrypt a package that is encrypted
with a user key. You may not be the user who encrypted this
package, or you are not using the same machine that was
used to save the package.
End Error
Could not load package "C:\Program Files\Microsoft SQL Server
\90\DTS\Packages\Package1\Package1.dtsx" because of error
Description: Failed to remove package protection with error
0x8009000B "Key not valid for use in specified state.". This
occurs in the CPackage::LoadFromXML method.
Source: {9D739ECB-C57C-4A4D-9DFE-80183F7B7002}
Started: 10:12:30 AM
Finished: 10:12:30 AM
Elapsed: 0.438 seconds.
Process Exit Code 5.
The step failed.

and this:

Executed as user: DOMAIN1\Administrator.
The package could not be loaded.
The step failed.


Also, check the comment below for yet another reason that proves the point I am making here.


SSIS Back Up Database task - yet another annoying SQL Server 2005 'feature'

If you are using the Back Up Database tasks in your SSIS packages, you should be aware that every time you click on the Databases drop-down-list-like thing and then you click OK to close it, the folder location in the Folder textbox is automatically set to the default backup location. So if you are using another location to store your backups, you have enter it every time you change or even view the list of backed up databases.


SSIS package configuration files

SSIS package may ignore a configuration file (the dtsConfig file) and use variable values stored in the package (the dtsx file), if the configuration file contains one or more special Polish characters (even if there are used only in comments - <!-- the comments go here -->).

I have no idea when or why it happens, but I have a package that worked fine, then started to behave strangely and then it all came back to normal, when I removed special Polish characters from the comments in the configuration file. The bug is reproducible.


HOWTO: Format nicely an XML document (beautifying XML)

From time to time I have an XML file that needs to be formatted nicely. If the file is small, I usually do it manually.

However, lately I was working with SSIS. I created a package with an XML configuration file. And it came out that Visual Studio 'thinks' it is a great idea to put all content of the file in one line. Well, it is not, but I have already got used to such bugs in SQL Server 2005.

The configuration file was totally unreadable, but I remembered that I had already had such problem in the past. After some searching, I downloaded XMLStarlet (that I had also used last time).

All you have to do to format nicely an XML file is to type:

xml.exe format ugly_formatted.xml > nicely_formatted.xml

Of course, XMLStarlet can do much more.


Remote query timeout

If you are using linked servers and encounter the following error:

OLE DB provider "SQLNCLI" for linked server "SRV_2000" returned message "Query timeout expired".

check your remote query timeout setting.

To do it execute this query:
  sp_configure 'remote query timeout (s)'

or go to:
SQL Server 2000 Enterprise Manager
(if you're lucky enough to still be using SQL Server 2000 Enterprise Manager)

or to:
SQL Server 2005 Management Studio
(if you have to use SQL Server 2005 Management Studio, that failed to accomplish such an easy task - not being worse that Enterprise Manager - I'll rant about this more someday)

It is also worth remembering that if you are executing a remote query in a step of a job and this fails because of the timeout, the step will be written to job's history with status 'Successful':

Executed as user: DOMAIN1\sqlagent2005. OLE DB provider "SQLNCLI" for linked server "SRV_2000" returned message "Query timeout expired".
[SQLSTATE 01000] (Message 7412). The step succeeded.

SQL Server Agent - multiserver administration (MSX/TSX configuration)

The sp_msx_enlist stored procedure adds the current server to the list of target servers available for multiserver operations. Only a SQL Server 2005 server can be enlisted against another SQL Server 2005 server.

That means that you cannot have a configuration with a SQL Server 2005 instance acting as a master server (MSX) and a SQL Server 2000 as a target server (TSX).

If you try to enlist a SQL Server 2000 instance into a SQL Server 2005 master server, you will receive an error like this:

The master server '<SRV_2005>' version 9.00.2047.00 is not compatible with the target server '<SRV_2000>' versions 8.00.2039.

(By the way, there is something wrong with this sentence, isn't it? I mean the word 'versions'.)

Management Studio showing negative values of free space in tempdb database (screenshots)

Data file
Log file


'Dedicated administrator connections are not supported. (ObjectExplorer)' error

Dedicated Administrator Connection (DAC) is a new feature of SQL Server 2005; it is a special diagnostic connection for administrators that can be used to connect to a server when standard connections are not possible.

If you are trying to connect to a server using the DAC with SQL Server Management Studio and you keep getting the following error:

Dedicated administrator connections are not supported. (ObjectExplorer)

it means that you are trying to connect Object Explorer using the DAC.

Object Explorer cannot connect using the DAC; only Query Window can. That means that you cannot press the New Query button; you have to use the Database Engine Query button.


HOWTO: Calculate MD5 checksum in Windows (and other checksums, too)

On Linux that's trivial - there is the md5sum program.

Windows does not come with such a tool, but you can use md5deep package.
md5deep is a cross-platform set of programs to compute MD5, SHA-1, SHA-256 Tiger, or Whirlpool message digests on an arbitrary number of files. The programs run on Windows, Linux, Cygwin, *BSD, OS X, Solaris, and should run on most other platforms. md5deep is similar to the md5sum program found in the GNU Coreutils package (...)


HOWTO: Perform a scheduled shutdown without installing additional software

The easiest way of performing a scheduled shutdown of a Linux computer, that came to my mind, was executing something like this:

  sleep 3600 && poweroff

However, this couldn't work, since root privileges are necessary to run poweroff command. So you have to use:

  sleep 3600 && sudo poweroff

But this will cause the computer to wait for 1 hour (3600 seconds) and then prompt for the root password. And what we are trying to avoid is sitting in front of the computer at that time.

But there is a very simple solution:
  1. Type sudo visudo to edit the /etc/sudoers file.
  2. Add the following line:
    your_username ALL= NOPASSWD: /sbin/poweroff

Now you can execute sudo poweroff without typing the password.


ISNULL, implicit conversion and integer data type



Server: Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value '/' to data type int.

To explain the above one must to remember that:
  1. ISNULL returns the same type as the check expression (that's the 1st parameter),
  2. varchar and char data types can be implicitly converted to int (if you don't know what it means, try executing SELECT 2 + '2'),
  3. SQL Server treats '+' and '-' characters as a number - 0.
So this is what happens - ISNULL tries to return int data type and it converts the replacement value (that's the 2nd parameter); it succeeds in 2 cases, but fails in the 3rd one, because '/' is not a numeric expression.


Linux applications - languages

If a Linux application starts and the interface is translated into some language that you don't want to use (or even worse - it is partly translated, as it was in my case, so names in the menus were a mix of English and Polish words), you can go to:


and delete [application_name].mo file.

Rather a dirty hack, but it works.

You will need root privileges, of course.


Querying a view in another view, column datatypes & a 'String or binary data would be truncated' error

When you query a view (a child view) inside another view (a parent view), always remember to recreate the latter one when you change a datatype of a column in the former one.

An example:

-- a child view

-- a parent view
  FROM dbo.FOO

sp_help BAR
-- column A has a datatype of varchar(1)
-- Column_name  Type       Computed   Length
-- ------------ ---------- ---------- ------- [...]
-- A            varchar    no         1


  SELECT 'aa' AS A

sp_help BAR
-- sp_help still shows that column A has a datatype
-- of varchar(1), although it is now varchar(2) - see
-- the SELECT statement below
-- Column_name  Type       Computed   Length
-- ------------ ---------- ---------- ------- [...]
-- A            varchar    no         1

-- A
-- ----
-- aa

If you now try to run the following query:

  FROM dbo.FOO

it will fail with an String or binary data would be truncated error.


Visual Studio 2003 sets a breakpoint in another file

There is a bug in Visual Studio 2003 that sometimes makes setting a breakpoint in certain files impossible. When you try to set it, the breakpoint is set, but not in the file that you opened - the moment you hit F9, VS jumps to another file and sets the breakpoint there.

I struggled with this problem for quite a long time. I tried using the mouse instead hitting F9, setting the breakpoint on different lines, reopening the file, reloading the project, restarting VS, using another machine. Nothing helped.

Finally, I discovered that I could open a Breakpoints window (Crtl+Alt+B), press New button and create a new Function Breakpoint - a breakpoint of this type was created successfully.

Note that you can copy the full name of a function from the Class View window.


Querying a view takes ages - really weird SQL Server 2005 behaviour

There is a view called VIEW_TITLES. It is quite complicated. Executing a SELECT query against it returns 189 rows.

A query:
  SELECT TOP 200 *
takes 13 seconds to execute.

However, executing an identical, when it comes to the returned rows, query:
takes an indefinite amount of time - I cancelled the execution after 5 minutes.

I have no idea how to explain this behaviour. It looks like a bug in the optimizer to me.

The only workaround I found looks like this:

I know it's a pretty dirty hack, but it works. And it is still better than hard-coding some fixed number in the TOP expression.


Debugging a Windows service

OnPause, OnContinue and OnStop methods can be debugged by simply attaching to the [WindowsServiceName].exe process and setting breakpoints in the appropriate places.

The problem gets a little bit harder when it comes to debugging OnStart method, since there is no process that can be attached to, because the service is not running. There are many ways to solve this problem, but, in my opinion, the easiest one is to
call a System.Diagnostics.Debugger.Launch() method within the OnStart method in order to start a debugger programmatically.

A detailed description of this problem can be found here.


How to format USB flash drive on Linux

You can use mkdosfs command.

For example:
  sudo mkdosfs /dev/sdb1


SSIS package execution fails when you run it from a SQL Server Agent job

I created a SQL Server Integration Services (SSIS) package. It was pretty simple and it worked fine. After testing it, I created a SQL Server job with a single step that was supposed to execute the package.

And it took me two days to make it work. Unfortunately, documentation dealing with this topic is pretty poor.

I was getting different errors - for example:

Executed as user: SOME_DOMAIN\sqlagent2005. The package could not be found.
The step failed.

Unable to start execution of step 1 (reason: Could not get proxy data for
proxy_id = 2). The step failed.

This is a method I found (I am positive that there are other ways to get the same result, too).

1. Create a credential (make sure that the chosen account can execute jobs).

2. Create an SSIS proxy using this credential.

3. Set the proxy in the 'Run as' combo in a job step definition.

4. Grant access to C:\Program Files\Microsoft SQL Server\90\DTS\Packages (or wherever you deployed your SSIS package) to the domain account that you used to create the credential.


Later I found a good article about this problem - An SSIS package does not run when you call the SSIS package from a SQL Server Agent job step.


sp_send_dbmail & blank messages

If you are using sp_send_dbmail stored procedure to send e-mails and the messages you receive are blank, despite the fact that you supplied @body parameter, try switching from TEXT to HTML messages (@body_format parameter).


How to determine if SQL Server 2005 SP1 is installed

If Service Pack 1 has not installed, the SELECT @@VERSION query returns:

 Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86)
  Oct 14 2005 00:33:37
  Copyright (c) 1988-2005 Microsoft Corporation
  Standard Edition on Windows NT 5.1 (Build 2600: Dodatek Service Pack 2)

After installing Service Pack 1, it looks like this:

 Microsoft SQL Server 2005 - 9.00.2047.00 (Intel X86)
  Apr 14 2006 01:12:25
  Copyright (c) 1988-2005 Microsoft Corporation
  Standard Edition on Windows NT 5.1 (Build 2600: Dodatek Service Pack 2)


How to install VMware Tools in VMware Player

After creating a 'new' virtual machine I noticed that I couldn't do a few things that I could do in the other VM (the one that served as a base when creating a 'new' one):
  • I could not move the mouse between the guest system and the host system. Each time I wanted to move from one OS to another, I had to click to grab input and press Crtl+Alt to release it.
  • I could not use the toolbar at the top of the VMware Player without leaving the guest system.
  • I could not use the guest system in fullscreen mode.
  • I could not change the size of the guest system (in a way similar to changing screen resolution) by simply resizing the VMware Player window.
After a short while I realized that the difference between these two virtual machine was the fact that VMware Tools were installed in the old one, but not in the new one.

I installed VMware Tools and it solved all the problems.

This article explains how to install VMware Tools in VWware Player.


How to create a 'new' virtual machine using only VMware Player

Well, not exactly new, hence the quotation marks.

But if you:
  • already have a virtual machine,
  • need a new one with another operating system, but do not need another configuration for this new machine (for example, smaller or bigger HDD),
you can simply:
  • make a copy of the existing virtual machine's folder,
  • run the machine from the new location,
  • put an installation CD of the new operating system and change the booting device to CD-ROM.
Quick and dirty method, but it works - I installed an evaluation copy of Windows Server 2003 this way.

And if you have more time, you may find these articles interesting:
  How-to: VMware player modification
  How to create virtual machines using VMware Player


Visual Studio - Command Window vs. Immediate Window

While debugging in Visual Studio, I often use Command Window to check values of variables (?mySqlStr), assign values to variables (mySqlStr = "SELECT FOO_ID FROM dbo.FOO") or execute short code snippets (myDS.Fill()).

Today I closed Command Window and re-opened it after a while. And I could no longer evaluate any expressions. I also noticed a > prompt that I've never seen before.

It turns out that Command Window has two different modes (clicky):
  • Command mode - used for executing Visual Studio Commands directly in the IDE, bypassing the menu system, or for executing commands that do not appear in any menu,
  • Immediate mode - used for debugging purposes, evaluating expressions, executing statements, printing variable values, and so forth.
Command mode (notice the prompt)

Switching from Command mode to Immediate mode (type immed and press Enter)

Command Window - Immediate mode (no prompt)


Finding orphaned packages

If you are using Debian or any other Debian-based Linux distribution, you can use deborphan tool to find orphaned and/or unneeded packages. Read the man page for the options (--guess-all is very useful).

I have just removed over 100 packages. And my system still works. :)

Could it get any less specific?

This is a description of an error that I've read today (here):
This error is not based on any particular query construct. Also, this error is not limited to any particular database environment, to any particular amount of data, or to any particular kind of data. This error may first occur only sporadically. However, this error may occur repeatedly after the first time it occurs.


How to list all open connections (on Linux)

lsof -i


sudo lsof -i will show all open connections, not limited to current user.


How to encode a DVD to an XviD file (on Linux)

There are of course many ways to do it, but a very simple one is to use:
  • Mencoder for ripping and/or encoding,
  • SimpleRip to generate all the necessary commands.


The OLE DB provider 'SQLOLEDB' was unable to begin a distributed transaction

If you use SQL Server 2000 on a machine that is running Windows Server 2003 and fail to start a transaction against a linked server because of the following error:

Server: Msg 7391, Level 16, State 1, Line 2
The operation could not be performed because the OLE DB provider 'SQLOLEDB' was unable to begin a distributed transaction. OLE/DB provider returned message: New transaction cannot enlist in the specified transaction coordinator.

you should check whether Data Transaction Coordinator (MS DTC) can access the network. By default, the network access settings of MS DTC are disabled on computers that are running Windows Server 2003.

Follow these steps to enable the network access settings of MS DTC. In my opinion though, it is not necessary to reboot the computer for these changes to take effect.


devenv - building a .NET solution from the command line

The easiest way to build a .NET solution (or a project) from the command line is to use devenv command.

However, there are two devenv files - devenv.com and devenv.exe. Today, I have noticed one really essential difference between them. The former one is a console tool, while the latter one is not. If you type devenv.exe to build a solution, it will start a background process and immediately return control to the console. It means that, if devenv.exe is used in a batch file, the commands succeeding it may be executed before the build process completes.


The above happens only when you type something like devenv.exe SomeSolution.sln /Rebuild Release in the command line and hit Enter. It does not happen when such a command is used in a batch file.


How to load subtitles in Kaffeine Player

I finally found how to manually load subtitles in Kaffeine Player.

An appropriate option is available only in the playlist context-menu.

Not very intuitive, in my opinion.


There are too many geeks around, when...

... somebody asks:
And would you pass a Turing test?
and everyone starts to laugh.


Maximum number of tables per SELECT statement

Have you ever wondered whether the number of tables that you can use in a single SELECT statement is limited or not?

Well, I haven't. But there is a limit. And, contrary to many maximum capacities of SQL Server 2000 specified here (like Databases per instance of SQL Server - 32,767, for example), it is possible to reach it.

When you do, you will see the following error:

Could not allocate ancillary table for view or function resolution.
The maximum number of tables in a query (256) was exceeded.


I started a discussion about this problem at StackOverflow.


eMusic & Linux (continued)

This is a follow-up to my previous post about eMusic.

If you don't like console applications (gasp!), you can consider using eMusic/J.


eMusic & Linux

If you use Linux and you want to download music from eMusic, visit http://frumppyoldwoman.com/emusicdlm/ and get decrypt-emp.pl script - you will be able to download entire albums with a single click (using EMP files), but without eMusic Download Manager (there is a Linux version of this application, but its development has been discontinued).

This is my .decryptemprc file, if you're not sure how to create one:

FileMask=%artist/%album/%tracknum %track.mp3