Thumb

Part-15: Insert & Get data using store procedure in SQL Server ASP.NET MVC AngularJS JQUERY

Part-04: Bootstrap Admin Dashboard Template setup in School Management Software Part 5: How to use AngularJS in ASP.NET MVC Part-6: CRUD Operation Insert Data using AngularJS in ASP.NET MVC Part-7: CRUD Operation & Load Data using AngularJS in ASP.NET MVC Part-08: CRUD Operation Edit, Delete Data using Angularjs in ASP.NET MVC Part-3: Create Database and Table in sql server for school management system Part-09: Insert Section data using ASP.NET MVC AngularJs Part-10: Edit Update and Delete Section data using Angular js | ASP.NET MVC | Jquery Part-11: Cascading Dropdownlist Section Batch selection in asp.net MVC JQUERY AngularJS Part-12: Insert & Delete course information for school management software using ASP.NET MVC Javascript Angularjs Part-13: Create Update course info in ASP.NET MVC AngularJs JQUERY Javascript Part-14: Insert data and Page design bootstrap using ASP.NET MVC JQUERY AngularJS Part-15: Insert & Get data using store procedure in SQL Server ASP.NET MVC AngularJS JQUERY Part-16: Load student list,bootstrap and Inactive using ASP.NET MVC AngularJS Jquery Part-17: User authentication using Store procedure Javascript AngularJS JQUERY ASP.NET MVC Part-18: User authentication, authorization and login using ASP.NET MVC AngularJS Javascript JQUERY Part-19: User Registration & Insert semester Info using AngularJS in ASP.NET MVC Part-20: Load semester info & Student course offer page design using ASP.NET MVC JQUERY Angularjs Part-21: Course Offer Entry Using Jquery Multiple Data Save (Part-1) using ASP.NET MVC AngularJS SMS-22: Student Course Offer Entry happens Using Jquery Multiple Data Save List view dropdownlist Load using Angular js in ASP.NET MVC SMS-23: Student course offer list semester search using ASP.NET MVC AngularJS JQUERY SMS-24: Student Marks Entry page in table column input marks entry using Jquery & Angular js in ASP.NET MVC SMS-25: Student Course Mark multiple data save using jquery with Stored Procedure & Angular js in ASP.NET MVC SMS-26: Student Marks list show by search student name and trimester Jquery & Angular js in ASP.NET MVC SMS-27: Student profile create and browse profile using Store procedure AngularJS Jquery ASP.NET SMS-28: Student Result show by search trimester and myasp server registration and login using Jquery & Angular js in ASP.NET MVC

11/8/2021 10:51:41 AM

In this post, you will Insert & Load using store procedure SQL Server ASP.NET MVC Angularjs Jquery.Here will cover passing parameter in store procedure and writing the store procedure for insert and load data through parameter.

Steps:

Step-1:

  • Create store Procedure for Insert Student information.
  • Go to SQL Server 2014 > dbStudentMangeSystem database> Programmability> stored procedures> Select New> stored procedure>Create sp_Insert_Student with writing the below code.
ALTER PROCEDURE [dbo].[sp_Insert_Student]
	-- Add the parameters for the stored procedure here
	 @StudentName nvarchar(max)=null ,
	 
	 @BatchId int=null ,
	 @SectionId int=null ,
	 @DOB datetime=null ,
	 @Gender nvarchar(max)=null ,
	 @Religion nvarchar(max)=null ,
	 @FatherName nvarchar(max)=null ,
	 @MotherName nvarchar(max)=null ,
	 @PresentAddrees nvarchar(max)=null ,


	 @PermanentAddress nvarchar(max)=null ,
	 @AddmittedDate datetime=null ,
	 @Status bit=null ,
	 @StudentIdNO nvarchar(max)=null 	 
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	INSERT INTO [dbo].[tblStudent]
           ( StudentName, [BatchId]
           ,[SectionId]
           ,[DOB]
           ,[Gender]
           ,[Religion]
           ,[FatherName]
           ,[MotherName]
           ,[PresentAddrees]
           ,[PermanentAddress]
           ,[AddmittedDate]
           ,[Status],StudentIdNO)
     VALUES
            (@StudentName,@BatchId,@SectionId,@DOB,@Gender,@Religion,@FatherName,@MotherName,@PresentAddrees,@PermanentAddress,@AddmittedDate,
			@Status,@StudentIdNO)

			declare @MaxStudentId int 

	 select	@MaxStudentId= MAX(StudentId) from tblStudent 
	 	declare @Bat int 
	 select @Bat= BatchId from tblStudent  where StudentId=@MaxStudentId
	 


	 	declare @BatName nvarchar(max) 
	 select @BatName= BatchName from tblBatch  where BatchId=@Bat
	   declare @StuIDNO nvarchar(max)
	   select @StuIDNO=   ISNULL(MAX(ISNULL(StudentIdNO,0)),0)+1   from tblStudent 
	   
	   where StudentId=@MaxStudentId and BatchId=@Bat
	  

	  insert into tblUser ([UserName]
           ,[LoginName]
           ,[Password]
           ,[UserType]
           ,[StudentId],ActiveStatus)
		   values(
		   @StudentName,
		  @BatName+ @StuIDNO,
		  @BatName+ @StuIDNO,
		   'Student',
		   @MaxStudentId,1
		   )
	   update tblStudent set StudentIdNO=@StuIDNO where  StudentId=@MaxStudentId
	 END


Step-2:

  • Get Student Id No add Dataset GetStudentIdNODAL()   in  StudentDAL.cs class.
  • Go to Solution Explorer > DAL Folder> StudentDAL.cs>  in this Class with writing the below code.
        public DataSet GetStudentIdNODAL()
        {
            SqlCommand com = new SqlCommand("sp_GetStudentIDNo", conn);
            com.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(com);
            DataSet dss = new DataSet();
            da.Fill(dss);
            return dss;
        }

Step-3:

  • Create store Procedure for Insert Student information.
  • Go to SQL Server 2014 > dbStudentMangeSystem database> Programmability> stored procedures> Select New> stored procedure>Create sp_GetStudentIDNo with writing the below code.
create  proc [dbo].[sp_GetStudentIDNo]
as
begin


declare @MaxID int 
select @MaxID= MAX(StudentId) from  tblStudent 

select b.BatchName+  StudentIdNO as StudentIdNO from tblStudent s 
left join tblBatch b on b.BatchId=s.BatchId

 where StudentId=@MaxID

end

Step-4: Run Application.

About Teacher

Reza Karim

Software Engineer

More about him