i am create 3 tiar application in asp.net
my ValueObjectLayer is below
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ValueObjectLayer
{
public class clsEmployeeVO
{
public int intID { get; set; }
public string strName { get; set; }
public string strMobile { get; set; }
public string strEmail { get; set; }
public DateTime dtBirthDate { get; set; }
public string strCreatedBy { get; set; }
public DateTime dtCreatedDate { get; set; }
public string strUpdatedBy { get; set; }
public DateTime dtUpdatedDate { get; set; }
}
}
and my DataAccessLayer is
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using ValueObjectLayer;
namespace DataAccessLayer
{
public class clsEmployeeDAL
{
SqlCommand objCmd;
int intCount;
SqlDataReader sqlrd;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["strCon"].ConnectionString);
public int RegisterEmployeeDAL(clsEmployeeVO objEmployee)
{
try
{
if (con.State == ConnectionState.Closed)
{
con.Open();
}
objCmd = new SqlCommand();
objCmd.CommandText = "sp_insert_update_tblEmployee";
objCmd.Connection = con;
objCmd.Parameters.Clear();
objCmd.Parameters.AddWithValue("@intID", objEmployee.intID);
objCmd.Parameters.AddWithValue("@strName", objEmployee.strName);
objCmd.Parameters.AddWithValue("@strMobile", objEmployee.strMobile);
objCmd.Parameters.AddWithValue("@strEmail", objEmployee.strEmail);
objCmd.Parameters.AddWithValue("@dtBirthDate", objEmployee.dtBirthDate);
objCmd.Parameters.AddWithValue("@strCreatedBy", objEmployee.strCreatedBy);
objCmd.Parameters.AddWithValue("@strUpdatedBy", objEmployee.strUpdatedBy);
intCount = Convert.ToInt32(objCmd.ExecuteNonQuery());
if (con.State == ConnectionState.Open)
{
con.Close();
}
}
catch (Exception ex)
{
return intCount = 0;
}
return intCount;
}
}
}
and my BussinessAccessLayer is
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccessLayer;
using ValueObjectLayer;
namespace BussinessAccessLayer
{
public class clsEmployeeBAL
{
public int RegisterEmployeeDAL(clsEmployeeVO objEmployee)
{
clsEmployeeDAL objDAL = new clsEmployeeDAL();
return objDAL.RegisterEmployeeDAL(objEmployee);
}
}
}
and my store procuder is
USE [dbDemo]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_insert_update_tblEmployee]
@intID int,
@strName nvarchar(50),
@strMobile nvarchar(50),
@strEmail nvarchar(50),
@dtBirthDate nvarchar(50),
@strCreatedBy nvarchar(50),
@strUpdatedBy nvarchar(50),
@intCount int output
AS
BEGIN TRANSACTION COMPILE_ALL
BEGIN try
if(not exists (select intID from tblEmployee where intID=@intID))
begin
insert into tblEmployee (strName,strMobile,strEmail,dtBirthDate,strCreatedBy,dtCreatedDate,strUpdatedBy,dtUpdatedDate)values
(@strName,@strMobile,@strEmail,@dtBirthDate,@strCreatedBy,GETDATE(),@strUpdatedBy,GETDATE())
end
else
begin
update tblEmployee set strName=@strName,strMobile=@strMobile,strEmail=@strEmail,dtBirthDate=@dtBirthDate,
strUpdatedBy=@strUpdatedBy,dtUpdatedDate=GETDATE() where intID=@intID
end
COMMIT TRANSACTION COMPILE_ALL
set @intCount = 1
END try
BEGIN CATCH
ROLLBACK TRANSACTION COMPILE_ALL
set @intCount = 0
END CATCH
and my save button code is
protected void Button1_Click(object sender, EventArgs e)
{
clsEmployeeBAL objBAL = new clsEmployeeBAL();
clsEmployeeVO objVO = new clsEmployeeVO();
objVO.intID = 0;
objVO.strName = txtName.Text;
objVO.strMobile = txtMobile.Text;
objVO.strEmail = txtEmail.Text;
objVO.dtBirthDate = Convert.ToDateTime(txtBirthDate.Text);
objVO.strCreatedBy = "Admin";
objVO.strUpdatedBy = "";
objBAL.RegisterEmployeeDAL(objVO);
ClearAll();
}
i got an error "Procedure or function 'sp_insert_update_tblEmployee' expects parameter '@intID', which was not supplied."