Pagination in Oracle 11g

Assalamualikum wr br.

Today we discuss about one requirement where data needs to be displayed in GridView from table abc which has more than 2,66,000  records. This was coded to fetch data using DataAdapter on page_load event later it was done pagination from memory using GridView pagination. Later it was reported that memory leakage encountered and pagination is not responding.

Hence it was suggested to retrieve data on demand which means based on page index of gridview, no. of records needs to be fetched from data table.

Also most interesting point is Oracle 11g is being used which does not support Fetch and Limit keywords.

Fetch is used to limit the result set  generated  from the query. Since we use 11g we need to modify the existing query  as below:

Select   *  from

(         Select  p.record_type,

p.reject_reason,

p.dealer_id,

p.dealer,

p.company,

p.country,

p.state,

p.pin,

rownum rm

from

(select   p.record_type,

p.reject_reason,

p.dealer_id,

p.dealer,

p.company,

p.country,

p.state,

p.pin

from  abc) p

where rownum <=   50 <max_limit>)

where rm >= 10  <min_limit>;

 

With the help of above modifications I can able to retrieve the records in table data between max_limit and min_limit. Otherwise the rownum would return from records 1 to specified constraint.

 

That’s all for the day.

Jazakallah khair..Happy Programming..:)

Sample Application Demonstrating LINQ

Assalamualaykum Wr Br…Today we build simple Web Application which demonstrates insertion of data from UI to data table without using Connection, Command class but using LINQ(Language Integrated Query).

Lets quick start our building by designing the Form as shown belowLinq_desing_form

Associated HTML code is shown as:

Linq_html_code

Now Drag & Drop the dbml file which creates the DataContext Class with various methods and properties. It also creates class as similar to our table which is shown below:
linq_dbml

Now the Button_Click event code is shown below:
linq_code
The above code generates the following output as shown below:

linq_output
Thats all for the Day!!!…Happy Coding…Jazakallah Khair
Which generates the following output as shown below:

Xplore XSLT with Visual Studio…

Assalamualaykum Wr Br…Today we explore XSLT which stands for XSL stands for eXtensible Stylesheet Language. It is a language used to design and apply style sheets especially for XML documents. Originally the research started to provide style sheet technology to XML using XSL, but finally ended up with three more divisions of XSL. So, XSL now consists of three parts namely XSLT, XPath and XSL-FO.

XSLT is a language for transforming XML documents (even today, several programmers call XSLT as XSL).

XPath is a language to filter, search or sort information available in XML documents.

XSL-FO is a language for formatting XML documents.

In this article we mainly focus on XSLT, which stands for XSL Transformations. Lets begin with simple xml file with its associated xslt as shown below:
simplexml

Please notice that at line 2 in above image we have HREF=”SAMPLE1.XSLT” which illustrates the browser to parse the xml document as per the standards mentioned in xslt file which is shown below:
simplexslt
When I try to open the simple.xml file in browser then it is displayed as:
simpleoutput

Let us explore the xml document first few lines which delivers the mapping with xslt as shown:

<xml:stylesheet type=”text/xsl” href=”sample1.xslt”?>

This is the only magic needed in any XML file to be transformed to any XSLT. The above statement instructs browser to link the current XML document with “sample1.xslt” and present (transform) it accordingly. So, in general we will not see the XML document as a tree structure anymore. It will be presented (transformed) in a different way as specified in “sample1.xslt”.
Now, let us study the most important lines in sample1.xslt.

<xsl: stylesheet version=”1.0″ xmlns:xslt=”http://www.w3.org/1999/XSL/Transform”&gt;

The above line defines that it is basically an XSLT document used for certain transformation.

<xsl:template match=”/”/>

The above line specifies the format (template) applicable to the root of XML document. We can also specify individual templates for each and every XML element as well. The attribute ‘match’ can be provided with any XPath expression.

<xslt: value-of select=”Employees/Employee/Name”/>

And finally, the above line states that it has to get the value (text) present in that path (Employees/Employee/Name) of XML document (tree) starting from root. In this case it starts from root (/), then searches for Employees element (first element), within that Employee child element (first child element) and finally the child element Name (first child element) of Employee element. This path could be replaced with any XPath expression.

Now very interesting part begins now…
Create a new project and add simple.xml and simple1.xslt files to your solution as shown below:
vsxslt
its xslt file in visual studio is shown as:
vsxslt1
Now hard code little code in page load as shown below:
vsxslt2
vsxslt3
Now Execute the code and output is as similar to shown above…hope enjoyed this post…
Jazakallah Khair…

jQuery Series 4

Assalamualaykum Wr Br..Welcome to the jQuery Series 4
Lets code the html as shown below:
series4
Now its associated jQuery code can be written as:
series4_js
Let us traverse the code, line 2 depicts the selector “h1” when clicked calls a function which in turn have a selector “h2” which gets hided as per the action defined. The parameter inside the hide method is the milli seconds which allows to hide the selector with such speed or you can consider the parameter as the speed of the event. The following images shows the output as:
output_4
output_4_!
The heading3 is going to take place of heading 2 after clicking the heading 1 i.e., “Click Here”.
Lets explore jQuery beauty a bit deep…The above requirement was that the html page consists of 3 headings and clicking Heading 1 hides heading 2…Right??
Now lets reverse our requirement as on html page there should be 2 headings and clicking heading 1 should show heading 2 and at the ed the page should have 3 headings..
To implement this there is no need to change our html code but jQuery as shown below:
output_4_2
Check it out its output its very interesting….That’s all for the day…Hope enjoyed…

jQuery Series 2

Assalamualaykum Wr Br..Today we deal with Selector of jQuery..
What is Selectors in jQuery?
Selectors can be attribute or entity which selects entire content(s) it belongs and perform the required action.
The syntax of selectors in jQuery is as follows:
$(“”).;
Now lets us start with an example whose html code can be coded as shown below:
series2
and its associated jQuery code is shown as:
seriesjs
Lets traverse the code of jquery which is shown above:
The first line is the entry point of jquery execution as stated in Series1 post..
The next line is Selector which selects the id of control followed by “#”, here please refer the html code where button has id as followed by “#”. Continuing after selector action is specified here is click then again 3 line starts with Selector which selects all “div” tagged lines and then followed action to change its background color change to red. The next lines are specifies the syntax of closing.When you execute such code the output can as shown after clicking Test buttonoutputseries2.
Now we observe that only first two lines which are under div tag gets background color change on button test click…Here we add some more selectors to our jquery file as shown below:
$(“div,#testbutton,p”).css(“background-color”,”red”);//which results change in background color of button,all tagged entites..
$(“strong”).css(“background-color”,”red”);//changes background color for strong tagged entities
$(“div > p:first-child”).css(“background-color”,”red”);//changes background color for first div tagged entity.similarly $(“div > p:last-child”).css(“background-color”,”red”);
Now selecting Descending elements as: $(“div strong”).css(“background-color”,”red”);//here single space after div specifies that the descend strong tagged in parent div tagged entities.Now the selector for selecting even and odd tagged elements can be shown as “$(“p:even”).css(“background-color”,”red”);” note that the line index starts with 0.

Some more interesting stuff…. to the html page for third <p> tag, I gonna edit it as <p id=”third”>………save it and to the jquery file change the selector field as:

$(“#third”).css(“background-color”,”red”);

I hope you are enjoying…Now awesome feature of jQuery is here..Selecting based on “id” of an element is represented by “#” and for classes it is represented by “.”(dot symbol)..lets look our selector statement would be:

$(“.multiple”).css(“background-color”,”red”);

here multiple is the class name which we specify in html page as shown:
class

JQUERY Series 1

Assalamualaykum Wr Br…Lets quick start our journey towards the world of JQUERY which is quite simple to use than JavaScript. JQuery is a library of JavaScript. jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript.

The prototype of jQuery is as follows:
1.$().ready();
2.Then modify step 1 as:$(document).ready(function () {//write code here
});
jQuery always start with symbol ‘$’ and ready keywords specifies that after all html code is loaded on browser then start executing the jQuery code. In other terms, jQuery controls all the execution of markup code and JavaScript. I understand that theory seems so boring…yeah now lets start our practical session.
step 1: Write the HTML code to display 2 headings, when clicked on first heading it shows corresponding paragraph text and on again click hides it. The next heading will be the static heading. The behavior is achieved from the jQuery code as shown below:
jq1
$(“p”).hide(); //this code specifies the browser not to display paragraph(

blah blah

)contents.
$(“h1”).click(function(){});//this piece code of code illustrates on click to heading 1 execute the function whose implementation is coded as:
$(this).next().slideToggle(300);//instructs that on click of heading toggle it to 300pxs..thats all in our jQuery code…save the file as “my_code.js”.
Step 2: Now write the simple html code that is shown as:
jq2
Please Note: It is simple html markup code written and in body tag we wrote two script tags, first is for referencing the library of jQuery which is kept in same directory location where all my files associated to this page is present and other script tag specifies the “my_code.js” jQuery file.
It is the protocol that these order of the scripts is must.
If you dont have the jQuery library with you then download it from http://jquery.com/ and reference it in src=”my_code.js” and close the script tag as show above.
When you open your html document using browsers then you would get is as shown:
jq3
Now click on Heading 1.
jq4
…Thats all for this series 1..we shall meet soon with various tips and tricks of jQuery..till then Enjoy..

 

Debugging an Application for long run…

Assalamualikum Wr Br…I was asked to look for settings to increase the timings of debugging from being time-outs when debugging a huge application. So in response to such situation I thought of posting it which would help to all.

Consider an application is being debugged as shown below:
iis
From the above image we conclude that a file named “RouteConfig.cs” possess a BREAKPOINT in method RegisterRoutes. Similarly we may have BREAKPOINTS in various files and methods, debugging these all may some time returns a dialog like as shown:

This situation caused because of the fact that the debugger(breakpoints) stopped execution of code on the Web site. This caused Internet Information Services (IIS) to assume that the worker process had stopped responding. Therefore, IIS terminated the worker process.

To continue to debug, you must configure IIS to allow the worker process to continue. This error message does not appear with versions of IIS that are older than IIS 7.
To configure IIS 7 to allow the worker process to continue

Open the Administrative Tools window.

Click Start, and then choose Control Panel.

In Control Panel, choose Switch to Classic View, if necessary, and then double-click Administrative Tools.

In the Administrative Tools window, double-click Internet Information Services (IIS) Manager.

IIS Manager opens.

In the Connections pane, expand the node if necessary.

Under the node, click Application Pools.

In the Application Pools list, right-click the name of the pool your application runs in, and then click Advanced Settings.

In the Advanced Settings dialog box, locate the Process Model section, and perform one of the following actions:

Set Ping Enabled to False.

Set Ping Maximum Response Time to a value that is larger than 90 seconds.

Setting Ping Enabled to False stops IIS from checking whether the worker process is still running and keeps the worker process alive until you stop your debugged process. Setting Ping Maximum Response Time to a large value allows IIS to continue monitoring the worker process.

Click OK to close the Advanced Settings dialog box.

Close IIS Manager and the Administrative Tools window. The brief screen shot is shown as:

iis1

For me it is TRUE just set to FALSE…

Hope you enjoyed this post…Thanks

Jazakallah Khair