+91-90427 10472
         
Dot net training in Chennai

Overview of C# and DotNet

Introduction:

The synergy between C# and the DotNet framework has become a cornerstone for building a wide range of applications, from desktop software to web services and cloud-based solutions, in the realm of software development. In this article, we’ll look at the capabilities, features, and versatility that C# and DotNet bring to the table, making them a dynamic programming duo.

C#: A Versatile and Modern Language:

A Quick Overview of C#:

Microsoft C# (pronounced “C sharp”) is a modern, object-oriented programming language. It combines the best features of C and C++ with the simplicity of Java, making it an excellent choice for developers looking for a powerful and expressive programming language.

Object-Oriented Paradigm:

C# adheres to the principles of object-oriented programming (OOP), emphasizing encapsulation, inheritance, and polymorphism. This enables developers to write modular, maintainable code, resulting in more efficient software design.

Type Safety and Memory Management:

C# is a statically-typed language, which means that variable types are known at compile time, reducing the likelihood of runtime errors. Automatic memory management via the garbage collector improves the language’s robustness.

Asynchronous Programming:

C# simplifies asynchronous programming with the introduction of the async and await keywords. This is especially important when developing responsive applications that can handle concurrent tasks without blocking.

DotNet: A Unified Development Platform

Introduction to the DotNet Framework:

Microsoft’s DotNet framework is a comprehensive platform for developing, deploying, and running applications. It provides a consistent development environment for a wide range of applications, including web, mobile, desktop, cloud, and gaming.

Common Language Runtime (CLR):

The Common Language Runtime (CLR), which manages the execution of DotNet programs, is at the heart of the DotNet framework. It has functions like automatic memory management, exception handling, and security.

Unified Type System:

The DotNet framework has a unified type of system in which all types, whether built-in or user-defined, derive from a single root (System.Object). This unity promotes interoperability and code reuse across the DotNet ecosystem’s various languages.

Extensive Class Library:

DotNet includes a large class library with pre-written code for common programming tasks. The Base Class Library (BCL) is a library that simplifies development by providing a wide range of functionalities without the need to reinvent the wheel.

Building Applications with C# and DotNet:

Desktop Applications with WPF:

C# is frequently used to develop Windows Presentation Foundation (WPF) applications, which allow for the creation of feature-rich and visually appealing desktop software.

Web Development with ASP DotNet:

ASP DotNet, a component of the DotNet framework, allows developers to use C# to create dynamic and scalable web applications. ASP DotNet provides a strong framework for developing APIs and full-stack web applications.

Cross-Platform Development with DotNet Core and DotNet 5/6/7:

Recent DotNet ecosystem advancements, such as DotNet Core and the subsequent DotNet 5, DotNet 6, and DotNet 7, have expanded C#’s capabilities to embrace cross-platform development. Developers can now create applications that run on Windows, macOS, and Linux.

Mobile App Development with Xamarin:

C# is used in mobile app development by Xamarin, a framework that allows developers to create cross-platform mobile apps for iOS, Android, and Windows using a single codebase.

Conclusion:

C# and DotNet are modern software development pillars, providing a versatile and unified platform for developing a wide range of applications. Whether you are an experienced developer or just starting out, exploring the capabilities of C# and DotNet opens up a world of possibilities. The continuous evolution of these technologies ensures that developers have the tools they need to stay ahead of the ever-changing software development landscape. Remember that the journey is just as rewarding as the destination as you delve deeper into the worlds of C# and DotNet.

 

Have fun coding!
Begin your Journey Today,
for Training, Contact via Call/WhatsApp :+91 90427 10472 

Stored Procedure – SQL

Stored Procedure:

A stored procedure is a collection of Structured Query Language (SQL) statements with a unique name that are stored as a group in a relational database management system (RDBMS) to be reused and shared by multiple programmes.

Stored procedures can access or modify data in a database, but they are not tied to a specific database or object, which provides several benefits.

So, if you have a SQL query that you write repeatedly, save it as a stored procedure and simply call it to execute it.

Additionally, you can send parameters to a stored procedure, allowing it to take action based on the value(s) of the passed parameters.

 

Advantages of Using Stored Procedures:

An essential layer of protection is added by a stored procedure between the user interface and the database. Because end users can add or modify data but not develop procedures, it enables security through data access controls. Since data is entered consistently while using a stored procedure, data integrity is maintained. Because statements in a stored method just need to be written once, productivity is increased.

Stored procedures are preferable to embedding queries in a graphical user interface (GUI). When a problem arises in an application, it is easier to troubleshoot because stored procedures are modular. Stored procedures are also tuneable, so there is no need to change the GUI source code to improve its performance. It is simpler to code stored procedures than it is to build a query using a GUI.

When using stored procedures, network traffic between clients and servers can be reduced Because commands are performed as a single batch of code. This implies that only the call to run the procedure—rather than each individual line of code—is delivered across a network.

 

Stored Procedure in SQL Server:

SQL Server stored procedures can accept input parameters and return multiple values of output parameters; stored procedures in SQL Server programme statements to perform database operations and return a status value to a calling procedure or batch.

Except when a read-only (resource database) is utilised, user-defined procedures can be created in user-defined databases or in all system databases. They are created using Microsoft’s T-SQL or Transact-SQL. There are two sorts of temporary procedures: local and global, both of which are kept in Temporary database. While global procedures are visible to any user once they are generated, local procedures are only available to the user connection that is active at the time. Physically, system procedures are kept in a hidden resource database that comes with SQL Server. They can be found in a user-defined database as well as each system’s SYS schema.

 

Stored Procedure Syntax in SQL:

Syntax To Create Stored Procedure:

CREATE PROCEDURE Procedurename
AS
SQL STATEMENT
GO;

Syntax To Execute Stored Procedure:

EXEC Procedurename;

 

Various types of stored procedures Server SQL:

 

System Defined Stored Procedure: SQL Server already has these stored procedures defined. These are physically stored in a hidden SQL Server Resource Database and logically appear in each user-defined and system-defined database’s sys schema. The sp_ prefix is used to begin this procedure. As a result, we avoid using this prefix when naming user-defined procedures.

Extended Procedure: Extended procedures interface with external programmes to perform various maintenance tasks. These extended procedures are stored in the Master database and begin with the xp_ prefix. Essentially, these are used to automatically call programmes on the server from a stored procedure or a trigger run by the server.

User-Defined Stored Procedure: The user creates these procedures for his or her own actions. Except for the Resource database, these can be created in any system database or in a user-defined database.

CLR Stored Procedure: CLR stored procedures are a type of procedure that is based on the.net framework’s CLR (Common Language Runtime). CLR procedure integration was introduced with SQL Server 2008, allowing procedures to be coded in.NET languages such as C#, Visual Basic, and F#. I’ll go over the CLR stored procedure later.

SQL Server Joins

SQL JOIN

The statement JOIN is used to combine the rows of two or more tables based  on a common column.

The different types of JOIN statement used in SQL are

  • INNER JOIN or JOIN – combines the data that matches  in both tables.
  • LEFT JOIN or LEFT OUTER JOIN – combines all the datas of left table with the datas from right table that matches.
  • RIGHT JOIN or RIGHT OUTER JOIN – combines all the datas of right table with the datas from left table that matches.
  • FULL JOIN or FULL OUTER JOIN – combines all the datas either from left or right table whenever there is a match found.

Let us consider an example:

Create a database with a name “StudentResults”

create database  StudentResults

Create a table “studentdetails” with following snippet

CREATE TABLE studentdetails (

regno int,

LastName varchar(255),

FirstName varchar(255),

age int,

dummyno int

);

Let us consider the following datas in table “studentdetails”

Create another table “result” with the snippet

CREATE TABLE result (

dummyno int,

marks int,

result varchar(10)

);

Let us consider the following datas in table “result”

 

INNER JOIN:

Inner Join is the most simplest Join. When inner join keyword is used in two tables, it will create a resulting table with combining the rows of both the tables until the condition is satisfied

For the above considered example, when inner join statement is used as follows

SELECT studentdetails.regno, studentdetails.FirstName, studentdetails.LastName, studentdetails.age, result.marks, result.result

FROM result

INNER JOIN studentdetails

ON studentdetails.dummyno=result.dummyno;

The resulting table will be

LEFT JOIN:

 Left join is also called as Left outer join. When left join keyword is used in two tables, it will create a resulting table with combining all the datas of left table with the datas from right table that matches.

For the considered example, when left join statement is used as follows

SELECT studentdetails.regno, studentdetails.FirstName, studentdetails.LastName, studentdetails.age, result.marks, result.result

FROM studentdetails

LEFT JOIN result

ON studentdetails.dummyno=result.dummyno

ORDER BY studentdetails.regno;

The resulting table will be

RIGHT JOIN:

 Right join is also called as right outer join. When right join keyword is used in two tables, it will create a resulting table with combining all the datas of right table with the datas from left table that matches.

For the considered example, when right join statement is used as follows

SELECT studentdetails.regno, studentdetails.FirstName, studentdetails.LastName, studentdetails.age, result.marks, result.result

FROM studentdetails

RIGHT JOIN result

ON studentdetails.dummyno=result.dummyno

ORDER BY studentdetails.regno;

The resulting table will be

FULL JOIN:

 Full join is also called as Outer join. When full join keyword is used in two tables, it will create a resulting table with combining all the datas either from left or right table whenever there is a match found.

For the considered example, when full join statement is used as follows

SELECT studentdetails.regno, studentdetails.FirstName, studentdetails.LastName, studentdetails.age, result.marks, result.result

FROM studentdetails

FULL OUTER JOIN result

ON studentdetails.dummyno=result.dummyno

ORDER BY studentdetails.regno;

The resulting table will be

SQL Constraints

SQL Constraints

Constraints are the rules that can be applied on the type of data in a table. i.e, it can be used to limit the type of data that can go into a table.

Constraints can be used either when the table is created, or after the table is created.

It can be either applied to a column in a table or to the whole table.

The constraints used in SQL are:

  • NOT NULL
  • UNIQUE
  • PRIMARY KEY
  • FOREIGN KEY
  • CHECK
  • DEFAULT
  • CREATE INDEX

 

NOT NULL: if this constraint is used in any column, then it will not allow NULL values in that particular column anymore.

Eg:

CREATE TABLE StudentDetail (

    ID int NOT NULL,

    Name varchar(250) NOT NULL,

    Branch varchar(250) NOT NULL

);

In this command, all the columns are specified with NULL Constraint, so all the columns will allow NULL data in it.

 

UNIQUE: if this constraint is used in any column, then it does not allow to repeat any data or value inn that particular column anymore.

Eg:

CREATE TABLE StudentDetail (

    ID int NOT NULL UNIQUE,

    Name varchar(250) NOT NULL,

    Branch varchar(250) NOT NULL

);

In this command, all the ID column is specified with UNIQUE Constraint, so that the ID cannot be repeated with same data.

 

PRIMARY KEY: This constraint uniquely identifies each record in a table or column and also does  not allow NULL data in  it.

Eg:

CREATE TABLE StudentDetail (

    ID int,

    Name varchar(250) ,

    Branch varchar(250),

PRIMARY KEY (ID)

);

In this command, the PRIMARY KEY Constraint is specified for ID, so that the ID cannot be repeated with same data, also ID cannot be NULL data.

 

FOREIGN KEY: The FOREIGN KEY Constraint references a row in another table, here, the table with the foreign key Constraint is called as the child table, and the table with the primary key is called the parent table.

Eg:

Parent Table::

CREATE TABLE StudentDetail (

    ID int,

    Name varchar(250) ,

    Branch varchar(250),

PRIMARY KEY (ID)

);

Child Table::

CREATE TABLE Marks (

    Mark int NOT NULL,

    Subcode int NOT NULL,

    ID int,

    PRIMARY KEY (Mark),

    FOREIGN KEY (ID) REFERENCES StudentDetail(ID)

);

Here the “Mark” of a student in the “Table Marks” refers to the “ID”  of the student in the “Table StudentDetail”.

 

CHECK: The CHECK Constraint validates condition for new value.

Eg:

CREATE TABLE StudentDetail (

    ID int NOT NULL,

    Name varchar(250) NOT NULL,

    Branch varchar(250) NOT NULL,

CHECK (Branch=’CSE’)

);

In this command, the CHECK Constraints, allows only the CSE as Branch.

 

DEFAULT: This Constraint is used to set a default value for any particular column, if any value is not specified.

Eg:

CREATE TABLE StudentDetail (

    ID int NOT NULL,

    Name varchar(250) NOT NULL,

    Branch varchar(250) DEFAULT ‘CSE’,

);

In this command, the DEFAULT Constraints, fills the Branch as CSE in default when Branch is not specified.

 

CREATE INDEX: This Constraint is used to speed-up the process, i.e it can create and retrieve any data from the database more quickly.

Eg:

CREATE TABLE StudentDetail (

    ID int NOT NULL,

    Name varchar(250) NOT NULL,

    Branch varchar(250) NOT NULL

);

CREATE INDEX ix_Branch

ON StudentDetail (Branch);

Here, in the table StudentDetail, the CREATE INDEX command creates an index ix_Branch using the Branch column.

 

SQL – Programming language

Database:

A database is an organized collection of structured information stored electronically in a computer system. It is controlled by a database management system (DBMS). A database most often contains one or more tables. Each table is identified by a name, the tables contain records with data.

SQL

SQL stands for Structured Query Language.

SQL is a standard language for relational database management system. Unlike Excel, SQL can handle over one million fields of data easily. SQL queries are more flexible than MS Excel formulas.

SQL is widely used in data science and analytics. SQL can be used in all modern relational database management systems like SQL Server, Oracle, mysql, etc.

SQL allows to

  • Create new databases, tables and stored procedures.
  • Insert, update, delete or retrieve any data from databases.
  • Execute queries in a database.

SQL commands is classified as below:

  • DDL Commands
  • DML Commands
  • DQL Commands
  • TCL Commands
  • DCL Commands

DDL Commands (Data Definition language) – used to define the database schemas, i.e. to create / modify / delete database structures.

  • Create – Command is used to create database, tables, and views.
  • Drop – Used to drop databases.
  • Alter – It is used to alter the structure of the table and databases
  • Truncate – It is used to completely remove all records from a table
  • Comment – used to add comment in data dictionary
  • Rename – used to rename an existing object in database

DML Commands (Data Manipulation Language) – used to manipulate the data present in database.

  • Insert: used to insert data into a table
  • Update: it updates existing data within a table
  • Delete: it deletes all records from a table

DQL Commands (Data Query Language) – used to perform queries on data within scheme objects.

  • Select: used to retrieve the data from the database

TCL commands (Transaction Control Language) – Used to maintain consistency of the database and to manage the transactions made by the DML commands.

  • Commit: used to permanently save any transaction into the database.
  • Rollback: it restores the database to last saved state.
  • Savepoint: used to temporarily save a transaction

DCL Commands (Data Control Language) – Used to control access to data stored in a database.

  • Grant: allows to perform specified tasks by specified users.
  • Revoke: cancels the previously granted or denied permissions.