I have 2 tables, what I am looking for is:
JobApplic
table contains:
ApplicNum,
JobNum,
UID "this is the employer",
Jobtitle,
AplicUID " this is job seeker"
CVs
table contains:
CVNum,
UID (here in this table is the job seeker) ,
FN,
LN,
etc....
The statement it something like that but I am not so professional to write in the correct way:
select
from [JobApplic] ApplicNum, JobNum, UID, Jobtitle, AplicUID
where
UID
into table JobApplic = session["UsrNme"],
inner join table [CVs] UID,FN, LN, ...
Where UID into table CVs = ApplicUID into table JobApplic"
The mean point from this code is when employer enter to his account he will be able to see all applicant CV's whose applied for jobs which posted by the employer.
protected void ViewapplCV_Click(object sender, EventArgs e)
{
if (Session["UsrNme"] != null)
{
using (SqlConnection AppCVsSQLCon = new SqlConnection(sc))
{
AppCVsSQLCon.Open();
SqlDataAdapter ApplCVsDAADP = new SqlDataAdapter(@"
SELECT AD.[ApplicNum], AD.[JobNum], AD.[UID], AD.[Jobtitle],
AD.[AplicUID], UI.[UID], UI.[FN], UI.[LN]
FROM [JobApplic] AS AD JOIN CVs AS UI ON AD.[UID] = UI.[UID]
WHERE AD.UID = @UID AND AD.AplicUID = UI.UID", sc);
var use = Session["UsrNme"];
ApplCVsDAADP.SelectCommand.Parameters.AddWithValue("@UID", use);
DataSet dsApplCVs = new DataSet();
ApplCVsDAADP.Fill(dsApplCVs);
showapplicforemployrLV.DataSource = dsApplCVs.Tables[0];
showapplicforemployrLV.DataBind();
}
}
else
{
// Your Session key could not be found, consider displaying an error
}
MultiView1.ActiveViewIndex = 12;
}
If I understand correctly the relationship between these tables then the query should be
SqlDataAdapter ApplCVsDAADP = new SqlDataAdapter(@"
SELECT AD.[ApplicNum],AD.[JobNum],AD.[UID],AD.[Jobtitle],
AD.[AplicUID],UI.[UID],UI.[FN],UI.[LN]
FROM [JobApplic] as AD JOIN CVs as UI ON AD.[AplicUID] = UI.[UID]
WHERE AD.UID = @UID", sc);
You say that the in the first table AplicUID "this is job seeker" and in the second table the UID
(here in this table is the job seeker) so you need to make a join between these two fields and there is no need to repeat the relationship again in the WHERE clause
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments