Monday 20 October 2008

Crystal Reports XI Cross Tab Reports - Column Order



In Crystal Reports, with a cross tab report, the column order is important.
However, the label used to describe the column may not be good for sorting on. for example Month Name, we would not want months sorted alphabetically.
The report I am working on now can have dynamic colum names.
This is the answer.

In the query for the report, I return one column for the sort order, and another for the display value.
When setting up the cross tab, select the one for the sort order (e.g. Period) as the column group.
Then on the design/preview page, right click the column header, choose column options\group options.
The following dialog appears:



Choose Options tab on the dialog, this allows to to choose the field that will be used for the header.

Friday 19 September 2008

SSIS Lookup Errors


I was having trouble importing a client spreadsheet and using the lookup component in the data portion of SSIS.

The original data had some bad rows and these were causing the error message:
component failed because error code 0xC020901E occurred

I went into edit for each of the lookup components and cofigured it to ignore errors.
Before the lookup I dropped any FK constraints that might depend on those lookups, and made those foreign key columns nullable. After the data was imported I ran somecleanup code to remove the columns where the lookup failed, reapplied the not null constraint and added the foreign key relationship back in.

This worked for tables where I was doing a single column lookup. But for one that needed three lookups on the way, I got data in with this approach - but it was not good enough quality.
I may have to resort to writting my own importer for this part of the process.

Wednesday 16 July 2008

CSS

Use of CSS to control all layout of web pages is strongly encouraged. Resist using HTML to control any presentation at all. Tables should only be used for tabular data.
To associate a CSS page with a HTML page a LINK should be placed within the header section.
Within Visual Studio, import or add a CSS page to a project, and then drag it into the header.

Example of CSS element:
p
{
font-weight: normal;
font-size: medium;
color: black;
font-family: Verdana;
}

Example of CSS (user defined) Class:

.headerlabel
{
font-weight: bold;
font-size: large;
vertical-align: middle;
color: red;
background-color: black;
text-align: center;
}

Thursday 10 July 2008

ASP.Net Controls

Textbox control
Many of the properties of the text box are self-explanatory.
Here are some of the less intuitive ones.

AccessKey: Allows user to enter the textbox by pressing a defined key combination. This is not considered good design practice.
AutoPostBack: if true, if the user edits the contents, when they leave the control the contents of the textbox are automatically sent back to the server. This is not a recommended property to use.
It is possible to pick up the TextChanged event and respond to the user input.
AutoCompleteType: If the browser supports AutoComplete, this determins which element is used to populate this text box. There is a list of permitted values here. For example, Email, LastName, BusinessPhone. In the properties box their is a drop down list of valid entries next to this property. I tested this, by setting this value to "Email" firefox flagged it as autocompletable and when I clicked Autofill it entered my email address. I should use this feature whereever applicable.
Focus: Set this property in the form load event to determin which control receives the focus once the page has loaded. Useful.

VALIDATION CONTROLS
There are several useful controls for validating user input. A particularly good one is the Regular Expressions Validation control. For example, here is a regex to check that input is a valid email address: ^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$
This one checks UK postcodes: ^[A-Za-z]{1,2}[\d]{1,2}([A-Za-z])?\s?[\d][A-Za-z]{2}$

This was copied from this site which has a number of Regex statements for a variety of purposes. http://regexlib.com/DisplayPatterns.aspx
Another validation control is the requiredfieldvalidator.
This functionality (in ASP.net 3.5) works in IE, Firefox and Opera.
For non-supported browsers check the Page.IsValid property. This will be false if any of the validation checks failed.
There is a range validator to check that values are in a certain range.
With each of the validation controls there is a Text property and an Error property.
The text is what will show in the error validator, the error message is what will display in the error summary if one is included in the page. So the text could be set to something like "Required" and the error message could be "please enter a valid email address".
The error summary has a number of properties, for example it will display errors in a message box in up-level browsers.

I have reached page 172 in the book, which contains an important section on Ajax validation. This is a key goal of what I am trying to achieve.

Wednesday 18 June 2008

ASP/AJAX - Notes

Learning ASP.Net, AJAX and CSS.
There are a number of ways to work with these features in Visual Studio.
For example, with CSS, it is possible to build a sheet by hand in notepad, but it is easier to add a sheet as a new item to a web project.




If you have an existing StyleSheet, it can also be dragged and dropped into the solution.
Elements can be added to the style sheet by hand, but it is easier to right click and choose "Build Style". That brings up this dialog:

You can add styles for Elements - standard HTML parts, or user defined names which need to go into Classes.

ASP.Net has a feature called master pages. If you have design features you want to show on all pages you add them to the master page, then when adding new pages you can select the master page you wish to apply. So you need only attach a style sheet to the master page and you can see the result of all design changes apply to all pages in the site.

Working with Master Pages.
To add a new aspx formto a project that references a master pages, go to Add Existing Item and choose Web Content Form. The next step will give you the oppourtunity to choose the master file to link too.

Friday 13 June 2008

Dotfuscator

Dotfuscator makes compiled .Net applications much harder to reverse compile.
For example, applications such as Reflector.exe, download here, make it possible to browse through the namespaces and classes in a compile .net application.
There is a cut down version of Dotfuscator included with Visual Studio.
However, on trying this with one of our executables it did not manage to output an application but threw up various errors. After Googling I found others that had the same problem had updated to the latest version.

I finally got Dotfuscator to work without a problem after doing the following:
1) Start Dotfuscator from All Programs\Visual Studio 2005\Visual Studio Tools\Dotfuscator and then following the options to Register
2) On registering I was emailed a user name and password that enabled me to log on to Dotfuscator's web site and download the latest community edition of Dotfuscator.
3) I installed this, then started Visual Studio with my project.
4) From the visual studio "Tools" menu I started Dotfuscator.
5) On the build tab I sent the temp and output directories, then clicked the build button. That was all there was to it. The resulting executable was slightly smaller that the original. On running it started throwing up error messages as I navigated around the app. On the rename tab there is an exclude option. By specifying certain parts of the application here, the error messages stopped.

So - careful and thorough testing would be required before releasing code.

Thursday 12 June 2008

Instruction at referenced memory xyzxyz at the memory could not be written.

This error occurred in a friend's PC running Windows XP Service Pack 2.

The error occurred frequently while running different applications and even in the background.


I also received a similar message about the memory could not be read.

There are a number of suggested answers to this problem kicking around the Internet.

I tried disabling DEP. This seemed to stop the "write" error messages but I still get "read" error messages. The system is slow, I have been told that networking does not work and that plug and play does not work I tried plugging in a USB key, and this took ages to install and detect.
I may have to use system restore.

I should test the physical memory first.
Download and write to CD the bootable ISO with Memtest86+ from Memtest.org
1) Try running Dial a fix - down load here
2) It could be a bios problem - check with the Sony website for specific information.

I ran the memory tests and it reported no problems.
I then ran chkdsk /F and it found problems it could not fix. Running this a couple of times before windows started did not help. I also found Event Viewer messages that showed problems accessing the hard drive. I am thinking that the hard drive is to blame and am going to replace it.

Tuesday 10 June 2008

JavaScript

JavaScript is a C based language. It is not strongly typed. It does support object orientation. It is a client side scripting language like VBscript.
The Wikipedia article on JavaScript is here.




METHODS
document.write("Testing");
window.alert("Test Message"); - displays a pop-up window.

Variables
Variables are not stongly typed.
This is an example of declaring them:
var x =0; //Declares variable and sets value to zero.
x="Hello"; //resets the same variable to a string value.
x=true; //Example of assigning a boolean value

FLOW CONTROL
Switch - similar to the case statement in VB.net
If
For.. Next
Loop

ASP.Net AJAX Elements

SERVER CONTROLS
  • ScriptManager - This is required in on all pages that use AJAX. It can also be used project wide, but it is recommended to be on a per page basis. This references Javascript libraries.
  • UpdatePanel - This controls parts of the page that will be updated independently without needing to use PostBack.

AJAX - what it is and other definitions

AJAX stands for Asynchronous Javascript and XML.

It involves several components including:
  1. DOM - Document Object Model. This is on the client side and is modified by JavaScript to dynamically change what the users sees.
  2. XMLHttpRequest - this send and receives data to/from the server in the background. This does not require the page to be reloaded as is the case with the traditional HTML Post method.
  3. XML - or other format, for sending data back to server. It does not have to be XML format.
---------------------------------------------------------------------------------------------
Mashup - Combine output from several sites - using their APIs
JavaScript - the only script supported by all the major browers. IE, Firefox, Opera, Safari. There are cicumstances where it may not be supported, for example, the user may have disabled JavaScript in their brower, or they could be using a mobile phone.

Visual Studio 2005: "Project type is not supported by this installation"

When trying to create new Web/Ajax project in Visual Studio 2005 received error message, "Project type is not supported by this installation ". This occurred even after reboot. I am not aware of anything that may have caused this problem to start occurring but this feature had previously worked.

The first fix I tried worked, which was installing Microsoft Visual Studio 2005 - Update to Support Web Application Projects.
This is available here:

The file name is: VS80-KB915364-X86-ENU.exe
This occurred on my office PC, running Windows XP.