Monthly Archives: May 2012

SQL Server 2005 Instances do not show up in Server 2008 R2

I updated my SQL Server 2005 to SQL Server 2008. Everything worked great.

After a few weaks later, I tried to connect to the db in SQL Server Management Studio after I had restarted the PC and it won’t connect. Fired up SQL Server Configuration Manager and it wont show any single instance of the SQL Servers.

The problem? After I upgraded to SQL Server 2008, I should have started SQL Server Configuration Manager 2008 not 2005. It appears SSCM 2005 does not show 2008 instances after they were converted to 2008.

Format date in Crystal Report

To format date in Crystal Report, the field must be date type. If the field is an integer and you want to convert this into day please see convert int to date in Crystal Report

To format date in Crystal Report, simply click on the field name, right click, format field. Make sure to select “date and time” tab. Select the proper format you want to show in. If the field is not recognized as date by Crystal, “date and time” will not be shown.

Convert Integer to date in Crystal Report

There is no function available to convert integer date into proper date format. The closest that I came across use a crystal field which take integer date and converts it only proper date format.

This topic talks about how to Convert Integer to Date format in Crystal Report. For
how to format date in crystal Report, click on the highlight link

Interview Questions

Q. You have a large file where you want to replace a lot of variable names. Fore example

Jon skeet
Alan Bradley
Micheal Moore

There are 500 entries. You want to remove the last name, how will you you do?

A. I will use regular expressions. Something like this
Find : [space].+
Replace: [empty string]

Q. In question 1 above, lets say you want to insert a dash(-) between first and last name, can yo do it?

A. Yes. It depends one different editors. In textmate I can use
Find: [space].+
Replace: – $0

$0 contains the whole string that was found using regular expression.

Remove anything after space in the same line – Regular Expressions

For example you have an SQL query like this

You want to create variables for each of the field. The first think you want to do is remove anything after the variable name. Use the following regular expression to achieve in in TextMate on Lion OSX.

Freedom is not a good thing

Freedom is not always a good thing

There is a lot of hype that freedom is a good thing. Well this is true, freedom is a good thing, it is not always a good thing and can be a really bad thing.

Imagine if we had the freedom of working from home, will the output be the same? We would save a lot of money on gas and can potentially be very lucrative? The fact it will be disastrous because you gave too much freedom.

Democracy works because of not freedom. There is the goverment who is accountable to judicial system. If they had the freedom to do what ever they want, would it wor? No.

Imagine a student who is free from any homework. He can submit it if he want to and is free if he doesn’t want to. Will he be as good student as the one who is required to submit his assignment? No. Freedom does not work.

Imagine you were free to not take care of your parents? Would that work. Would that be better for you? No. Having duties makes you responsible and makes your life worthy of living.

Living free makes you life unworthy with no goals, no ambitions and pretty much boring as well. Not to mention, you will not achieve much, if you did not have any strong desire to achieve anything.

No connection could be made because the target machine actively refused it

Error: No connection could be made because the target machine actively refused it

Plateform: ASP.NET
Problem: You are trying to send mail from an ASP.NET application and you are getting this error.

Solution: Go into web.config file and remove localhost from mail setting.

Use a proper mail server setting. One solution is here too

If you have a domain, use your domain setting here, even though you application does not has to sit in that domain address. Or use a public email server setting.

Getting Started with Excel VBA

Quick start with Excel VBA

  • Excel VBA is same as classic Visual basic 6. Think of it as Visual Basic optimized for Excel
  • Every VBA are also called Macros inside Excel
  • You can program inside every excel sheet. Infact you can do some Visual Basic programming in every Excel document

First things firts

  • Macros can be a secruity thread inside Excel, therefore they are disabled by default
  • Enable macros in Excel 2007 by going to Excel Option > Marco Setting tab > Select All Macros with Notification
  • While you are in the same options go to first tabl named “Popular”, check the box next to “Show Developers tab in Ribbon”

You should now be all set to write your VBA program.

Write your first VBA program

At this point, lets assume you want to run a VBA program. Go to Developer tab click the 2nd left most icon “Macros”. It will popup a dialog called “Macro” asking for Macro name. You will see that this is empty because no program was written yet. Lets write one first

  1. Fire up Visual Basic by clicking left most icon in Developer ribbon tab called “Visual Basic”
  2. It will bring up a new IDE (Integrated Development Environment) that you probably are not familiar off. Pay attention to the left most column in the top, called Project

Export to Excel does not export headers – Nexant

It can happen in Nexant Revenue manager, if you export a crystal report in Excel Data only, the report headers are not exported. This could be because in Crystal Report the headers and data was not place close togather.

Solution: Put titles in Page Header section. Do not leave any vertical space between the page header section.

Immediately below the page header, place the fields in ‘Details a’ expert. It magically solves the problem. When you export to Excel data only, column names and data both are exported. It is kind of weird and hard to figure it out.

Crystal Report does not get exported in proper format in Nexant Revenue Manager

This can happen, if you export a report in Revenue Manager and when you opee the exported excel file, the fields are not in order, there are blank column left, header missing etc. This could be fixed by the solution above. Something that might help is

  1. Make all fields the same width and height. Select all element go to format menu > same width and height
  2. Do not leave any space between header and detail section.
  3. This hopefully will fix the problem.