2007/03/28

HOWTO Inserting a file into image column using only Transact-SQL (SQL Server 2005)

CREATE PROC dbo.InsertBlob
  @id int
, @path varchar(255)
AS
  DECLARE @sql nvarchar(MAX)
 
  CREATE TABLE #BlobData(BlobData varbinary(max))
 
  --insert blob into temp table
  SET @sql =
      N'
      INSERT INTO #BlobData
      SELECT BlobData.*
      FROM OPENROWSET
          (BULK ''' + @path + ''',
          SINGLE_BLOB) BlobData'
  EXEC sp_executesql @sql
 
  --update main table with blob data
  UPDATE dbo.SOME_TABLE
  SET SOME_BLOB_FIELD = (SELECT BlobData FROM #BlobData)
  WHERE SOME_TABLE_ID = @id

  DROP TABLE #BlobData
GO
I found it here and I am happy I can finally stop using textcopy.exe tool.

HOWTO Getting 16x16 icons for file types

1. Download this sample.

2. Put a button and a textbox on the form.

3. Use a snippet similar to:
Dim types As String() = txtFileTypes.Text.Split(",")
For i As Integer = 0 To types.GetLength(0) - 1
  Dim im As Image = _
  Me.FileSystemImages.SmallImageList.Images( _
  FileSystemImages.GetTheFileIconIndex("*." & types(i)))
  im.Save(Application.StartupPath & "\" & types(i) & ".bmp", _
  Imaging.ImageFormat.Bmp)
Next
and you have a tool that allows you to retrieve 16x16 icons for different file types.

2007/03/19

Skype may prevent Outlook from closing properly

If you use Skype with the View / View Outlook Contacts option checked, Outlook does not close properly after you hit Alt+F4 or click the Close button. It disappears from the taskbar, but the OUTLOOK.EXE process continues to run and the Outlook icon stays in the system tray.

I think this is because Skype holds some kind of lock on Outlook's address book, but that's only my guess.

Here you can find some other applications that cause similar behaviour.

2007/03/06

A job step seems to hang when executing a console application

An application executed in an Operating System (CmdExec) job step has to be a console application and it cannot ask for any user input.

Even a simple Press any key to continue..., used (when the application is executed by a user, not SQL Server Agent) to prevent the command prompt window from closing before the user can see the results, will keep such a job running forever.

2007/03/02

Clipboard stops working while using remote desktop connection

If the clipboard suddenly stops functioning, when you are connected to a terminal server or other remote computer, you can try to do the following:

1. open Task Manager on the remote machine and kill the rdpclip.exe process;
2. start the rdpclip.exe application again (you can find it in c:\WINDOWS\system32\).