Presentation Layer Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using DAL;
namespace _3_tiersample
{
public partial class RegistrationForm : System.Web.UI.Page
{
classBLL Objbal = new classBLL();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
string Output = string.Empty;
classBLL Objbalregistration = new classBLL();
Objbalregistration.Name = TextBox1.Text;
Objbalregistration.Roll_Number = Convert.ToInt32(TextBox2.Text);
Objbalregistration.Email_Id = TextBox3.Text;
Objbalregistration.Mobile_Number = TextBox4.Text;
Objbalregistration.InsertUserDetails(Objbal);//here Iam getting the above error please help me out
Console.WriteLine("Data Inserted");
}
catch(Exception Ex)
{
Console.WriteLine(Ex);
}
}
}
}
Data Access Layer;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using BLL;
namespace DAL
{
public class classDAL
{
string connection = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
public void InsertUserDetails(classBLL Objbal)
{
SqlConnection con = new SqlConnection(connection);
SqlCommand cmd = new SqlCommand("sp_InsertEmpdetails", con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
try
{
cmd.Parameters.AddWithValue("@Name", Objbal.Name);
cmd.Parameters.AddWithValue("@Roll_Number", Objbal.Roll_Number);
cmd.Parameters.AddWithValue("@Email_Id", Objbal.Email_Id);
cmd.Parameters.AddWithValue("@Mobile_Number", Objbal.Mobile_Number);
Console.WriteLine( "data saved");
}
catch (Exception Ex)
{
Console.WriteLine(Ex);
}
finally
{
con.Dispose();
}
}
}
}
Business Logic Layer Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
namespace BLL
{
public class classBLL
{
private string _Name;
private int _Roll_Number;
private string _Email_Id;
public string _Mobile_Number;
public string Name
{
set { _Name = value; }
get { return _Name; }
}
public int Roll_Number
{
set { _Roll_Number = value; }
get { return _Roll_Number; }
}
public string Email_Id
{
set { _Email_Id = value; }
get { return _Email_Id; }
}
public string Mobile_Number
{
set { _Mobile_Number = value; }
get { return _Mobile_Number; }
}
}
}
Thanks In Advance