-->

Friday, March 7, 2014

How to develop rich-interactive applications with silverlight

In the initial years of the Internet and Web development, websites were developed using only Hypertext Markup Language (HTML). The content built using only HTML for the Web pages is mostly static. Gradually, with the advent of other new technologies and languages, such as cascading Style Sheets (CSS), XHTML, and Javascript, it is now possible to add user interactivity and a little bit of dynamism to webpages. With the passing years, some other technologies, such as Adobe flash and JavaFx, gave a new dimension of interactivity to Web pages as these technologies gave a huge boost to various fields of business, such as e-learning and online advertising. However, some of these technologies are expensive to deploy, varied in performance, and also have inadequate compatibility with different programming technologies.

How to develop rich-interactive applications with silverlight


To overcome the limitations of earlier technologies, such as Adobe Flash and the ever increasing demand of Rich Internet Applications (RIA), Microsoft brought out Silverlight. Formerly known as Windows presentation Foundation/Everywhere (WPF/E), Silverlight is an inexpensive small plug-in that can work in a cross-platform, cross-browser, and cross-device environment. Silverlight is supported by both Microsoft Windows and Apple Macintosh family of operating systems as well as popular Web browsers, such as Microsoft Internet Explorer, Mozilla Firefox, and Apple Safari.

Silverlight is a Web-based technology that allows Web designers and developers to stretch the boundaries of Web application development. It is an integration of the rich user interface (UI) of desktop applications and the transparency of other Web languages, such as HTML and JavaScript . Silverlight allows you to develop Web applications that contain high-fidelity multimedia content and eye-catching visual effects. Web applications.

Thursday, March 6, 2014

How to use Primary Key Constraint on Column in SQL

In SQL, Primary Key constraint is defined on a column or a set of columns whose values uniquely identify all the rows in a table. These columns are referred to as the primary key columns. A primary key column cannot contain NULL values since it is used to uniquely identify rows in a table. The primary key constraint ensures entity integrity.

You can define a primary key constraint while creating the table or you can add it later by altering the table. However, if you define the primary key constraint after inserting rows, the SQL Server will give an error if the rows contain duplicate values in the column. While defining a primary key constraint, you need to specify a name for the constraint. If a name is not specified, the SQL Server automatically assigns a name to the constraint.

If a primary key constraint is defined on a column that already contains data, then the existing data in the column is screened. If any duplicate values are found, then the primary key constraint is rejected. The syntax of applying the primary key constraint when creating table is:

CREATE TABLE table_name
(
Col_name [CONSTRAINT constraint_name PRIMARY KEY
 [CLUSTERED|NONCLUSTERED]
Col_name [, col_name [, col_name [, … ] ] ]
)

Where,

  • Constraint_name specifies the name of the constraint to be created.
  • CLUSTERED|NONCLUSTERED are keywords that specify if a clustered or a nonclustered index is to be created for the primary key constraint.
  • Col_name specifies the name of the column(s) on which the primary key constraint is to be defined.

In the preceding example of the EmployeeLeave table, you can add a primary key constraint, while creating the table. You can set the EmployeeID and the LeaveStartDate columns of the EmployeeLeave table as a composite primary key. You can use the following statement to apply the primary key constraint:

CREATE TABLE HumanResources.EmployeeLeave
(
EmployeeID int,
LeaveStartDate datetime CONSTRAINT cpkLeaveStartDate PRIMARY KEY (EmployeeID, LeaveStartDate),



)

The preceding statement creates the EmployeeLeave table with a composite primary key constraint on EmployeeID and LeaveStartDate. The name of the constraint is cpkLeaveStartDate.

How to Apply Constraints on Columns in SQL Programming?

In SQL Programming, consider an example where a user entered a duplicate value in the EmployeeID column of the Employee table. This would mean that two employees have same employee ID. This would further results in erroneous results when anybody queries the table. As a database developer, you can prevent this by enforcing data integrity on the table by using constraints.

Constraints define rules that must be followed to maintain consistency and correctness of data. A constraint can either be created while creating a table or can be added later. When a constraint is added after the table is created, it checks the existing data. If there is any violation, then the constraint is rejected.

A constraint can be created by using by using either of the following statements:

CREATE TABLE statement
ALTER TABLE statement
A constraint can be defined on a column while creating a table. It can be created with the CREATE TABLE statement. The syntax of adding a constraint at the time of table creation is:
CREATE TABLE table_name
(
Column_name CONSTRAINT constraint_name constraint_type [, CONSTRAINT
)
Where
  • Column_name is the name of the column on which the constraint is to be defined.
  • Constraint_name is the name of the constraint to be created and must follow the rules for the identifier.
  • Constraint_type is the type of constraint to be added.
Constraints can be divided into the following types:

Difference between structure and class

Structure
Class
Structure use public modifier by default
Class use private modifier by default
In concept of inheritance, derived structure is public by default when access modifier doesn’t use in base class.
In case of class concept, derived class is private by default when access modifier doesn’t use in base class.
Use ‘struct’ keyword in language c, c# and ‘structure’ keyword use in VB for implementing structure block
Use ‘class’ keyword for implementing class block.
Structure is a collection of bits.
Class is a collection of members of society.
Structure is based on procedural approach
Class is based on object-oriented approach.
It doesn’t support Data hiding concepts. Means you can’t implement security in it.
You can implement security in it Using data hiding.
It is a value type
It is reference type
Size of empty structure is 0 byte
Size of empty class is 1 byte
In case of template, we can’t use it.
Always we use class in case of structure.
template<struct T> // ERROR, struct not allowed here
template<class T> // OK
Structure may represent real world object.
Class is highly suitable to represent real world objects rather than "Structures"
Structure value will be stored in stack memory
Class members are stored in heap memory.
Structure used for light weight object.
Class is used for complex data type

Wednesday, March 5, 2014

What are the types of Data Integrity in SQL Programming?

If checks are not applied while defining and creating tables, the data stored in the tables can become redundant. For example, if you do not store the data about all the employees with complete address details, then the data would not be useful.

Similarly, if a database used by the Human Resource department stores employee contact details in two separate tables, the details of the employees might not match. This would results inconsistency and confusion.
Therefore, it is important to ensure that the data stored in tables is complete and consistent. The concept of maintaining consistency and completeness of data is called data integrity. Data integrity is enforced to ensure that the data in a database is accurate, consistent, and reliable. It is broadly classified into the following categories:

  • Entity integrity: ensures that each row can be uniquely identified by an attribute called the primary key column contains unique value in all the rows. In addition, this column cannot be NULL. Consider a situation where there might be two candidates for an interview with the same name ‘Jack’. By enforcing entity integrity, the two candidates can be identified by using the unique code assigned to them. For example, one candidate can have the code 001 and the other candidate can be 002.
  • Domain integrity: Ensures that only a valid range of values is stored in a column. It can be enforced by restricting the type of data, the range of values, and the format of the data. For example, you have a table called Branchoffice with a column called offices are located in ‘Berkeley’, ‘Boston’, ‘Chicago’, ‘Dallas’, ‘Munchen’, ‘New Jersey’, ‘New York’, ‘Paris’, and ‘Washington’. By enforcing domain integrity, you can ensure that only valid values (as per the list specified) are entered in the City column of the BranchOffice TABLE.
  • Referential integrity: Ensures that the values of the foreign key match the value of the corresponding primary key. For example, if a bicycle has been ordered and an entry is to be made in the OrderDetail table, then that bicycle code should exist in the product table. This ensures that an order is placed only for the bicycle that is available.
  • User-defined integrity: Refers to a set of rules specified by a user, which do not belong to the entity, domain, and referential integrity categories.

When creating tables, the SQL Server allows you to maintain integrity by:

  • Applying constraints
  • Applying rules
  • Using user-defined types

Difference between procedure and function

Procedure
Function
A procedure is a block of code that can't returning a value. You can say it’s a types of function when that doesn’t return the value.

Example.
Module ABC

    Sub Main()
      
        SProcedure()
       
    End Sub
   
    Sub SProcedure()
        Console.WriteLine("dotprogramming.blogspot.com")
    End Sub
   
End Module

A function is a block of code and after running its code returns a value to the calling code.

Example
Module ABC

    Dim a As Integer = 10
    Dim b As Integer = 20
   
    Dim result As Integer

    Sub Main()

        result = Addition(a, b)
        Console.WriteLine(Addition(a, b))
       
    End Sub
   
    Function Addition(ByVal c As Integer, _
                       ByVal d As Integer) As Integer
        Return c+d
    End Function
   
End Module
Procedure are not categorize or you can say it doesn’t divide in parts.
Functions are divide in two parts
1.       Built-in function
2.       User-defined function
Use “Sub” keyword for creating procedure
Use “function” keyword for creating function.
Procedure will execute when action is called
But in case of function you can say it’s a loop.

HTML server control classes in ASP.NET

ASP.NET uses the HTML server control classes to work with the HTML controls using a programming language. These classes include the HtmlTextArea class for the HTML <textarea> controls, the HtmlInputButton class for HTML buttons created with the <input type="button"> elements, the HtmlInputText class for HTML text fields created with the <input type="text"> elements, and the rest. while working with HTML server control, you are actually working with their supporting classes. You can even work with these classes directly in code.
Most of the attributes of HTML server controls can be specified through the properties window of IDE. These properties are written in lowercase. As soon as you change or specify the value of these properties, the corresponding changes are made to the HTML element in the .aspx page. For example, you can set the caption of an HTML server button at design-time using the Value property, which corresponds to the HTML <Input> element's value attribute. However, at runtime, this attribute is supported by the HtmlInputButton class's Value property. When we work with an object of the HtmlInputButton class on the server, the casing (upper or lower case) of property name in server code adheres to the coding language standard.
It is important to know that the HTML server control classes exactly correspond to the actual HTML controls that you see in the HTML tab in ToolBox. For example, the HtmlInputButton class is used not just for buttons but also for reset buttons. All these buttons are created using an HTML <input> element, and they differ only through the attribute named type; for example, a standard button uses <input type="button">, a reset button uses <input type="reset">, and a submit button uses <input type="submit">.

Note : As per HTML rules, the HTML controls must be in the HTML form(with .htm or .html extension) while they are sent back to the server. However, when you create a web form using the ASP.NET IDE, you need not require to create the HTML form explicitly; ASP.NET does that automatically as soon as you add a new web form to the website.

HTML classes are based on the HtmlControl class. Some server control class are listed in

HtmlAnchor : Creates an <a> element for navigation.

HtmlButton : Creates an HTML button using the <button> element.

HtmlForm : Allows access to the <form> HTML element which is a container for other controls on a web page.

HtmlgenericControl : Defines the methods, properties and events for all HTML server controls not represented by .NET Framework.

HtmlImage : Maps the <img> element for displaying image on a web page.

HtmlInputButton : Creates an Html button using the <input> element.

HtmlInputCheckBox : Creates an Html checkbox.

HtmlInputControl : Defines the methods, properties and events for HTML input controls.

HtmlInputFile : Creates an HTML file upload control.

HtmlInputHidden : Creates an HTML input hidden control.

HtmlInputImage : Creates an HTML button that display image.

HtmlInputRadioButton : Creates an HTML radio button.

HtmlInputText : Creates an HTML text field. You can also use this control to create password fields.

HtmlSelect : Maps <select> element and allow to create list control.

HtmlTable : Creates an HTML table.

HtmlTableCell : Creates an HTML cell in a Table.
© Copyright 2013 Computer Programming | All Right Reserved