Monthly Archives: July 2012

Create Roles in SQL Server

Creating new user in SQL Server (SQL Server Management Studio) is easy. Simply click on the security tab and you get an option of creating a new user but creating roles is not that easy. AT least you cannot create role using the GUI option, At least I could not. Here I will explain how to create roles and how to use them.

Creating Roles in SQL Server

Creating Roles in SQL Server is a two step process, if you want to include assinging user, then it is three step

  • Create Roles in itself (step 1)
  • Grand permission to the role (step 2)
  • Assign/attached user to the role (step 3)

Role in itself is nothing but simply  a name. For example I create a role called Super-administrator This role cannot do anything because it is just a name. It has not been given any access to the database. To make it a useful Role, we have to give it certain permission using SQL Grant Statements. I could not create them using a GUI options in SQL Server Management Studio 2005/2008.

Create a role (step 1)

Note that this will create role in TestDB database not in the master database!

Grant Permissions to the Role (step 2)

Next step is to assign permission to the role. We want this role the permission to select, update, delete and execute (store procedures) permission so we issue the following command.

Execute – Can execute Store Procedure and functions
Select – Can fetch data from the database
Update – Can update data
Delete – Can delete a record

You may omit either of the four to give different permissions.

Attach User to the role (step 3)

The last step is to attached the role to a user of the database. User an be added only in the master database > Security tab not in TestDB > Security tab. The best way is to create a user in the master database, give him access to all the database that you want him to have access too by Right clicking on the user and going to User Mapping. Here select the databases he should have access too. Once this step is complete assign him a role in that database

Note that we have used sp_addrolemember a stored procedure supplied by Microsoft to assign the user Guest_User to the role Guest_Access.

Summary

Important point to not here that you must create a role, give him permission. Make sure the user already exists in the database, if not you have to create the user using GUI and then assign user the role.

Reference links http://blog.namwarrizvi.com/?p=248, Microsoft CreateRole Reference, Another link to Create Role

Should I upgrade to Mountain Lion OS X

There has been some confusion over weather I should upgrade to Mountain lion because

  • It makes your computer slow
  • The upgrade might crash your data
  • The Air Play does not work
  • Siri Dictation is stupid
  • I lost some nice features such as active corners and multiple screens
  • They took away some cool features of Safari
  • It makes your computer hot and I mean seriously hot
  • Over all it is not worth it

Well when I was upgrading, I said to myself, what ever happens, at least I am going to write a review about it so here it is.

 

The upgrade Process

It too 1 hour and 4 min in total to install Mountain Lion on my 2011 macbook pro 13″. This includes only the time of installation. It took about 33 min to download the Mountain Lion OS itself. It is said, it takes considerably shorter on Macbook Air, as less as 15 min.

First Verdict

All installation went smooth. It had opened multiple sites in Safari and I really wanted to save it. I bookmarked all of it just in case. After the upgrade, all my browsers were there as it is. I check my active corners, all were still active. I also check my multiple desktop and they worked just as it used to. So no complains there. It did make my laptop hot, considerably hot! Just 5 min ago, the temperate on my macbook pro read 86C. I would clearly hear the fan. My macbook has been running really quite up till not or may be in rear occasion, but at least right now it read 62C, this is till higher than the temperature I recorded before the upgrade which was 54C. So yes so far it did make the temperature go high and it will have adverse affect on the batter life as well.

Up time before and after the Upgrade

Before the upgrade, the uptime for my macbook pro 13 with 8GB of ram was 1:25 sec and 1:18 seconds for two instances. I have to yet restart my pc to find the new uptime. This time btw include the time it takes from select the OS to the time when my calculator is displayed when the computer starts.

Over all verdict

This review is not complete. I have upgrade just over 1 hour ago. Over all I would recommend this upgrade. Please visit later for full comparison review before and after with measure data.

Outlook Deletes all Old Emails automatically

I don’t know what happened, my out look deletes all old emails (older than 6 days), even they are kept on my local drive in *.PST folder, they are even deleted from this folder. I do not know why. 6 days is the time, emails are left on the server.

So far I tried going to Tools -> Options menu and going to the last tab (other tab), then selecting Auto Archive. Here i disabled, “run auto archive every 14 days”. I hope this will help.

Basic SEO techniques

The following are a sliest of short and basic SEO techniques. I have gathered them from my personnel experience as well as from the internet.

1. Content is not King

This is commonly believed but it is not true. Content is not king. You will see a lot of top rated sites with 3 lines of contents which could be related but they are not a lot. There are bogus sites which have not contents but appear on top. Bottom line, content is not king

2. Domain name

Domain name is the second biggest factor in appearing on top of search results. If I searched for juicy oranges, the domain that contains juicy oranges will be on top. In there is not such domain, the page that had this name in the URL will be on top.

3. Page Title

As discussed above page name (that is url) contains keywords, high importance is given to it.

4. Page URL

Page title is the most important factor if you leave all the above factors. This is how the search engine decides is this the right page?

5. Meta tag

People used to believe at one point, meta description of the site is really important. Then other say, well it is not important at all as long as the contents are terrific. That is true, if contents are great, meta is not needed. But if you think you site contents are good but the site is still not on top, work on meta. Simply include keyword or phrases that you want to work target. I would target only one or two phrases at most. Phrases are better than keywords in the modern searching engines.

6. Header Tags

They are really important in the page. It brings focus to the search engine what you are discussing. Without header tags, there is no focus. Meta tags in your contents acts like magnets to search engine.

7. Contents are king

If all the above are sound (with the exception of meta), your contents are kings. If there is nothing on the site that makes people read or simply click and go back (that is higher bounce rate), the rating will gradually and quite fast go down. The site or page will loose it spot in the top page and soon it will not be shown in top results.

An important thing about content is, that it should contains the keywords or phrases that are mentioned in the title, headers so that it bring harmony and focus to the page. If contents are all over the place, it does not have a focus and it rating will be low.

8. Use of Proper HTML tags

Use proper HTML tags where it can be beneficial, for example use lists that agains bring focus to the page, you are talking about something in particular, or use definition list etc to say what a word means. These little things help and in a good way.

9. Page Life

Older pages usually have more history associated with it so they can possibly be rated high. If you ever want to replace it with a new page, use 301 redirect that is page has permanently moved. This will not affect the SEO of your new page at all. In fact it will improve it if the contents and tags are better listed in the new page.

10. Google is not stupid

Just want to say if there you have a domain, it does not have any content and it barely has anything on it, it may never show up on google search because simply there are a lot of other sites which has higher ranking that than site in that particularly category.

Format of the initialization string does not conform to specification starting at index 0

I encountered the above error in quite a weird way. I replaced a  fromview control (TextBox) with a DropDownList and an SQL DataSource and began to get this error in a different place in the application, not related at this control at all. It turned out this is one of those weird ASP.NET errors that are totally out of context. The problem was indeed the datasource control whose connection string was wrong but it pointed to something entirely different.

In the above I added connection to my sqldatasource using Properties while editing in .ASPX code (not form designer view). The problem was the connection string was built wrong, although it was done by ASP.NET itself.

Fixing the connection string as above fixed the problem.

Create Branch in SVN Tortoise – Video tutorial

Create Branch in SVN Tortoise – Video Tutorial

Steps

1. Go the repository from Tortoise SVN menu, Right click anywhere in a Window  select  > Repository browser (the top option). This will take you to the repository viewer. All of the following will be done inside Repository Viewer.

2. Copy trunk contents to a new folder i.e banches\mybranch folder and commit (Right click on truck folder and click “copy to” which has the branch icon). This creates a branch

3. Check out mybranch folder to a working copy (right click branch folder and select checkout)

4. Make changes in the working copy and commit.

5. These changes are committed in the branch folder not in the trunk (main).

 

 

Branch

File comparison with winmerge

File comparison with winmerge is really easy. You do not even need two files. You can fire up Winmerge Program Files > WinMerge > Winmerge.exe

The windows popups up with two editors one on left, one on right. Past some text in the left. Past the same text in the right pan. Modify it a little bit. Hit the referesh button and you just compared two files. It is that that easy.

Merging files using WinMerge

WindMerge is a powerfull tool for merging too files. In that case for example you have 10 lines in each code and there are 4 differences. Right click on each different and select move to the other side. Bingo you just merge the two files using a very easy interface.

‘DropDownList1’ has a SelectedValue which is invalid because it does not exist in the list of items

This error is thrown by ASP.NET in a dropdownlist where the selected value (fetched from the database), does not match any of the value in the drop down list and is therefor invalid. To explain this

Note that SelectedValue=5 does not exist in the dropdownlist therefor the error. The above code is for demenstration purpose only. It is not a working code.

Another practical example is below.

In the above case the SQLDataSource sdsGetErrorCodes fetches a list of error_id’s and Error_codes. If the selected one is not a match to anyone single of the one in the list, .NET would through this error.

Usually it is caused by NULL values which are not accepted in DropDownList or invalid values such as -1 etc.

Divert emails in outlook

If you have two different emails setup in outlook, you will have two different pst files, one for each email account. When an email comes it you can divert them to which PST file the email should go to. Sometime they can be configured wrong and both your email account will go to the same PST file although they are different emails address.

I have highlighted the three rec circles around area which point to the data files. The data files in Microsoft Outlook have .pst exention. the default is outlook.pst. Or it can be archive.pst etc etc.

The first red circles will take you to all data files that are in the default folder. They do not give you distinction which is connected to which.

The second circle is around one of the email that you can select and then click on the third red circle (change folder), it will show you what is the current default pst file and where you want to change it. This could be very useful.

Migrating PST file from one PC to the other

You can easily migrate PST file from one PC to the other. Just copy the the pst file to the new folder. Make sue you quit outlook otherwise, it may not copy. When save to the detination folder, click on File>Open Outlook data file … and select this file. It will show all the emails it has.

Migrate email and also setup the old email on the new PC

Copy the data file as above to the new PC and put it in default destination. Create a new email setup just like you would. When everything is complete, use the above image to check every single email account and which PST they are sending data too. It is possible, you default PST will be changed for the new account, it will be set to the default email on the new PC. That can be easily changed using the steps above.