Monthly Archives: January 2015

Copy and Past in Visual Studio and Fix IDs

When you copy a big chunk of ASP.NET code the chances are you are going to run int IDs problem. IDs from the new code is wiped as soon as you past them. Here is a solution to fix it.

Copy the chuck of code into clipboard and past into “Sublime Text 2” for example. Use the following RegPater to call all IDs.

Use the following patter in the replace text

Make sure you have select “Regular Expression” (there is a short cut button for it).
Replace everything it finds. And the copy and past the new code. This should fix the problem.

If your code has control validator, use the following regex as a second run to fix that issues

Please note, do not leave – character in ID as Visual Studio will automatically wipe that out.

You can start GUI Applications as Services in Windows

There is an overwhelming answer that you can’t start GUI Applications as Services in Windows 2003 and above but in fact you can. There is a small program that allows this (1MB). Unzip it. It has 32bit and 63 bit version both. This is how to use it

My Example

In my case I have started a GUI Application (developed in C#), that records attendance. What is really happening start the App as Service is the GUI part is not showing/working but the back end application does work. It read data from serial port and can record attendance.

Just something you might find useful!

obi there is no service available after changing password

If you change google password, you might get the message “There is no service avaialble” from obhi talk. The problem is there is no “easy” way to change your password. There is suggestion, the only way you can regconfigure your device is delete the current connection and add a new one again. Here is how to change password without deleting your OBI Device.

How to change password in ObiTalk

1. After you login, go to your obhi dashboard.
2. See your devices. Select the gear icon next to the device that has the trouble (authentication error)
3. On this page, click the link that says “Click Here to replace Google Account”
4. After this select, use a different account (there is where the trick is)
5. Here use your existing email but choose the updated password. It should work!

So you essentialy reconfigured your obhi device without deleting the account.

Some useful links

Stimulsoft Report Multiple Queries with different Parameters

Lets say I have two queries in my stimulsoft (.mrt) report.

In Stimulsoft Report for this to work correct, Query1 which takes 3 arguments must come first than Query2, for the report to work correct. You can move Query (DataSource) up and own by selecting the query first and the click up and own arrow at the top.

How to troubleshoot your Stimulsoft Report

The most common scenario that you will have to troubleshoot is are parameters passed correctly the queries? To do that simply drag all parameters from the queries on to the report area, one in each line and then print the report. See which value is not passed or has incorrect value.

Remove unwanted Columns, data, text from Stimulsoft

It happens that out of a blue a new column appears in the report or some text that is hidden under some control and appears only in the report and not in the design. What I found works in such case is drag the control and while it is being dragged, see what is underneath it. Another thing I found use, is change page size, this give you more area to look at. You might find controls that you can see in your regular pagelayout, once you spot it, remove it and change your layout back to your regular page size. I had a couple of reports that I had to clean this way.

Passing Parameters to MySQL Stored Procedure

MySQL Stored Procedure parameter does not take @ sign. The variables are declared using identifier name (without the @sign). In some editors like PHPMYADMIn, you might declare a variable with @ sign and may not get any error but your code will not work correctly. To fix this issue, simply remove @sign.

This also leads to an interesting scenario. If your parameter name is same as one of your table field, you will have to use alias to different the two. For example

My variable name is ID, but that is also the field inside my student table. To fix the issue, use this syntax


Passing Parameters to SQL Stored Procedure


MySQL IF ELSE Statement

MySQL IF…ELSE statement can only be used inside stored procedure. They will not work in regular scope. The syntax is

If you run the stored procedure by calling  call IfTest();, it should print


Notice that the IF command will not work if you run the if block outside the stored procedure.

General Syntax for IF…THEN…ELSE command is


  1. Make sure you are running if IF…THEN…ELSE block inside stored procedure. It will not work outside stored procedure.
  2. Make sue you are writing ; at the end of each statement
  3. Do not forget the THEN statement
  4. Do no forget the END; and END IF;  statement at the end
  5. It is good practice to create stored procedure using command line.

MySQL – Working with Variables

Variables in MySQL work quite different than how they work in SQL Server. I stumbled upon quite a few things when working with Variables in MySQL. Here is a short overview of it

Declare Variables

No need to declare variables using DECLARE statement. Simply use Set followed by @variable_name. You can set the variable in the same line.

Declare Variables inside Stored Procedure

If you want to declare variables inside stored procedure, the syntax is different. It is more like what you would do in SQL Server


  1. In stored procedure you must declare variables using the declare keyword.
  2. Variables declared with DECLARE keywor does not take @ sign. They are simply identifiers.
  3. You can set them using Set = [new value]. In some editors, use set := [new value]
  4. Declare statement must come first after BEGIN keyword in Stored Procedure. All variables must be declared first.
  5. If you are creating stored procedure in PHPMYADMIN default editor (using routines), the syntax might give you error. Instead create stored procedure using command line.

Example Stored Procedure that uses variables