Monthly Archives: November 2012

Regular Expresson for SQL keyword with spaces

You drag the column node in SQL Management studio so you have access to individual columns. You delete some field and keep other and want to pull data from the table.The proble is some field name contain spaces such as “First Name”, or “Local Address”. they are seperate only by ,

It would be painful to put brackets around every single keyword. You can use regular expression in SSMS or Visual studio or any other online utility to bring this into proper format.

I used the followring reqular expression in SSMS

Previous logic

This logic was not that robust.

If you want to put brackets aro

Calling asp.net control from C# constructor

If you try to call an ASP.NET control from the constructor in C# page, you will get a null exception. This is because the control really did not get initialized at this point or the value was not yet assigned to it. So the constructor in ASP.NET page is really limited of what it can do.

To initialized variable from textboxes or other controls on page, use Page_load(Object Sender, EventArgs e) function

Quran Translation Errors

There are verses in Quran that are translate wrong. Check this verse

The translation of this verse is made as

Sahih International
And if you fear that you will not deal justly with the orphan girls, then marry those that please you of [other] women, two or three or four. But if you fear that you will not be just, then [marry only] one or those your right hand possesses. That is more suitable that you may not incline [to injustice].
Muhsin Khan
And if you fear that you shall not be able to deal justly with the orphan-girls, then marry (other) women of your choice, two or three, or four but if you fear that you shall not be able to deal justly (with them), then only one or (the captives and the slaves) that your right hands possess. That is nearer to prevent you from doing injustice.
Pickthall
And if ye fear that ye will not deal fairly by the orphans, marry of the women, who seem good to you, two or three or four; and if ye fear that ye cannot do justice (to so many) then one (only) or (the captives) that your right hands possess. Thus it is more likely that ye will not do injustice.
Yusuf Ali
If ye fear that ye shall not be able to deal justly with the orphans, Marry women of your choice, Two or three or four; but if ye fear that ye shall not be able to deal justly (with them), then only one, or (a captive) that your right hands possess, that will be more suitable, to prevent you from doing injustice.
Shakir
And if you fear that you cannot act equitably towards orphans, then marry such women as seem good to you, two and three and four; but if you fear that you will not do justice (between them), then (marry) only one or what your right hands possess; this is more proper, that you may not deviate from the right course.
Dr. Ghali
And, in case you fear that you will not act equitably towards the orphans, then marry such women as is good to you, two, three, four, (Literally: in twos and threes and fours) then, in case you fear that you will not do justice, then one (only), or what your right hands possess. That (way) is likelier you will not be in want (Or: you will have too many dependents).

None of the translation has accurately translated the last phrase.
ذَٰلِكَ أَدْنَىٰ أَلَّا تَعُولُوا

It correct meaning is
The lowest does not count

How to optimize SQL Join for peformance (speed)

I was working on Joining three table which took 3min 4 sec to execute. Unacceptably slow. There was no way I could make it faster because the logic was straight forward.

Then I though one of the column that I was using in JOIN (even though it was number) did not have index on it. So I put index on it using

And then ran my query. It gave result in less than a second.

The result always JOIN on Index column esp if the tables are large!

Entity Framework Tutorial

This about link is a great tutorial about Entity Framework.

Basically there are a number of ways to access data from the database in an Application.

ADO.NET
LinQ
Entity Framework

ADO.NET

Allows you to access data directly through SQL Server API’s or any RDBMS.

LINQ

Linq allows to fetch/access SQL Server data via C#/VB.NET language. It further has 3 flavours. Linq to SQL, Linq to DateSet and Linq to Entity

Entity Framework

Allows access to database entities. In Entity framwork that database is model in a new entity based data. There is an abstraction between the actual data and the queries. These entities can be anything, SQL, XML or something else. To the programmer he simply fetches data from this model, not the actual database.

Regular Expression for Phone numbers

The following regular expressions can be used to validate/test the phone numbers

It can be test on Rubular – Regular Expression Tester

The following variation of the above string accepts a . (dot) also between numbers

Visiting Dubai via Transit

If you are flying through Dubai and you have more than 8 hours stay, you might want to go out of the airport and check out Dubai. There are certain rules though you need to be aware of. Your airlines (Emirates) usually will give you a hotel which will include free food or you may have to arrange it yourself through them. Please read the following if you have transit in Dubai and you want to check out the city yourself.

US Passport Holder

If you hold a US passport, you do not need a visa. You do not need any Voucher from Emirates. You do not need to book a hotel via Emirates to get out of the airport. You simply stand in line for Passport Control, they issue you stay upto 30 days (without any fee). You can book your own hotel if you want too but even better you do not need a hotel, just roam around the city and come back for your departure flight. It is that simple. You do not have to pay for anything.

Pakistani Passport Holder

With computerized Pakistani passport, you will need a Voucher from Emirates to get out of the airport. If you do not have the Voucher, you will have to ask Emirates to arrange a hotel for you. If your ticket is expensive, you might get it free but most likely you will have to pay for it. The free is about $100 and up. Note that with Pakistani Passport, you will not be allowed to go outside the airport with out a hotel. You have to make hotel reservation before you go out.

Pakistani Passport Holder – Manual

If you have a manual Pakistani passport, Dubai authority do not issue visa on these (manual) passport. The only way you get get out of the airport is if you already have a Voucher from Emirates. If not they will ask you to contact your Embassy who will send them letter to approve your Visa so they can stamp it. This would be a pain and not worth the time.

Comming up — How to visit Dubai vai Dubai Metro