Wednesday, May 25, 2011

SSIS Package error handling

Sometimes when you running a SSIS package with hundreds of dataflow tasks you simply don't want to have frustrations of one error at pre-validation ruins the whole package, as it might just be a tiny error but cost you hours of debugging and more importantly, may even slow down the business process.

Recently I've come across similar problems with one of my packages, and i digged a little which I found a few approaches that could cater such issue.

Approach 1: my case, I have dozens of dataflow tasks running parallel and I want to allow some file changes and format changes to cause error but package still runs and I could get back to the error later on after I receive the error Email I set for each individual task.

To do this is really simple, just change the main control flow's property "maximumerrorcount" to whatever size you like but 1. If you wish, you can also set individual dataflow task's max error count number as well. but all these must based on that you have a very good understanding of what your package is doing and what sort of error you're expecting. If you're not sure of the errors, then you should also add some error handling in event handlers' of tasks.

Approach 2: A more sophisticated solution for this kind of issue is to write a script task to do the file validations yourself before the package does, and set variables whether the following child task should run or not based on your script task result. here's a link of showing an example: http://dichotic.wordpress.com/2006/11/01/ssis-test-for-data-files-existence/

Personally I found first one is really simple, but as I'm aware of, if error handling isn't good enough you might end up spending more time when weird error occurs.

Thursday, May 19, 2011

“Cannot generate SSPI context” error message

I ran into this problem when i'm doing testings on my local machine, after a little bit search i found out the actual problem was I set my local time to 2 months ago and there has been a mismatch of time clock between server and client, therefore this error pop up.
so after changing my local time back to current time, it's all good again.

Wednesday, May 11, 2011

Outlook blocked access to the following potentially unsafe attachments

Sometimes you may receive this message when receiving email from others with a file attached it.
To deal with it if changing security settings of your exchange server admin isn't an option, there are a few steps to get rid of this message:


  1. Exit Outlook if it is running.
  2. Click Start, and then click Run. Copy and paste (or type) the following command in theOpen box, and then press ENTER:
    regedit
  3. Verify that the following registry key for your version of Outlook exists. 
    Microsoft Office Outlook 2010
    HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Security
    Microsoft Office Outlook 2007
    HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Security
    Microsoft Office Outlook 2003
    HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Security
    Microsoft Outlook 2002
    HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Outlook\Security
    Microsoft Outlook 2000
    HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Outlook\Security
    If the registry key exists, go to step 5.

    If the registry key does not exist, follow these steps to create it:
    1. Locate, and then click the following registry key:
      HKEY_CURRENT_USER\Software\Microsoft
    2. Under Edit, click New, and then click Key.
    3. Type Office, and then press ENTER.
    4. Under Edit, click New, and then click Key.
    5. For Outlook 2010, type 14.0, and then press ENTER. 
      For Outlook 2007, type 12.0, and then press ENTER. 
      For Outlook 2003, type 11.0, and then press ENTER. 
      For Outlook 2002, type 10.0, and then press ENTER. 
      For Outlook 2000, type 9.0, and then press ENTER.
    6. Under Edit, click New, and then click Key.
    7. Type Outlook, and then press ENTER.
    8. Under Edit, click New, and then click Key.
    9. Type Security, and then press ENTER.
  4. Under Edit, click New, and then click String Value.
  5. Copy and paste (or type) the following name for the new value:
    Level1Remove
  6. Press ENTER.
  7. Right-click the new string value name, and then click Modify.
  8. Type the file name extension of the file type that you want to open in Outlook. For example:
    .exe
    To specify multiple file types, use the following format:
    .exe;.com
  9. Click OK.
  10. Exit Registry Editor.
  11. Restart your computer.
the source link for this solution is :http://support.microsoft.com/kb/829982

Thursday, May 5, 2011

Searching through a datagridview control in Visual Studio

There are lots of ways of searching a datagridview in VB. Depending on different situations you might want to choose the one that most suitable to your situation.
Today I was asked by someone how to do a search if he doesn't have a databinding(hence, can't search in bindingsource), meanwhile, he also knows that which column his searching target will be, which makes it quite easy. heres the code:


        For i As Integer = 0 To Datagridview1.RowCount - 1
        'Cell(2) here is the column our results located
            If Datagridview1.Rows(i).Cells(2).Value.ToString.Contains("Cake") Then
                Datagridview1.Rows(i).Selected = True           'Move Cursor to this row
            End If
        Next

If you want to search an entire datagridview without knowing which column, a nested for loop will solve this quite handy as well:

        For i As Integer = 0 To Datagridview1.RowCount - 1
            For k As Integer = 0 To dgvAccural.ColumnCount - 1
                If Datagridview1.Rows(i).Cells(k).Value.ToString.Contains("Cake") Then
                    Datagridview1.Rows(i).Selected = True       'Move Cursor to this row
                End If
            Next
        Next

Above solutions are handy for small recordsets, if you have a very large recordset, it is still recommended to use search in bindingsource, or use LINQ to search through your list