Sunday 26 September 2010

Decompiling VB.Net Applications

I recently had two situations where I needed to decompile vb.net applications. One was for a client who had an application that could not be supported any longer, and need a fix, there other was for a version of something I had written and I no longer had the original code.

I tried a number of tools, including one from Red Gate.
Red Gates was not the easiest to use, and does not recover form design, but it was good value at $59.

To decompile an executable using Red Gate Net Reflector Pro
Once installed open Visual Studio
There is a new main menu item .Net Reflector
1) Choose Debug an Executable
2) Browse to the Exectuable you wish to decombile
3) The executable will start in a sepecial debug mode
4) Choose .Net Reflector\Choose Assemblies to Debug (a screen like the one below will appear)




5) A list will appear in Visual Studio of available decompiled assemblies


6) Right click on a item and choose Go to Decompiled Definition

Others I tried included
http://www.decompiler-vb.net/register.aspx

Friday 24 September 2010

SSIS Packages - SQL Server Agent Jobs, Credentials and Proxies

SSIS Packages and Credentials


One issue with SSIS packages is that they run fine when executed manually, but when scheduled as a SQL Agent job, they do not run, or have problems.


This can be because the SQL Agent runs jobs under its own account by default and may not have the same permissions as the account used when they are created and executed manually.


The answer is to use credentials and proxies to impersonate an account with the correct permissions.


So having tested that the SSIS package works correctly when run manually under a certain account do the following: 



1. SQL server Management Studio. 
Security - Credentials- Create New Credential.
Give it a name. 
Fill identity column with domain\account used to test package successfully.  
Password of that account

2. SQLServerAgent-Proxies
Create a new proxy. 
Give it a name. 
Credential should be the one which you created previously in step 1
In subsystems. Check Sql Server Integration Servive Package.

3. Now when you create a job step, in the Run As box, change it from 'SQL Agent Service account' to the proxy created in Step 2.

Example:


SSIS Package Checkpoints

Sometimes a package will fail part way through, and it can be a problem to execute the whole package again. It is possible to edit the package and execute the individual components, but this may not be desirable if there are many tasks within the package.

SSIS has a feature which allows the package to resume from the point at which it failed, called checkpoints.


To get check points to work there are four steps to take:
The first 3 involve the package properties.
1) Set a checkpoint file name
2) Set checkpoint usage to IfExists
3) Set savecheckpoints to True

Then, for each of the tasks that you would wish to be able to resume from, edit their properties and set Fail Package on Error to true.

The next time the package is run, a checkpoint file is created. If the package completes successfully, the checkpoint file is deleted. However, if there is a failure, the package can be executed again, and it will resume  from the checkpoint.

While the package is being executed, you can see the checkpoint file appear, it is a text file, so it is human readable.

If, one time, you do not wish the package to resume from the checkpoint next time it is run, simply delete the checkpoint file. The next time the SSIS package is run, it will start from the begining.

Thursday 9 September 2010

SSIS Looping Through Files In Folder

A task I have had to do a number of times in SQL Server Integration Services (SSIS) is to cycle through all the files in a folder, and import each of those files. Here is a step by step guide to how I do that.

1) To a SSIS package add a For Each Loop Container
2) Inside the For Each Loop container, add a For Each Sequence container
3) Right-click on an empty space on the package file, and choose Variables
4) Create a string variable to hold your file-name
5) Right-click On the For Each Loop Container, choose Edit, choose Variable Mappings
6) From the drop-down list, select the variable you created to hold the file-name

7)

Additional Notes:
VALIDATION
When the package executes its first task is to validate connections and other elements. If certain files do not exist when the package first executes, this can cause validation errors and the package can fail.
To avoid this, on the connection or task properties set Delay Validation to True.

Another Problem
UNICODE
In a data-flow task, I got the error message "cannot convert between unicode and non-unicode string types."
The solution was to add a data conversion component to the middle of the data flow task.


To set the data conversion component up, select the columns that need transforming in the input columns list. Then in the list below, select Unicode String, or whatever Unicode type is appropriate. Also set an alias for the  column. The alias should be different from the original column name.

Finally, after closing the conversion component, redo the mappings going into the destination so that your new aliases are used, rather than the original unconverted column.

Tuesday 7 September 2010

Wireless Network - Local Access Only

I have a Windows Vista machine, with a wireless network USB key, both the key and the router are by Netgear.

This would occassionaly loose it wireless connection, and report "Local Access Only".
Rebooting the PC did not solve this problem. I tried hard coding the IP address, sub net mask and gateway, but this did not resolve the problem.

Finally it did start again, I carried out these steps:
1) Rebooted the router
2) Disabled the network adapter
3) Rebooted the PC.

Then the network worked fine.

It may be that only steps 2 and 3 are required.

I still have to find out why it stops working after 2 or 3 days.

Building Web Pages with Telerik components

Validation of required fields

To validate required field add a system.requiredfieldvalidator for each component, and set the ControlToValidate property.

RadMenu
  • Number of Visible Rows When Dropping Down - this is controlled from the properties for the menu. In the section default group setting height controls how deep the menu will appear.