I need to search by using some keywords like experience,Job Location etc,I wrote code but something was going wrong and I can't able to able to find out where I did mistake,Can any one help for this??? Here I'll explain my code
Stored Procedure:
Create Procedure USP_Search
@query varchar(1000)
as
begin
exec(@query)
end
In DAL:
public DataSet GetJobDetails(string PositionTitle, string JobLocation)
{
try
{
SqlConnection con = dbcon.OpenCoonection();
SqlCommand cmd = new SqlCommand("USP_GetJobsearchDetails", con);
string query = "select distinct r.PositionTitle,r.RequirementID,r.Experience,r.JobLocation from Tbl_RequirementModule r ";
if (PositionTitle != "")
{
query = query + " where r.PositionTitle LIKE '%" + PositionTitle + "%'";
}
if (JobLocation != "" && JobLocation="0") // Location is dropdown
{
query = query + " where r.JobLocation LIKE '%" + JobLocation + "%"
}
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@query", query);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
DataTable dt = new DataTable();
da.Fill(ds);
return ds;
}
catch
{
throw;
}
finally
{
dbcon.CloseConnection();
}
}
In .CS:
protected void btnView_Click(object sender, EventArgs e)
{
string PositionTitle = txtkeyword.Text;
string JobLocation = txtjobcity.Text;
objjobBAL.GetJobDetails(PositionTitle, JobLocation);
GetData();
}