Monthly Archives: November 2014

you have choosen to open php file

I started having his problem with my local virtual host site in XAMPP. Every time I go to php file, it ask me to download the file. I search for solution online, some suggested add module to httpd.conf in xampp but that was of no help.

Turn out it was the .htaccess file. While updating my local directory from remote, I over wrote my local htaccess file and I started getting this error. Firefox would display prompt, do you want to download the php file. Safari on Mac would download the file automatically. After I restored the original .htaccess, the problem is resolved.

Note: If your other site is working but one site is not working, this is most likely the root cause of the problem. Other suggestions are use http://yoursite.test, which may solve the problem as well some user reported.

Decimal value is automatically rounded off in Stimulsoft Fixed

stimulsoft automatic rounding

stimulsoft automatic rounding

I had a database field Qty which which was showing as integer in Stimulsoft MRT report but the value was actually of type double (decimal value). I played with formatting and added two decimal places to the number by right clicking the field and selecting “Text Format”. That added decimals but now the numbers were showing as 2.00, 5.00 etc. For example, 1.35 would be showing as 1.00 and 3.6 would be showing as 4.00. It turned out that I needed to change the data type in Stimulsoft SQL query.

To fix it, right click on the database field in the right side and select edit. This should popup the dialog above. Notice that the value here was int and hence rounding to x.00. Change this to decimal and the problem should be fixed. It is important that double value here may not work (may not show actually decimal numbers)!

Repro Steps

This problem actually started because the original SQL query was pulling Qty as integer which was later changed to double. After changing the field type, it needed to be updated in Stimulsoft report as well.

Here are some related links that I got some help from

How to create voucher numbers in SQL?

This is a short tutorial on creating voucher numbers in SQL Server. I took most of the help from this so article but made my own changes. This can be very handy script if you are working in a financial software where you need to generate voucher numbers or sequence numbers per day.

Voucher numbers are typical numbers sequences based on department from start to end of financial year.Typical examples can be SAL/001, CST/001 etc.

The following code creates a function (needs to be created first) which is then used by the table. Every time a new entry is made in the table, the function is called which generates a voucher number. In this case, the voucher number is simply a sequence number which is generated on daily basis. For example, on a new day, first voucher is always starts with 1 and then goes.

use regular expression for advance editing

You have a loooooong select box, you want to change value field for each option and want to make it same as the option value. You can use regular expression to make the changes rather than edit every single line.


What you want is make the value, same as the text of option. Use the following regex. Basically you will be using groups to reference the two values and you will be reconstructing the matched string using the group values.

Regex Find (pattern) :([0-9]*)”>([A-Za-z ]*)
In replace (type this): $2″>$2

End Result

The first group is reference by $1, the second group is references by $2 and so on. Here we are skipping $1 in replace since it contains the numbers only which we do not want to use in replace.

RAISERROR and Exceptions

RAISERROR with severity level below 10 are not catched by ADO framework. To fix it simply raise severity level to 10 or above or you can instead use THROW statement which has severity level of 16 by default and will always be catched by the ADO framework (C#).

RAISERROR('Your Error Message', 'Severity Level', 'State Level')

Set Severity Level to 16
Set State Level to 1

Note that RAISERROR does not stop execution. It is recommend to use THROW statement inst5ead to raise error and stop execution.

Does RAISERROR cause Transaction ROLLBACK