nallya

nallya

  • NA
  • 459
  • 474.1k

How to pass object of a class to stored procedure(in oracle)?

Sep 13 2012 9:19 AM
How to pass object of a class to stored procedure(in oracle)?

class:
public class clsPayrollEmployee
  {
  string _firstname;
  string _lastname;
  string _contactno;
  string _email;
  string _address;
  public string firstname{
  get { return _firstname; }
  set { _firstname = value; }
  }
  public string lastname{
  get { return _lastname; }
  set { _lastname = value; }
  }
  public string contactno{
  get { return _contactno; }
  set { _contactno = value; }
  }
  public string email{
  get { return _email; }
  set { _email = value; }
  }
  public string address{
  get { return _address; }
  set { _address = value; }
  }
  }

Stored Procedure(oracle):
CREATE OR REPLACE procedure Payroll_Employee_Insert(firstname_ varchar2,lastname_ varchar2,contactno_ varchar2,email_ varchar2,address_ varchar2)
is
begin
insert into payroll_employee(firstname,lastname,contactno,email,address) values(firstname_,lastname_,contactno_,email_,address_);
end;
/

Insert Button Code:
protected void btnadd_Click(object sender, EventArgs e)
  {
  Entity ent = new Entity();
  PAYROLL_EMPLOYEE emp = new PAYROLL_EMPLOYEE();
  clsPayrollEmployee clsobj = new clsPayrollEmployee();
  clsobj.firstname = txtfirstname.Text;
  clsobj.lastname = txtlastname.Text;
  clsobj.contactno = txtcontactno.Text;
  clsobj.email = txtemailid.Text;
  clsobj.address = txtaddress.Text;
 
  ent.Insert_Emp(clsobj.firstname,clsobj.lastname,clsobj.contactno,clsobj.email,clsobj.address);
  ent.SaveChanges();
  }

instead of parameter of object i want to pass whole object to stored procedure