Sunday, May 16, 2021

SQL Server : Round function

In this article I am going to explain the ROUND() function of SQL Server.

ROUND function returns the rounded value of numeric field to the specified length or precision. ROUND function accepts 3 parameters.

SYNTAX :

ROUND (numeric_expression , length [ ,function ] ) 

 

1.      numeric_expression : It is an expression of the exact numeric or approximate numeric data type category, except for the bit data type.

2.      Length: It is the precision to which numeric_expression is to be rounded. length must be an expression of type tinyint, smallint, or int. When length is a positive number, numeric_expression is rounded to the number of decimal positions specified by length. When length is a negative number, numeric_expression is rounded on the left side of the decimal point, as specified by length.

3.      Function: It is the type of operation to perform. function must be tinyint, smallint, or int. When function is omitted or has a value of 0 (default), numeric_expression is rounded. When a value other than 0 is specified, numeric_expression is truncated. This is an optional parameter. 

Saturday, April 3, 2021

SQL Server error handling

Here in this article I am going to explain how we can handle the error in SQL Server.

SQL server has the built in support to handle the Transact-SQL statements errors. TRY...CATCH constructs allow us to handle the error(s) in SQL server. To use the TRY...CATCH: write the T-SQL statements in TRY section. If any error occurs in TRY section written code, CATCH section T-SQL will be executed and it returns the error description.

Sunday, July 19, 2020

Web API : CRUD operation using repository pattern .net framework

In this article I am going to explain how to create Web API CRUD (create, read, update, delete) operation using repository pattern .net framework.

 

In previous I have explained how to create First Web API Hello World application with repository pattern and how to return data in JSON format from ASP.NET Web API.

 

Here in this article I am going to create Web API with CRUD operations for Article with Title, description and tags fields.

Prerequisites

-          -Visual Studio 2019

Tuesday, July 14, 2020

What is DATABASE MASTER KEY in SQL?

In this article I am going to explain What is Database master key (DMK) in SQL.

*DMK = Database Master Key

The database master key is a symmetric key used to protect the private keys of certificates and asymmetric keys that are present in the database. When we created DMK, it is encrypted by using the AES_256 algorithms and a user-supplied password.

Every database can have a separate DMK and each database can have only one DMK. 

Sunday, June 28, 2020

SQL SERVER : OFFSET and FETCH example

In this article I am going to explain OFFSET and FETCH in SQL Server.

OFFSET and FETCH are introduced in SQL Server 2012. These are used with Select and Order By clause to provide the result set.

OFFSET can only be used with Order By clause.  OFFSET specifies the number of rows to be exclude from the query. Before use the OFFSET make sure value must be equal to zero or greater than otherwise it will give error. Values can’t be negative.

FETCH is optional. FETCH specifies the number of rows to return after the OFFSET. Similar to OFFSET, values can’t be negative. Value should be equal to zero or greater than otherwise it will give error.

Friday, June 26, 2020

SQL SERVER : Get Random Records from database table

In this article I am going to explain how to get random records from SQL SERVER database table.

 

When I am working on multiple choice question application, I have got requirement every user have different questions on every test attempt. If I am going to attempt the ASP.NET test, get ASP.NET unique questions from ASP.NET category.

Tuesday, June 9, 2020

SQL SERVER : Store and Retrieve different languages data from Table

Here in this article I am going to explain how we can store and retrieve the different languages (other than English) data from SQL SERVER table.

 

When working on an application get requirement to store the data of other language than English (multilingual) in database. If you have get any such requirement, you can achieve this following two things:

Set Unicode compatible datatype (ntext, nvarchar, nchar) for table column

Use N (capital) as a prefix before inserting data/text

 

Example :

First of all, create a table. I have created table to store admin users name.



Create table tblAdmin (
EnglishName NVARCHAR(100),
HindiName nchar(100),
JapaneseName ntext
)

 

Now insert data into table.

insert into
tblAdmin(EnglishName,HindiName,JapaneseName) values(N'Vijay Saklani', N'विजय सकलानी',N'ビジェイ・サクラニ')

Get the data from table and check the saved data.

Select * from tblAdmin

 

SQL SERVER : Store and Retrieve different languages  data from Table

If you will insert the into table without prefix N, data will not be useful. It will be inserted in question mark (????) form and become garbage. Let’s check with this also:

insert into tblAdmin(EnglishName,HindiName,JapaneseName) values('Vijay Saklani',
'विजय सकलानी','ビジェイ・サクラニ')

 

Check the inserted data now.

 SQL SERVER : Store and Retrieve different languages  data from Table



Tuesday, June 2, 2020

[Error Solved]: @angular/material/index.d.ts' is not a module

Here in this article I am going to explain how to resolve the @angular/material/index.d.ts' is not a module error.

 

After upgraded currently working Angular application to Angular 9 and Angular Material 9, I get the error :

@angular/material/index.d.ts' is not a module

 

Now the question arise why this error comes and how to fix this error.

 

Reason:

Wednesday, May 27, 2020

How to add Material in Angular project

In this article I am going to explain how to add Material in Angular project.

 Angular material is an UI component library.  It is an alternative to bootstrap for Angular application. It provides modern UI components that work across mobile, web and desktop. It is Versatile, Fast and Consistent. You can read more about material component from its website : https://material.angular.io/


Prerequisite :

Visual studio code

Saturday, May 23, 2020

Angular CLI commands

In this article I am going explain the all Angular CLI commands.

 The Angular CLI is a command-line interface tool that you use to initialize, develop, scaffold, and maintain Angular applications. You can use the tool directly in a command shell, or indirectly through an interactive UI such as Angular Console.

Follow the below given command as per your requirement :

Friday, May 15, 2020

SQL SERVER : Store Multilingual (Hindi, Japanese etc.) data in Table

Here in this article I am going to explain how we can store the multilingual (Hindi, Japanese etc.)  data in SQL SERVER table.

 When working on an application get requirement to store the data of other language than English (multilingual) in database. If you have get any such requirement, you can achieve this following two things:

Saturday, April 25, 2020

Routing in ASP.NET Web API


Here in this article I am going to explain Routing in ASP.NET Web API.


What is Routing?
Routing is a mechanism that handle the incoming request from browser and figure out what to do with that request.

If you are familiar with MVC, you are happy to know Web API routing is very similar to MVC routing. In ASP.NET Web API, controller handles the HTTP requests and call the action method of controller.

Thursday, April 16, 2020

ASP.NET Web API : Return data in JSON format


In this article I am going to explain how to return data in JSON format from ASP.NET Web API.


As you know ASP.NET Web API by default return the data in XML format when we run the API in browsers. Here, we are going to learn to change the return data/response to JSON.
You can achieve this from WebApiConfig.cs file. You can find this file under App_Start folder. Firstly, add the namespace to config file
using System.Net.Http.Headers;
 and add the below given code in this file:
 config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));

Complete code of WebApiConfig.cs

Monday, April 6, 2020

Create First Web API Hello World application with repository pattern


In this I am going to explain how to create First Web API Hello World application with repository pattern.

In previous article I have explained Introduction to ASP.NET Web API.

I am using Visual studio 2019 and .net framework to create this application.

Implementation:


STEP 1 : Open VS 2019. Click on create a new project and select ASP.Net web application (.Net Framework).
Create First Web API Hello World application with repository pattern


Create First Web API Hello World application with repository pattern

STEP 2 : Configure new project window will be open. Enter the project Name, select location and click on Create button.

Create First Web API Hello World application with repository pattern

Tuesday, March 10, 2020

Create Web API Hello World First application

In this article I am going to explain how to create Web API first Hello world application.

In previous article I have explained Introduction to Web API.

I am using Visual studio 2019 and .net framework to create this application.

Implementation:
STEP 1 : Open VS 2019. Click on create a new project and select ASP.Net web application (.Net Framework).
Create Web API Hello World First application


Create Web API Hello World First application

STEP 2 : Configure new project window will be open. Enter the project Name, select location and click on Create button.

Create Web API Hello World First application

STEP 3 : Create a new ASP.NET Web application window will be open. Select Empty and check the Web API from add folders & core reference. If you want to create MVC + Web API, then select the MVC option. 

Sunday, March 8, 2020

Introduction to ASP.NET Web API


Here in this article I am going to give you introduction of ASP.Net Web API.


ASP.NET Web API
API stands for application programming interface. ASP.NET Web API is a framework developed by Microsoft, which is used to build HTTP based services. It processes the information/data between two applications and returns the data in XML or JSON format. API can be accessed by a broad range of clients like browsers, mobile, IOT, desktop application etc. It is an ideal platform for building RESTful services.

Thursday, March 5, 2020

Introduction to Web API


In the world of web, API is playing a big role. API stands for application programming interface.

What is Web API?

Web API is a framework which is used to build HTTP based services. It processes the information/data between two applications and returns the data in XML or JSON format. API can be accessed by a broad range of clients like browsers, mobile, IOT, desktop application etc.
Web API can be build using different technologies .net, java, Python, Ruby etc.

Saturday, January 18, 2020

[Solved] SQL SERVER (Error Message) : Invalid object name 'string_split'.

Sunday, January 5, 2020

SQL SERVER : Split comma separated string value


In this article I am going to explain how to split the comma separated string value in Sql Server.

Microsoft release the Sql Server 2016 in year 2016 and introduced new built-in table value function string_split. This function can be used to split a string value by a specified separator character and returns the result value inform of table. So we no need to write our user defined function to split the string value as we have doing earlier.

Tuesday, October 15, 2019

SQL SERVER : Take database backup automatically


In this article I am going to explain how to take automate daily backup of SQL Server database

As you know database is the heart of any software driven application and nobody want to lose it on any cost. So the main purpose of the database backup is to create a copy of database that can be recovered if something goes wrong with database. There can be many reason of database failure like database got corrupt, virus.

To avoid the loss of data we need to take the database backup regularly/daily basis. It is not possible to take the backup daily manually.

Saturday, September 28, 2019

Windows Task Scheduler: How to Create Basic Task


Here in this post I am going to explain how to create a basic task in Windows Task Scheduler
Few days ago I have wrote an article on Windows Task Scheduler. You can read this to know why we use the task scheduler.

To create basic task follow the steps given below:

STEP 1: Open Task Scheduler
Go to windows start button and type task scheduler.