Posts

Weekend Gateway Trip - Shrivardhan

Image
We were looking for short trip to get refreshed from daily routine. Are you looking for one halt short trip from Pune, then read onwards. We started at 6 PM Saturday from Narhe, Pune and returned back by 7:30 PM on Wednesday. Route that we followed was as below. Pune -> Pirangut -> Mangaon -> Mhasala -> Shrivardhan And return route was Shrivardhan -> Dive Aagar -> Mhasala -> Mangaon -> Pirangut -> Pune In all it was approximately 350 Km drive. You can view this route on Google map here -> Trip Route   About Shrivardhan :- I will say Shrivardhan has got most clean and developed beach in all kokan beaches we visited so far. It has been developed with seating arrangements and provision of lights on the beach. It is great experience seating at beach in the night. You will also get typical rides that you can expect at other beach like Camel ride, Horse ride, Ghoda gadi, beach bike ride. You get couple of water sports options ...

Tech.Ed 2011 announcements I am looking forward to

Image
TechEd is an event every developer, especially those working on Microsoft Technologies would look for. This year TechEd is on 23rd to 25th March at Banglore. With so many new products from Microsoft since last TechEd, I am looking forward for really cool stuff this year. I expect sessions on hot cake technologies like Windows Phone, Azure. Introduction of these technologies have also resulted new architectural patterns. It would be nice to get introduced to these patterns. I expect a Azure trial period offer announcement for developers in India, as in US. Some hands on and tips for Windows 7, Office 2010. Microsoft Certifications have been restructured in recent past. Several new certification focussing on new technologies have been added. It will be nice to have overview of that. I expect certification offers for recently introduced technologies. A lot has been said on HTML5 and Silverlight. It will be great to hear about Silverlight focus from Microsoft guys. Silverlight team ...
Incorrect syntax near '.' Recently I came across an issue in Sql Server 2005, while running CROSS APPLY. The error says that Incorrect syntax near '.'. I tried to figure out all syntax that I could apply but it did not resolve the issue. Actually we need to set sp_dbcmptlevel level to 90. There are good blog posts for this here and here, which can save your valuable time.

Cross Apply Incorrect syntax near '.'

Recently I came across an issue in Sql Server 2005, while running CROSS APPLY. The error says that Incorrect syntax near '.'. I tried to figure out all syntax that I could apply but it did not resolve the issue. Actually we need to set sp_dbcmptlevel level to 90. There are good blog posts for this here and here , which can save your valuable time.

Asp.Net Save File on client machine

Recently I had a task to save file on client machine. We usually save file on server and in ASP.NET the more familiar task to save on client side was to export gridview results to excel file. This time the task was to save an image on client machine. Following is the code that I followed.   <pre name="code" class="html"> byte[] fileBytes = File.ReadAllBytes("D:\\Projects\\TestClientDownload\\images\\banner_ad_1.jpg");        Response.ClearContent();        Response.ClearHeaders();        Response.ContentType = "text/plain";        Response.AppendHeader("content-disposition", "attachment; filename=" + "banner_ad_1.jpg");        Response.AppendHeader("content-length", fileBytes.Length.ToString());       ...

Alert : can not set credentials for principal sa

  While editing credentials of database user, you may get this error in Sql Server 2008 management studio. It is just a checkbox that needs to be checked to resolve this issue. But this may save your few minutes finding the issue cause. Here is a great link for resolving this issue – http://weblogs.asp.net/atlaszhu/archive/2009/08/08/alert-cannot-set-a-credential-for-principal-sa-when-trying-to-modify-sa-properties-through-sql-management-studio-2008.aspx Technorati Tags: sql server , login

Apply CSS Class based on Browser

  Do you need to modify couple of CSS class attributes depending on browser?   There are various ways to achieve it. But I found this very simple approach for working on this issue.                 There are modifications needed at 2 places in the code. One is in the HTML body / ASPX page and other is in CSS file. Suppose there is DIV in your mark up and you want to apply different CSS class attributes if browse is IE6 / IE7/ IE8. Then just add a container div with id IE7 to this div. It can be added as this on ASPX page (Note- you can add this in Master page / specific page if you are not using Master Pages): - <!--[if IE 7]><div id="ie7"><![endif]-->       <div class=”category”> This is div of interest where ie7 specific rendering should be done.       </div>   <...

Optimized way to get count of rows from a table

  To get no. of rows from a table we usually use query Select count(*) from table_name But this query reads complete table to return no. of Optimized way for performing this query is Select rows from sysindexes where id= Object_Id(‘table_name’) Technorati Tags: Sql Sever

Get Unused Stored Procedures from Sql Server 2008

While working in projects, I always used to wonder about maintaining Stored Procedures in Sql Server. The way in which we organize them is that we go on adding the required stored procedures with some name convention so that we can identify what is the module to which this SP refers. But as the project goes ahead modifications come, we go on adding required Stored Procedures and some Stored Procedures become obsolete because of business rule changes. But as far as I have observed in IT projects, these stored procedures are kept as it is and when the project completes no one has any idea about which Stored Procedures are currently in use and which are obsolete. But I have come across this post , which shows how to get probably unused SPs from Sql Server 2008. The query is as follows, which returns SPs which are not in procedure cache. //The first part gives list of all SPs and also works in SQL2005 Select p.name From sys.procedures as p wh...

Adding Javascript In Amazaon mTurk Form

  Adding JavaScript to mTurk form is possible and very simple. The difference here is that we have been given only body tag of html page. So we have to add JavaScript under body tag of the page. One difficulty that I faced was if there is some error in JavaScript, it simply doesn’t execute the script. So using alert to debug into the JavaScript problem is very useful here. You can get the element in JavaScript using document.getElementById(). But it you want to use syntax document.form.element_name then you should use it like document.mturk_form.element_name. This has worked properly in my case. One more precaution while using JavaScript with mTurk form is that mTurk validates html file with stricter validations. So if your JavaScript is working fine in your html editor but not in mTurk, then there could be syntax problem with your JavaScript which is not supported by mTurk due to stricter validation rules. Technorati Tags: Amazon mTurk , JavaScript

ado.net service end point exception

While using ADO.NET Service, we need to be very careful about setting initial Entity reference; otherwise the errors do not reveal cause. E.g. suppose you have not given proper entity reference, the error that it throws while viewing service in browser is Service 'NorthWindDataService' implements multiple ServiceContract types, and no endpoints are defined in the configuration file. WebServiceHost can set up default endpoints, but only if the service implements only a single ServiceContract. Either change the service to only implement a single ServiceContract, or else define endpoints for the service explicitly in the configuration file. So we may look to change settings for service endpoints. But the error is actually because of improper service reference. Technorati Tags: ado.net data service , entity data model

Calculating Computed Column in Sql Server For XML data Using Function

Lets work on 2 operations in this post. 1.Using Function in Sql Server 2.Calculating Computed Column in Sql Server For XML data Using Function I have used AdventureWorks Database in this example. Table Used := FROM HumanResources.JobCandidate Table contains Resume in XML format. First get candidates into new table hr.CandidateNames. CREATE Schema hr SELECT TOP 10 JobCandidateID As CandidateID, Resume As JobResume INTO hr.CandidateNames FROM HumanResources.JobCandidate Now Create Function to parse through XML nodes. Function will return concatenated FullName for each candidate. CREATE Function hr.FullName(@name XML) RETURNS NVARCHAR(60) AS BEGIN RETURN @name.value('declare namespace ns= "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; concat((/ns:Resume/ns:Name/ns:Name.First)[1], " ", (/ns:Resume/ns:Name/ns:Name.Last)[1])','nvarchar(60)') END Now Just Query Function to get Result as...

Sample From Desktop

This is sample blogging from Google Blogger Desktop

Windows Install/Uninstall Error :-Error 1327 : Invalid Drive Z

The error occurs while installation / uninstallation of Microsoft softwares like Office,SqlServer,VisualStudio in Windows OS. It may happen because of number of reasons. It may look for an entry in Windows registry which looks for an invalid drive, which may be created while installation of some other product. One solution is to check registry values for incorrect Data field. To resolve this behavior we can enter correct value data for register key. In Registry Editor locate Registry Key in following folders:- HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders If any Key has invalid Drive Entry, Right click on the Entry & change In...

SQL Server 2005 - Showing ResultSet in a Single Row OR in a comma separated string format.

Scenario:- Suppose You have a table abc (Sal_Id int ,Emp_Id int). The Following Query is fired on the table select Emp_Id FROM abc WHERE Sal_Id=1 Query gives result with following rows 1 2 4 Your requirement is to get these values in a single row. This can be achieved by making use of COALESCE in SQL Server. The above Query can be modified as follows to fetch the rows in required format. DECLARE @EmpList varchar(100) SELECT @EmpList = COALESCE(@EmpList,'') + CAST(Emp_Id AS VARCHAR(3)) FROM abc WHERE Sal_Id=1 select @EmpList This will fetch result as 124 If you want result as a Comma Separated string, change COALESCE function as COALESCE(@EmpList,',' ''). You will get result as 1,2,4

Simple Program to read Xml File Using LINQ in ASP.NET 3.5

Image

Disabled TextBox content not PostBack to Server in ASP.NET 2.0

You are having a web page with text box and button. When you click on Button, the value content by TextBox is posted to server. Now suppose one scenario is such that you already have got value of text box content while showing the web page. You don’t wish user to change this value. So you have to disable TextBox, so that value can not be entered. TextBox can be disabled by code in JavaScript:- document.getElementById( "textBox1" ).disabled= "disabled" ; The disabled TextBox in JavaScript can be eanble by document.getElementById( "textBox1" ).disabled=false; But the problem is that ASP.NET 2.0 do not recognize value supplied in TextBox if it is disabled. This is the way they have changed ASP.NET structure from 1.1 To 2.0. The solution to this that I have found for this problem is enable property of Form to submit Disabled Controls. This can be achieved by this line in PageLoad Page.Form.SubmitDisabledControls = true ; ...

Cross Page PostBack Using ListBox

Scenario:- You have a list box on a web page. You select value in the Listbox & Control is transferred to another page which shows value selected in the ListBox. Solution:- As there is no button on the page, ListBox AutoPostback should be true. But ListBox PostBacks to same Page. Here requirement is that it should post to other page. So we need to change the property of ListBox. We can not access Controls of Previous Page from Next Page. So we will define a Public property on First Page & access that on Second Page. Code Snippet:- Code on FirstPage.aspx.cs:- public partial class ListBoxCrossPagePostBack : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { PostBackOptions options = new PostBackOptions(ListBox1); options.ActionUrl = "SecondPage.aspx"; string s = Page.ClientScript.GetPostBackEventReference(options); ListBox1.Attributes["onchange"] = s; } public Lis...
CommandEventArgs contain CommandName & CommandArgument Properties Button by default behaves as Submit button, but if we provide CommandName then itbehaves as CommandButton CommandButton raises CommandEvent . It will be useful when u want to pass event related info to event handler Features Of webServer Contorls:- Intrinsic Events Eg. Button has intrinsic events of click and command But Datagrid has 9 intrinsic events Event ArgumentsAll Events in .Net framework passes 2 arguments. 1.Object that raised event 2.Object that contains event specific info. If Event doesn't have event specific info then it passes System.EventArgs by default. Otherwise it passes EventSpecific data such as ImageClickEventArgs which is derived from System.EventArgs AutoPostback It causes Immidiate Postback as a result of click event of Button Control BubbledEvents All the events raised at child level are bubbled up to p...
How To Hide And Show ListBox in JavaScript:- To Hide document.getElementById(ListBoxId).style.visibility="hidden" To Show document.getElementById(ListBoxId).style.visibility="visible"