14 December 2011

SQL Performance Tips 5

Hello,

Another SQL Performance tip, which will help you to determine the exact execution time of your sql statements. The simplest way of doing that is to save the time before running your statement and then compare that value with current time. Here is a sample SQL statement:

25 November 2011

ANTS Memory Profiler 7.1 without license

Hi All,

The trial period of 14 days of your ANTS Memory Profiler has passed.

You are now searching for a license for ANTS Memory Profiler?
Or are you searching for a crack for ANTS Memory Profiler?
Or are you searching for a keygen for ANTS Memory Profiler?

No need to do that anymore because there is an easy way to use it without having a license, crack or keygen (Note: the version that I am using is 7.1).

So what to do?

23 November 2011

SQL Performance Tips 4

Hi All,

Again me with some more SQL Performance Tips.

If you have a lot of tables with which you have to join and those tables are big then pay attention to the order of how you join those tables because the order matters.

Why the order of the tables in joins matters?

It is because even if the result of your query returns only a few of records, lets say 7 records, it doesn't mean that it will run fast, and it will not run fast because during the first joins your tables can "return" thousands, millions or even more records with which the SQL Server will be working further.

So the idea is that you have to use the Actual Execution Plan to see what is Estimated Number of Rows with which the SQL Server will be working with.

Try to filter the data using the joins, so that less data remains to be processed, and less time it takes to the SQL Server to return the result to you.

Good luck,
Roman

18 November 2011

SQL Performance Tips 3

Hi All,

Me again with another SQL Performance tip.

Another way to optimize a query is using the Actual Execution Plan.

Well, first of all by using it you will see what indexes are missing, what table or join is causing the performance issue, which join is returning a lot of rows and many more.

It worth learning how to use the Actual Execution Plan.

Now about indexes, you must keep in mind that not all indexes that are suggested to be created by Actual Execution Plan are good to be created, and this is for several reasons:

17 November 2011

SQL Performance Tips 2

Hi All,

Here are some more tips on SQL Performance.

SET NOCOUNT
So what is it useful for?
First of all what is it doing: Stops the message indicating the number of rows affected by a Transact-SQL statement from being returned as part of the results.

Which means that when you do not need the number of rows affected to be returned from the SPROC then write that at the beginning of the SPROC. Why? because it will reduce the traffic and the execution time of your SPROC.

16 November 2011

SQL Performance Tips 1

Hi All,

By working at some performance issues with SQL Stored Procedures, Views and Functions I had to make some investigations on SQL performace, how to do that, I've been searching a lot to find some tips.

So the first tip is: Avoid using CURSORS.

Yes, avoid cursors, do everything to avoid cursors.

Often time people say to me that for their case it is not possible to avoid cursors, and often times I prove them that it is possible.

When there is just a few things that you could do with a set of data then try to do that in some statements by joining the data, instead of going through each item.

It is not always clear that cursors could be avoided, this is why you have to think several times if it is really not possible to avoid them.

Regards,
Roman

27 October 2011

Migrating .wdproj From VS 2008 to VS 2010

Hi All,

Do you want to work under Visual Studio 2010 and your project is currently working under VS 2008?
All you need to do is to to convert your projects into a VS 2010 Version.

However there could be a small problem that we are going to solve: not all projects can be converted, and I am speaking about Web Deployment Projects. In order to make those available for VS 2010 you will need to download and install the "Visual Studio® 2010 Web Deployment Projects - RTW".

Now if you want to migrate your project from a .Net 3.5 to .Net 4.0 then you can face an error like this:
"Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive."

19 October 2011

Visual Studio Memory Profiler resulted into - Blue Screen

Hi everyone,

Have you ever tried to use Visual Studio's Memory Profiler?
I have recently had a need to profile a .Net application and was searching for a memory Profiler tool, and that was the moment when I have found out that Visual Studio 2008 Development Edition has it's own memory Profiler.

I decided to search for a quick guide and have  found several of those on the internet.

Unfortunately when I started my application using that profiler my computer showed me the Blue Screen of Death.

11 October 2011

Invalid Argument, jQuery bgiframe + position + iframe + IE6

Hi all,

Do you have an error when using jQuery bgiframe library together with jQuery UI position and your own frame? An error like: Invalid Argument. Which is actually very odd.

The problem when putting my own iframe behind a element that I want to position somewhere on the page with jQuery UI position function it throws the error. The error is thrown because jQuery UI position is automatically calling the bgiframe function if it exists. Here is the code:

06 October 2011

jQuery dialog height problem

Hi All,

I will describe you a problem that I have experienced with jQuery dialog in IE8 (but I guess that it can be reproduced on other versions of IE too).

The problem appears when you create a draggable dialog and you want to set a height to it, and the problem is that when you drag and drop the dialog multiple times then the dialog height will get smaller.

If you notice such a strange behavior then you need to know that this is because of the height that you have set for the dialog.

When you set the height of the dialog something wrong is happening inside the jQuery library.

How to fix this?

28 September 2011

ASP:RegularExpressionValidator force validation with JavaScript

Hi All,

You often have the situation when you want to force the validation of the ASP:RegularExpressionValidator using JavaScript.
This is usually because for some reason the Validator is not actioned automatically like: the submit button was initially disabled, or the value of the input to validate is changed through JavaScript.
So you can force the validation of the ASP:RegularExpressionValidator using the Page_ClientValidate JavaScript function.

26 September 2011

asp:RegularExpressionValidator not working for initially disabled buttons

Hi all,

I have found an interesting thing or better to say odd behaviour about asp:RegularExpressionValidator and the way it is actioned.

Below I will describe the odd behaviour:
For example you have a form and a field with a RegularExpressionValidator on that field and a asp:Button on that form. So if that button is disabled by default (through asp or in code-behind)  and then it is enabled through JavaScript then you will have a surprise - the RegularExpressionValidator will not be actioned.

The RegularExpressionValidator will work very good when button is disable by default and then is enabled through codebehind.

Conclusion:
Pay attention when disabling/enabling asp buttons through JavaScript.

22 September 2011

Some Relax

Hi all,

There has passed some time since I haven't posted anything, It's because I had some routine work to do and nothing interesting to post, no interesting solutions for the public. Today at work I have received an interesting image which made me laugh. It is about "Reasons why people who work with computers seem to have a lot of spare time". See below the image:

13 July 2011

Linq on DataTable

Hello everybody,

Sometimes we need to easily make a select on a table, and usually most of developers will use loop through the rows of the DataTable and find the row that developer is searching for or the collection of rows.

I came across this problem too, and I was thinking why it isn't possible to use Linq to select those rows?

16 May 2011

Unsafe JavaScript attempt to access frame with URL in Chrome

Hello everybody,

This time I have found an interesting issue with Google Chrome browser.
The problem appears when you try to access the code from within the iframe which source has an url from the same domain.
For example you have two simple html files on your computer (ie page1.html and page2.html), where one of them contains an iframe:

Code:
<iframe src='page2.html' id='myFrame' />

If you try to change  or get something in/from page2.html through javascript you will have an error in Google Chrome. I will give an example with getting the title through javascript from inside page1.html like this:

29 April 2011

Word Mail Merge - How to merge through Javascript

Hello,

Word Mail Merge - How to merge through Javascript?

What I will describe here will work only on Internet Explorer. Because it is using an ActiveXObject which is not available in other browsers other than IE.

I know just one way to make Word Mail Merge to work cross browser and that is to implement this in code behind in C#, you can find an article about that on Microsoft's support page: http://support.microsoft.com/kb/301659.

I will probably also make a C# version of my own, if I have a good solution I will post it on the blog.

Here is a Javascript function that I have written for Javascript Word Mail Merge.
Code:

11 April 2011

SQL - trigger fired when table is not updated

Hi,

First of all what microsoft tells us about triggers:
"A trigger is a special kind of stored procedure that automatically executes when an event occurs in the database server. DML triggers execute when a user tries to modify data through a data manipulation language (DML) event. DML events are INSERT, UPDATE, or DELETE statements on a table or view. These triggers fire when any valid event is fired, regardless of whether or not any table rows are affected."
            Taken from: http://msdn.microsoft.com/en-us/library/ms189799.aspx
There is something interesting in above sentences, I suppose many of us would not understand correctly the last sentence: "These triggers fire when any valid event is fired, regardless of whether or not any table rows are affected". I have also walked through these problems some days before.

31 March 2011

Code 128 C - SQL Function

The Code 128 barcode is a high-density linear symbology that encodes text, numbers, numerous functions and the entire 128 ASCII character set (from ASCII 0 to ASCII 128.) It is commonly used for several implementations; and is also referred to as ISBT-128, GS1-128, UCC-128, EAN-128 and USS Code 128.

Code 128 contains 106 different printed barcode patterns. Each printed barcode may have one of three different meanings depending upon which of the character sets are being used, with the availability of three different Code 128 start characters to program the initial character set. Functions are also provided in the barcode symbology to switch between character sets and encode Application Identifiers. The Code 128 barcode may be complex to use because of the different character sets, which is the primary reason IDAutomation provides the Code 128 auto function, "Code128( )", in several of the Font Tools, Components and Applications.
The complete Code 128 barcode consists of a start character, data digits, a modulo 103 check digit and a stop character.

Many developers are searching a way of how to correctly encode the string using SQL.
I had a need to dispaly a 10 characters long string (containing numbers only) as a barcode, this is why I had first to encode it correctly in Code 128 C format.

29 March 2011

Custom Insert/Update on LinqToSql and ASP.NET Dynamic Data

ASP.NET Dynamic Data brings major usability and RAD development changes to the existing ASP.NET data controls. RAD development is significantly increased by the use of a rich scaffolding framework.

If you want to create a custom insert or update for ASP.NET Dynamic data and LinqToSQL then you will have to perform the following steps:
1) Create a partial class for the entity you want to make the insert/update custom. For example if you had a table name employees then your code would look like this:
[ScaffoldTable(true)]
public partial class Employees
{
}

25 March 2011

Javascript Debugger does not work in IE9

Hi,

As I said previously I had installed Internet Explorer 9 on my computer and I also said you that this was a very BAD idea.

Here is one more reason of why it was a bad idea - my lovely javascript command is not working anymore, I am talking about debugger;

Do you remember in Internet Explorer 7 and 8, am not sure about IE6 (I vague remember, but I think debugger was working in IE6 too), that when you put debugger somewhere in the code IE opens a popup with the message: "An error has occurred. Do you wish to Debug?", or something like that. After what you can press YES and you then can select the application with which you wish to debug your page.

For me the above behavior was something which helped me a lot.

Now with IE9 the problems starts the keyword - debugger - DOES NOT DO ANYTHING.
What is that? Why?

24 March 2011

MS SQL RowID equivalent

Hello everyone,

Many MS SQL developers ask if there is an equivalent to RowID from ORACLE in MS SQL.

The answers is NO.

But there is a workaround. You can use ROW_NUMBER() instead and where you will need to specify based on which columns to generate RowID, the order in which the ROW_NUMBER value is assigned to the rows in a partition.

Here is an example:

SELECT FirstName, LastName, ROW_NUMBER() OVER(ORDER BY SalesYTD DESC) AS 'Row Number', SalesYTD, PostalCode
FROM Sales.vSalesPerson



You can see more details on Microsoft's page about ROW_NUMBER() function: http://msdn.microsoft.com/en-us/library/ms186734.aspx

Simple, isn't it?

21 March 2011

jQuery Dialog BUG in IE6 & Quirks Mode

Hi,

I have found a bug in jQuery dialog - it has strange behavior when dragging and resizing a dialog in IE6 or IE7 and up in Quirks Mode.

The problem is that when resizing or dragging many times then the Dialog:
  • Becomes smaller;
  • The content becomes bigger.
I've been trying a lot to try and fix this, I had a walk-through the jQuery UI code and found out these:
On dragging guys from jQuery performs some strange things:
  • Why do they set the height of the Dialog to it's height? "$(this).height($(this).height())". I would not have had anything against it if that piece of code would not set the height of the Dialog with 5px shorter.
    Yes, I'm serious - 5px shorter, however I could not understand how that is possible because it set's the height to the same height.

17 March 2011

Did you try Internet Explorer 9 ?

Wwwwwooooooowwww, this is what I can tell you about it.

It has a very simple and intuitive interface and it is easy to use. Till now Google Chrome was the best for me (my preference, I can tell that I was a fun), however now I see that Internet Explorer took the right way, and made so that the user have more space to view the page but not Browser's menu, tabs and buttons.

Here is a screenshot of the new Internet Explorer - Version 9.

Click on the image to enlarge:


But hold on, the new interface is not the only thing with which Microsoft is making us happy, the other thing is that this browser's speed will surprise you, it is really fast.

I personally made some tests with a page where I had a lot of Javascript with asynchronous calls to the server, I didn't even needed to use any tool to compare IE 9 with other Browsers like: Chrome, Firefox and Safari. Do you know why? Because you can see that by yourself, without any tool.

09 March 2011

CheckBox "onchange" event fired before "onclick" event in Google Chrome

Hi,

      When working on another Javascript Library I have found another problem or maybe I am wrong and this is expected behavior. The problem is:
           - In Internet Explorer - onchange event is fired after the onclick event;
           - In Google Chrome - onclick event is fired after the onchange event.

      I am not sure about other browsers.

      All this refers to checkbox only, because I didn't try others, but I guess radiobuttons have the same issue.

ASP.NET __doPostBack not working

Hello,

Did it happened so that you try to use __doPostBack javascript function but it didn't work?

 __doPostBack - is a function which makes a postback to the server with an target element ID, and it should also fire the corresponding Event on server-side automatically. This is a very useful function.

Well there are several possible situations that I know where it doesnt work:
1) because you are passing an invalid ID;
2) you should use btnObj.ClientID for ASP.NET controls
3) because you are trying to call __doPostBack for a button that is placed on a page with Master Page or for a button that is inside an ASCX control.

Make HTML elements like DIV, SPAN, Table focusable

Hello,

When you need to detect onkeydown event it is fine to do this with focusable elements like: inputs, dropdowns,..., but what to do with non-focusable elements like DIVs, SPANs, TABLEs?

You can achieve this by adding TABINDEX attribute to these elements, this way browsers will consider that element as a focusable element.

Also depending of what value you set to tabindex attribute - it will behave differently:

ASP.NET Dynamic Data - Default sort Table by specific column(s)

Hello,

      ASP.NET Dynamic Data brings major usability and RAD development changes to the existing ASP.NET data controls. RAD development is significantly increased by the use of a rich scaffolding framework.

      The DetailsView and GridView controls have been extended to display fields by using templates instead of by using hard-coded rules that are programmed in the controls. These templates are part of the project, and you can customize them to change their appearance or to specify which controls they use for rendering. This makes it very easy to make a change in one place in your site that specifies how to present dates for editing, as one example.

      But it is not so flexible as we wanted and it does not allow default sorting on tables.

      Here is a solution of how to make your ASP.NET dynamic data GridView sorted by default. This solution will require you to create an attribute - MySortByAttribute which will contain 2 proprieties: SortExpression (of type: String) and SortDirection (of type: SortDirection).

Height 100% does not work

Height 100% does not work ?

When you put a height for an element inside the page to have 100% of the parent element it does not work?
This is correct.

I have also had this problem and I have found out that this is because when you put 100% it will take 100% of the height of the html document or 100 % of the body.

But in modern browsers html's and body's default height looks to be set to 0 pixels. Which means that their height will be adjusted to the height of inner elements.

So what to do if you want your element to be 100% of the browser window?
ANSWER: make html and body to have height set to 100%, in this case these will take 100% of the window and this way you will be able to set the height for the elements inside html and body needed value in percents.

window.showModalDialog() - Cross Browser, new version

Hello,

This is a continuation, or a new version for my last post about window.showModalDialog().

The new version was implemented as a jQuery function to which you can pass options which you like.
This version was made because:
    1) The impossibility of previous version to retain dialogArguments during postback;
    2) The impossibility of previous version to close the dialog when the target page is inside several iframe tags;
    3) The impossibility of previous version to retain window.returnValue during postback;
    4) It will be possible now to fire a postback of the page or to fire a postback of a element (with targetElementId) right after the dialog was closed and the callback function finished to execute;
    5) Theoretically this popup library can be used to open another popup inside an existing one (Note: I haven't tried this yet).

However, previous version of my showModalDialog can satisfy someone's requirements and it will be no need to complicate his life with the new version.

XML Parsing and other XML Utilities - Cross Browser

Hello,

Are you searching for an alternative to new ActiveXObject("Microsoft.XMLDOM") which will work in all popular browsers? Then here it is a solution.

This Javascript library will give you the possibility to do almost everything what you could do with ActiveXObject("Microsoft.XMLDOM") but in different browsers.

IE window.showModalDialog() - Cross Browser solution

Hello,

QUESTION: How to make window.showModalDialog() work on cross browser? or at least how to do something similar? with arguments, return value and window.close()?

ANSWER: There is no simple way to do that.

ATTENTION: dialogArguments will be lost if the page inside the popup will do a postback. For a better solution see my new version - click here.

First of all window.showModalDialog() function is something which works only on Internet Explorer and in the best case this command will open a new small window on some browsers, however this window is far from a modal window.

If you still need to have the same functionality as window.showModalDialog(), to pass some parameters / arguments to the page inside the popup and then return some values back from that page in the parent page, and also have the ability to close the popup from the inside of the popup then this article is for you.

Here I have created a modal popup, using jQuery, which gives you the ability to pass arguments to the page inside the popup almost in the same way as you would pass it through showModalDialog().

02 March 2011

SQL - How to check if a string has uppercase / lowercase characters

Hello,

When you need to compare two strings in SQL to check if this string contains uppercase or lowercase values it is always a problem, because in sql "ExTremeDev.blogSpot.com23" is equal to "extremedev.blogspot.com23".

I also needed to do such thing, in order to make some rules for a password, so that it will contain numbers, uppercase characters and lowercase characters.

Here I will provide an example like that:

03 February 2011

Menu on multiple lines - Cross Browser


Hello,

Sometimes the menu which you need to display is generated using a repeater and you do not know exactly how many items will be displayed, and here you need a menu which will wrap in case there is not enough space.

I have also searched for this kind of menu on the internet but I could not find one. This is why I decided to create one by myself.

Well of course some ideas are take from some samples but in general I had to rewrite some code and change CSS, in order to make it to work how I needed and cross browser.

The height of the menu items are automatically readjusted to be the same. This is done because otherwise the menu will not be displayed correctly.

23 January 2011

IE window.createPopup() - cross browser solution

Hello,

Probably a lot of you came to the situation when you needed to have a popup as the one which IE is providing when using window.createPopup().

I have surfed a lot on the internet, but I couldn't find a solution that would satisfy my requirements. This is why I decided to create my own library in Javascript. I will provide the code of it below in this post.

Note: jQuery is used in this code, this is why you will need first of all to include jQuery library (Core & UI) before below code.

Need more? Leave comments and subscribe to my blog.

.