Posts

Showing posts from 2008

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"
How to Access Selected Value Of a DropDownList In JavaScript:- ddl.options[ddl.selectedIndex].value ; This is the way that I have found to access a DropDownList. Thogh there is SelectedValue property of a dropdownList, It did not work.
Digital Divide Of 32 Bit And 64 Bit There are lot of products from hardware and software speaking about 32 and 64 bit. The article is an effort to understand the differences for common user. Your hardware and software both can be 32 bit OR 64 bit. If your hardware i.e. processor and other peripherals support 64 bit, then you can run 64 bit supported software on it provide you have 64 bit Operating System such as Windows Vista 64 Bit. 1.Software:- 32 bit OS Features of 32 bit OS: - Good for systems running 32 bit applications and having data sets smaller than 2GB. Supports - 4GB System Memory 2 GB Dedicated memory / process eg. Windows Vista, Windows Server 64 bit OS What do you mean by 64 bit OS? More than 4GB Dedicated Memory/process can be supported 64 bit of data can be moved per clock cycle. Features of 64 bit OS: - ASLR(Address Space Layout Randomizer) – It ensures system fil

Enter key pressed on TextBox flushes content….

ASP.Net 2.0 Enter key pressed on TextBox flushes content…. If you go on professionally developed websites, many times you need to fill in some forms. If you notice carefully, when you filled up all the fields in the form and you want to submit the form you don't need to tab to Submit button. If your cursor is on a text box and you press enter, your form will be submitted. Try this with your form developed in .Net. Probably it will behave in very wearer ways. Your contents may get flushed or something else situation may happen at run time. On .net platform previous to ASP.NET 2.0 solving this situation was some time taking task like using Javascript, register your control for a particular function call and do the required things in that function. OR add a text box invisible. But these all techniques may create some other problems while solving one problem. Solution:- ASP.NET 2.0 removes all these headaches and provides you a simple way to go. Suppose you have 2 text box and Submit b

jrew has stopped executing…….

Oracle9i Installation:- jrew has stopped executing……. This is the message that you will get when you will try to install Oracle9i on Windows Vista. The mystery behind this message is that Oracle has stopped providing support to Oracle9i and Vista is latest operating system from Microsoft which is totally different from previous Microsoft OS. So Oracle9i will not work on Vista. If you want to keep your OS as Vista and want to work on Oracle, you have to install Oracle 10g.

Validate TextBOx in javascript

A simple Javascript function to validate Input values entered in TextBox will be as follows:- //Calls when User Clicks on Ok in AddCriteria Div to validate Text Box Name function ValidateGroupName() { Name = Document.getElementById("ctl00_ContentPlaceHolder1_txtCritGroupName").value; NameSize=Name.length; //Validation for Blank TextBox if(NameSize==0) { alert("Group Name cannot be empty"); return false; } if(DescSize==0) { alert("Group Description cannot be empty"); return false; } //Validation for Group Name //Validation for only Space Input FlagName=true; for(i=0;i { if(Name.charAt(i)!=" ") { FlagName=false; } } if(FlagName) { alert("Group Name

Check If Control/Shift/Alt Key Is Pressed In JavaScript:-

Check If Control/Shift/Alt Key Is Pressed In JavaScript:-

We need to check evt.CtrlKey property to check if Ctrl Key is pressed. This code only works on IE and not on FireFox.. The same code can be used to check if Shift & Alt Key is Pressed, by replacing CtrlKey with respective keys in evt.CtrlKey