-->

Wednesday, March 12, 2014

Data Bound Control in ASP.NET

What are databases? Why do we need them? How does a .NET application work with databases? These are some of the questions whose answers we need to know before we learn about working with databases in ASP.NET.
A. database is a collection of records or information that is stored in the form of tables in a systematic way so that a computer program can access the information easily whenever required. Structured Query Language (SQL) is used for retrieving, storing, deleting, and updating the records stored in a database. An application may need to use the databases for performing various functions, such as:
Displaying data in a tabular format by retrieving the records from the database
Displaying the data after processing the record retrieved from the database, such as calculating the service duration of each employee and then displaying the records
Processing the retrieved data and updating them in the database
Deleting the records from the database depending on the choice or condition specified by the user of the application
Here you learn about data bound controls that supported by ASP.NET. You can bind the data bound controls to the data source controls to display the data. Following is a list of data bound controls:
The GridView Control
The DataList Control
The DetailsVlew Control
The FormView Control
The ListView Control
The Repeater Control
The DataPager Control
The data source controls allow you to work with different types of data sources, such as SQL server or an XML file. Following is a list of data source controls:
The SqlDataSource Control
The AccessDataSource Control
The LinqDataSource Control
The ObjectDataSource Control
The XmlDataSource Control
The SiteMapDataSource Control

Recursive function to find the factorial of a positive number

Recursive function to find the factorial of a positive number:

        unsigned long int rfact(unsigned long int num)
       {
         if (num==0)
          return 1;
         else
           return n*rfact(n-1);
         }

In the above function (num==0), is the base condition. When this condition is true then the recursive call is terminated. In the recursive call you can observe that every time the actual parameter value is changed. It is necessary to reach to the base condition. Suppose that the recursive function is called with a parameter 4. Then the function will return the value of the expression 4*rfact(3); it means the function rfact() is called i.e. recursion. So, the function will return the value only after getting the value of rfact() is again called with parameter 2. So, till the base condition is satisfied the same function is called again by again by changing the parameter. When the parameter is 0 for the rfact(), the call terminates by returning 1. Then one by one all the function calls will be terminated in the reverse order of their calls. This is called as backtracking. So the call rfact(0) returns 1, rfact(1) also returns 1, rfact(2) returns 2, rfact(3) returns 6, rfact(4) returns 24. 24 is the final value returned by the first function call. So the factorial value of 4 is 24.

Recursive function to find ‘gcd’ of two positive numbers:
int rgcd(int a, intb)
{
    if (a%b=0)
       return b;
    else
      rgcd(b, a%b);
  }

QUEUE for Data Structure in C Programming

Queue is also a special type of linear data structure resulting after restriction of insertion and deletion operations on linear data structure. So, it can be implemented using either one-dimensional array or linked list. When the insertion operation is restricted to the other end in a linear data structure, then the resulting data structure is called as QUEUE. Insertion or addition of items is done at the end called REAR end and deletion of items is done from the other end called as FRONT end.
                         Assume a service center, with one serving window. The person comes for the service first is served first. If another person comes for the service, while the first person is being served, he has to wait. He will stand behind the first person. If any other persons come for the service, they will also stand one by one behind each other. The waiting persons frame a QUEUE. The persons are added into the QUEUE from end called REAR end. One person who enters the QUEUE  first is served first. The deletion is done from the other end FRONT end. As an item is added to QUEUE at the REAR end and it is deletion from the other end, FRONT end, the item added first comes out first. So the data structure QUEUE is also called as FIFO, First In First Out structure. QUEUE has many applications in computer Field.
                   In a multiprocessing environment, the processes waiting for the CPU service are placed in a QUEUE called Ready Queue. In multiprocessing environment the CPU executes more than one process.

Representation of Queue: 
          The representation of QUEUE  depends on the type of QUEUE. The QUEUE can be implemented either using a one-dimensional array or using Linked List. As there are different type of QUEUE depending on storage and the way the ADD and DELETE operations are done on the QUEUE.

Type of QUEUE:


1 Linear QUEUE: The elements are arranged in a QUEUE in linear order.

2 Circular QUEUE: The elements are arranged in a QUEUE by means of circular array.
3 DEQUE-Double Ended QUEUE: The ADD and DELETE operations are done from both the ends.
4 Priority QUEUE: The elements are stored in QUEUE with a characteristic called priority and DELETE  operation depends on priority, high priority elements are deleted first (served first).

Tuesday, March 11, 2014

Recursion for Data Structure in C programming

Recursion:


          Recursion is another good example of programming field where STACK is used. Recursion is an art of programming or a technique in programming in which the subprogram calls itself. In programming usually when a subprogram is written it is called in main program. Using a statement in the main program can do a call to the subprogram. If a call statement of the subprogram is used within the definition of the same subprogram then it is termed as recursion.
                                        Whenever a function (in case of C the subprogram is function) call is made in main program the control transfers to the function, the function is executed and control transfers back to the calling point. Note here that the internal STACK is used to store the address of the next instruction that is to be execution completes.

                                   main()
                                  {
                                     -----;
                                     fun();
                                     -----;<------------address of this instruction is stored in STACK
                                  }
                                   fun()
                                   {
                                      ----:
                                    }
                   The recursion can be used to solve certain problems where the problems have base condition. When the base condition is satisfied the call should terminate otherwise a call is made again with changed value. Means recursion is used only in those cases when the same set of statements are to be executed again and again with changed value and that changed value reaches to base condition the recursive call should terminate.

Monday, March 10, 2014

Evaluation of POSTFIX expression using STACK

Evaluation of POSTFIX expression using STACK :

To evaluation the value of a POSTFIX expression STACK can be used in the following way:
Procedure: Add #, a pound symbol, a sentinel, a terminating symbol at the end of the POSTFIX expression. Scan the expression from left to right till #.If the character scanned character is an operand PUSH it on to STACK. If the scanned character is any operator, * , POP STACK once call it B and POP again and call it A, find A  *   B, and PUSH the result on to STACK. If the character scanned is #, then POP the STACK and it is the value of the POSTFIX expression.. For example consider a POSTFIX expression, 6 3 2| *3 6 +/.

The value of POSTFIX expression is 6.
Algorithm to evaluate the value of POSTFIX expression:
POSTFIXVAL (P)
[P is a POSTFIX expression]
Add # at the end of P
Repeat Scanning P from left to right While scanned character
< >  #
  If Scanned Character = operand Then:
    [PUSH it on to STACK]
   STACK [TOP]<--OPERAND, TOP<--TOP+1
 Else:
  B<--STACK[TOP], TOP<--TOP-1
  A<--STACK[TOP],TOP<--TOP-1
  RES <-- A operator B
  STACK [TOP]<--RES
[End of While]
VAL<--STACK[TOP]
Write : ‘Value of POSTFIX expression is ‘, VAL
Exit.


Sunday, March 9, 2014

How to use Unique Key Constraint on Column in SQL

Unique constraint is something like primary key constraint, which is used to make a record unique within all other records in sql database.

The unique constraint is used to enforce uniqueness on non-primary key columns. A primary key constrain column automatically includes a restriction for uniqueness. The unique constraint is similar to the primary key constraint except that it allows one NULL row.

Multiple unique constrains can be created on a table. The syntax of applying the unique constraint when creating table is:

CREATE TABLE table_Name
(
Col_name [CNTRAIN cstraint_name UNIQUE [CLUSTERED | NONCLUSTERED]
 Col_name [, col_name [, col_name [, …]]])
Col_name [, col_name [, col_name [, …]]]
)
Where
  • Constraint_name species the name of the constraint to created.
  • CLUSTERED | NONCLUSTERED are keywords that specify if a clustered or a nonclustered index is to be created for the unique constraint.
  • Col_name specifies the name of the column(s) on which the unique constraint is to be defined.
This constraint is also applied on columns as same as primary key constraint.

Primary Key Constraint
Foreign Key constraint

Friday, March 7, 2014

Main Features of Silverlight

As started earlier, silverlight was previously known as WPF/E because it is a subset of WPF, inheriting many functionalities of WPF. For example, Silverlight supports XAML, 2-D vector graphics, animations, and multimedia. However, certain features, such as 3-D graphics and hardware rendering of WPF, are not available to Silverlight. You may wonder about the difference between XAML browser Applications (XBAPs) in WPF and Silverlight. One of the notable differences between the two is that XBAPs can run only in Internet Explorer and firefox, whereas Silverlight applications can run in multiple Web browsers. Secondly, XBAPs require .NET Framework to be available on the users’ computers, while Silverlight provides the necessary components on itsown and does not need .NET Framework. Thirdly, an XBAP has access to the computer WPF functionality, while a Silverlight application has only limited WPF functionality.

The first version of silverlight unveiled by Microsoft was Silverlight 1.0. this version was released in 2007 and was based on the JavaSript application model. You could incorporate the functionality of Silverlight 1.0 in .NET Framework 2.0 and Visual Studio 2005 applications. Now, let’s go through these main features of Silverlight.

Improved Programming Model

Silverlight technology supports the .NET Framework programming model to develop Silverlight applications easily. Silverlight leverages many functionality and features of .NET Framework, such as type safety and exception handling. It also includes many classes from the base class liberary, and offers you the provision of working with IO, collections and generics, and threading. You can use any of the .NET languages, such as VB and C# to develop Silverlight applications. You can also use other dynamic language such as IronPython and IronRuby. Furthermore, you integrate Silverlight functionalities with the existing ASP.NET Web applications. You can combine ASP.NET AJAX and Silverlight to get the best of both the technologies. Silverlight also supports language Integrated Query (LINQ) to objects, which facilitates you to work with various types of data in the Web applications.

Note that Silverlight seamlessly integrates with the HTML, JavaScript Document Object Model (DOM) as with XAML parser providing you with the facility to work with HTML, JavaScript, and XAML simultaneously. In this way, Silverlight extends a cohesive platform for developing interactive and superior quality  Web applications.

Comprehensive UI Framework

Silverlight has a comprehensive UI framework to allow you to design the UI of Web applications by using the predefined controls, styles, themes, and templates. Silverlight offers a wide range of controls and layout features to build exceptionally attractive Web applications. Most of the controls and layout features are the same as those available in WPF. For example, the Grid, StackPanel, Calendar, Button, TextBox, and RadioButton controls of WPF are also available in Silverlight. You can also use styles and control templates in the Silverlight applications. Moreover , there are additional controls, such as MultiScaleImage that are specific to Silverlight. You can also use the data binding and data manipulation controls, such as DataGrid. These new controls were designed from scratch to give an extra edge to the Web applications.
These predefined Silverlight controls and layout features help you to quickly and easily develop some high-end Web applications. You can set the properties of these controls to get the desired effect. Note that these properties can also be set using XAML. XAML is the facilitator for separating the design and the code of Web applications.

Support for Deep Zoom Technology

Silverlight  includes a new feature called Deep Zoom, which allows you to zoom high-resolution images in the applications. You can use the Deep Zoom technology to deliver unbelievably creative and uniquely interactive Web applications. With the Deep Zoom technology, you can easily, quickly, and smoothly zoom in or out multiple photographs simultaneously. You can see a highly detailed and fine view of the photographs by using the MultiScaleImage control available in Silverlight 

Support for 2-D Graphics, Animations, and Multimedia

Silverlight has built-in support for using 2-D vector graphics and animations in Web applications. You can create 2-Dshpes, such as rectangles and ellipses, geometries, and brushes. You can also transform and animate the shapes and geometries. In addition, you can make your Web applications dynamic by using storyboards controlling the animation timeline and speed, and much more.
There is an extensive support in Silverlight for captivating multimedia experience on the Web. You can include .jpeg or images in the applications to give them an attractive UI. In addition, Silverlight supports various multimedia formats, such as .wma, .wmv, and .mp3 and has some of the essential codecs for playing back multimedia content. You can also use High-Definition (HD) quality video (up to 720p) in Silverlight applications. Silverlight also offers protection through authentication  and authorization of users and Digital Rights Management (DRM) for the multimedia content that you add to your Web applications.

Support for Networking

Silverlight  contains classes to support networking and predefined sockets. It allows you to use various HTTP, XML, RSS and REST services. Furthermore, you can use an XML format to use the data and resources on other web sites. Silverlight extends the cross-domain support for networking. You can also use Silverlight  for communication with sockets over standard network protocols, such as IPv4 and IPv6.
© Copyright 2013 Computer Programming | All Right Reserved