Wednesday, October 17, 2012

Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironmentException


Few days ago, I was working on a Windows Azure App, I created a Web Role  which was representing my application interface. Its purpose was to upload images. I needed to generate thumbnails as well.I thought to delegate this responsibility to a Worker Role. 
My Web Role  add image to a Blob and add a message in queue as well for the worker role, so that it can read it and generate thumbnails for each queued image, later.
When I created a worker role and tried to access the storage account with my defined connection string, it started giving me RoleEnvironmentException , I set the connecting-string for the application so I thought it will work for both Web ad Worker Roles, but it was not the case.
For Windows Azure, we have to set connection string for every worker and web roles, independently. I hope this will help any new bee on Windows Azure. 
Thank You and Happy Coding.......

Tuesday, October 16, 2012

Datatable belongs to another dataset


DataTable already belongs to another DataSet this error we get when we are trying to add table into datatset which is already belonging to another dataset. So whats the solution?Its simpleUse Copy() method of DataTable to add to your dataset e.g.

objDataSet.Tables.Add( dataTableFromDataSetA.Copy() ); 

//here objDataSetis your Dataset and dataTableFromDataSetA is DataTable.


Hope this post save your time. Thank You.

Tuesday, October 2, 2012

Jquery Tabs


Let me mention few simple steps to implement tab in Jquery :


First, make sure the HTML (ASPX) page you are creating is pointing at the stylesheet that contains the jQuery UI theme you are using.  The tabs make use of the themes and will not render as tabs unless the styles are pulled in.


Next you’ll need to create the HTML.  Everything that has to do with tabs should be wrapped in a DIV.  You can either give the ID a class or give it an ID, as long as you can select it later to apply the tabs() method that turns it all into a tabbed interface. Suppose our parent div is  


Within that DIV, you’ll place an unordered list:

<ul> <li><a href="#cricketTab">Cricket</a>

</li> <li><a href="#hockeyTab">Hockey</a></li> <li>

<a href="#footballTab"> Foot Ball </a></li> <li>

<a href="#basketballTab"> Basket Ball </a></li> </ul>

which represents your tabs.  Notice the href=”#id” stuff.  Those are pointing to ids of the DIVS that come next.

<div id="cricketTab">Cricket content</div> <
<div id="hockeyTab">Hockey content</div> <
<div id="footballTab"> Foot Ball content</div> <
<div id="basketballTab">Basket Ball content</div>

Next, in your jQuery code, select the outer DIV and call tabs()


$(function() {
$("#tabs").tabs();
});



By following this simple steps , tabs will be created.  For full documentation go to Jquery Tab. Thank You.

Tuesday, September 25, 2012

SET NOCOUNT Usage


SET NOCOUNT ON, in SQLSERVER, is used to stop the message that shows the count of the number of rows affected by the SQL statement written in the stored procedure or directly SQL Statement. You can view this message in the Management Studio in the Message tab of the result pan. 

When NOCOUNT is ON - the number of affected rows will not be returned 
 When NOCOUNT is OFF - the number of affected rows will be returned   

Triggers also need it, as its useful, If we don't turned on NOCOUNT, their performance can be drastically affected . Take, for example, INSERT triggers that are fired repeatedly, especially when using INSERT INTO statements for massive insert operations. In such cases where the trigger is fired over and over again during the course of the statement, the trigger will issue DONE_IN_PROC messages for each INSERT action, which can slow things down drastically. 

This slow down is especially pronounced if the trigger is being fired as the result of a scheduled SQL Server Agent job. SQL Server Agent automatically imposes a delay after each DONE_IN_PROC signal to avoid server congestion. If you try running the same set of commands through the Query Analyzer, it will execute much faster since no such delays are imposed. If you run such a query through Query Analyzer and see multiple "n rows affected" statements, there's a good chance the query is iterating repeatedly and re-firing the trigger many more times than it really needs to. To turn off DONE_IN_PROC messages, use the SET NOCOUNT ON command at the start of a trigger statement. 

 Microsoft actually encourages the use of SET NOCOUNT ON in Stored Procedures. 
 There is another thing @@ROWCOUNT, which is relevant to this. It is used to get the number of rows affected. Note that either the SET NONCOUNT is ON or OFF, @@ROWCOUNT is always updated with the number of rows affected.

 I hope this post help everyone in understanding the usage of SET NOCOUNT. Thank You.


Earn Money ! Affiliate Program
Open Directory Project at dmoz.org