ASPMANTRA | Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server AND WCF snippets and tutorial

Sql Server: Send test email with Database Mail

In the previous article I have explained how to configure databasemail using wizard in Sql Server. Now in this article I am going to explain how we can send test email with Database mail from Sql Server.

We have 2 different ways to send test email. One using Management option and 2nd using system procedure.

SQL SERVER: Configure Database Mail using wizard


Here in this article I am going to explain how to configure database mail using wizard in sql server.

As you know we can send email from Sql server. To send email from Sql server firstly we need to configure the database mail in Sql server. Kindly follow the below given steps to configure database mail in Sql server.

Error Message : Failed to update database “Aspmantra” because the database is read-only


While working on one of project, I have get below given error:
Error Message : Failed to update database “Aspmantra” because the database is read-only

As you can see error message explain the reason why you are not able to write the database. There is no way to write into database when it is read only state. To write into database you have change the state of database from read only to read-write.

Solution:
To resolve this issue we have 2 ways. One using Sql server management studio and 2nd one using Sql query.

Download Microsoft Sql server 2019


Microsoft has announced the preview of Microsoft Sql server 2019 and this will also work on both Window and Linux operating systems. Here in this article going to explain how we can download the Microsoft Sql Server 2019 CTP 3.1.


Select the evaluation file type and click on Continue button. After that fill the form with your contact information and click on Continue button. 

Download Microsoft Sql server 2019

SQL Server : Export data to excel using export data wizard


In this article I am going to explain how to export data to excel file using SQL Server export data wizard.


There are many ways to export data to excel from SQL server. Here I am going to explain how you can export the data to excel file using export data wizard. This feature is available in SSMS (SQL Server management Studio).


Open SQL Server management Studio and connect to server. Right on database from which you want to export the data. Here I have select Northwind database. Right click on it, go to Task and select Export data.
SQL Server : Drop or delete all tables from database

SQL Server : Drop or delete all tables from database


In this article I am going to explain how to drop or delete all tables from SQL Server database.

In SQL Server, there is hidden store to delete all tables. Once you connect to SQL and execute this store procedure, it’s executed for each table.

EXEC sp_MSforeachtable @command1 = "DROP TABLE ?"

If tables are referenced by foreign key constraints, in that case you have run this again and again to till all foreign key constraints delete.

Download Microsoft Northwind, AdventureWorks and Pubs sample database for SQL Server


In this article I am going to how to download Microsoft Northwind, AdventureWorks and Pubs sample database for SQL Server.

Download Microsoft Northwind, AdventureWorks and Pubs sample database for SQL Server


Northwind, AdventureWorks and Pubs databases are available free by Microsoft and can download script and back up of these databases. For Northwind and Pubs database script file is available and for AdventureWorks both script and Backup are available.

Go to this link and you will saw the link to download the script and Backup.

Download SQL Server 2017


In this article I am going to explain how to download Sql Server 2017.

We have 3 options to download the Sql server:

    1.     Sql server on premises
If  you are planning to buy the license then you can download this version, otherwise you have 180 days trial. This version have all features.

    2.    Sql server developer edition
This version of sql server is free and also includes all features. But you can’t use this version in production. Personally I want to recommend this version for development and training purposes.

    3.     Sql server Express
This version is also free and can be used in production. But the disadvantages is, it doesn’t include all features and limitation in data storage. It can store data upto 10 GB.

Sql Server: how to change the state of database


In this article I am going to explain how to change the state (Read only to Read Write and vice versa) of Sql server database.

Description:
While working on window form application, I have face the issue of read only database on data insert.

Solution:
To resolve this issue we have 2 ways. One using Sql server management studio and 2nd one using Sql query.

Asp.net MVC : Implement infinite scroll using Jquery

Here in this article I am going to explain how to implement infinite scroll using Jquery in asp.net MVC application.

Description:
I am showing list of country in application. Instead of pagination want to show all records on scroll. To fulfill this requirement I am using Jquery.

Implementation:

Model class:
   public partial class CountryMaster
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public string CountryCode { get; set; }
    }

Add Controller
Add an empty controller to project.

Complete source code of Controller:

MVC : Cascading DropdownList

Introduction: In this article today I am going to explain how we can Populate Cascading Dropdown List in Asp.net MVC4 using Json and Jquery
Populate Cascading Dropdown
(Click to Enlarge)
Description:

I want to populate State dropdown on Country selection and on State Dropdown Selection populate City dropdown. I have three classes in model CountryState and City.
Country:
using System.ComponentModel.DataAnnotations;

public class Country
    {
        [Key]
        public int CountryId { getset; }
        public string CountryName { getset; }

        public virtual ICollection<State> States { getset; }
    }

State:

Hello world application with Angular 6


Here in this tutorial I am going to explain how to create hello world application with Angular 6.

Prerequisite 

a.  Visual studio code
b.  Node.js

You can download the latest version of Visual studio code from here and Node.js from here.
Node.js installation will also install the npm. After installation start the visual studio code. If you see the message of Git is missing then you have to install the git to your system. You can download latest version here or in visual studio code  there is link in message to download git, when you click on the link it will redirect you to download link.

How to change password in MVC application


In this article I am going to explain how to change password in MVC application. 

Description:
I want to add change password functionality for logged in users. To change password users have to enter current password, after that new password and confirm the new password.
  

Implementations:
Please check the previous post Create login form and maintain authenticated user’s detail in MVC application.

Model

How to generate numeric and alphanumeric OTP (one time password) in MVC application


Here in this article I am going to explain how to generate numeric and alphanumeric OTP (one time password) in MVC application.

Description:
I want to generate OTP. OTP can be numeric or alphanumeric and it is used widely to validate the user’s information such as mobile number, in banks for transaction etc.

Implementation:

Add controller
Add an empty controller to project. Create 3 action to generate OTP, one to generate numeric and 2nd one alphanumeric.
Generate random password in MVC application

Generate random password in MVC application


In this article I am going to explain how to generate random password in MVC application.


Description:
I want to generate strong random password for users when they registers to website. Here in this article I am going to generate password using 2 ways.


Implementation:
Add an empty controller to project. I have create action Generatepassword.

  public ActionResult Generatepassword()
        {
            return View();
        }

Using Membership Generate method
ASP.NET MVC : Display data in 2 or more columns

ASP.NET MVC : Display data in 2 or more columns


In this article I am going to explain how to display data in 2 or more columns in MVC application.

Description:
I want to display data in 3 columns. To display data 2 or more columns we have 2 approaches. One use the Bootstarp, if use the bootstrap it adjust itself. 2nd one using the loop, run the loop and differentiate them like odd and even. For 2nd one check this article.

Implementation:
Model

MVC : Generate random OTP (one time password)


In this article I am going to explain how to generate random OTP (one time password) in asp.net MVC application.

Description:
I want to generate OTP. OTP can be numeric or alphanumeric and it is used widely to validate the user’s information such as mobile number, in banks for transaction etc.

Implementation:

Add controller
Add an empty controller to project. Create 3 action to generate OTP, one to generate numeric and 2nd one alphanumeric.

Complete code of controller:

How to show data in 2 columns in MVC application


In this article I am going to explain how to show data in 2 columns in MVC application.

Description:
I am displaying list of all countries in MVC application one record per row but I want to display data in 2 columns. 2 records pre row.

Implementations:

Model

How to crop image using Iedit Jquery in MVC application

In this article I am going to explain how to crop image using Iedit Jquery and save to folder in MVC application.

Description:
In MVC application, want to add functionality to crop the image. When user’s uploading profile image, they can crop the uploaded image and it will be save to image folder. I am using IEdit Jquery plugin to crop the profile image. You can download the IEdit Jquery from here.

Implementation:
Add Controller:
Add an empty controller to project. Create action to upload profile pic.

Convert Image to Base64 string and Base64 string to Image in asp.net MVC application

In this article I am going to explain how to convert Image to Base64 string and Base64 string to Image in asp.net MVC application.

Description:
In MVC application want to convert Image to Base64 and Base64 encoded string to Image.

Implementation:
Add empty controller to project. Create method to convert Image and Base64 encoded string.

Complete code to Controller :

ASP.NET MVC : Crop image and save cropped image to folder

In this article I am going to explain how to crop image and save cropped image to folder in MVC using Jquery.

Description:
In MVC application, want to add functionality to crop the image. When user’s uploading profile image, they can crop the uploaded image and it will be save to image folder. I am using IEdit Jquery plugin to crop the profile image. You can download the IEdit Jquery from here.

Implementation:

Add Controller: