i'm using 3 tier architecture for web development. I need to parametrize the query which i'm unable to. please help me out.
this is my Business class (BAL)
public static DataTable InsertFamDetails(int EmpId,string DependentName,string Relation,string DOB)
{
DataTable dt = new DataTable();
string q = string.Format("INSERT INTO Dependants_Master(emp_id, dependent_name, relation, dob) VALUES('{0}','{1}','{2}','{3}')",EmpId,DependentName,Relation,DOB);
dt = HRMSDAL.select(q);
return dt;
}
and this is my asps.cs page
protected void AddFamDetails_Click(object sender, EventArgs e)
{
EmpId = int.Parse(Session["EmpId"].ToString());
string Name, Relation, DOB;
Name = txtFamName.Text;
Relation = ddlRelation.SelectedItem.Text;
DOB = txtDepDob.Text;
try
{
EmpBAL.InsertFamDetails(EmpId, Name, Relation, DOB);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}