I'm using MS Access 2003 to generate the DataSource of a DataGridView, when I launch the program, it throws :
"Syntax error (no operator) in expression " k.Ka = p1.Id
INNER JOIN Person AS p2 ON k.Kc1 = p2.Id
INNER JOIN Person AS p3 ON k.Kc3 = p3.Id "
My code :
try
{
using (OleDbConnection conn = new OleDbConnection(connecString))
{
conn.Open();
OleDbCommand cmd = new OleDbCommand(@"Select k.[Desc],k.Family,k.Num,p1.Name
AS KeyAdmin, p2.Name AS KeyCustodian1, p3.Name AS KeyCustodian3,p4.Name
AS SecurityOfficer,p5.Name AS ServiceIT
FROM KC AS k
INNER JOIN Person AS p1 ON k.Ka = p1.Id
INNER JOIN Person AS p2 ON k.Kc1 = p2.Id
INNER JOIN Person AS p3 ON k.Kc3 = p3.Id
INNER JOIN Person AS p4 ON k.So = p4.Id
INNER JOIN Person AS p5 ON k.It = p5.Id
WHERE k.Num = @Num;", conn);
OleDbDataAdapter adapt = new OleDbDataAdapter(cmd);
cmd.Parameters.AddWithValue("@num", form.comboKC.SelectedValue);
DataTable dt = new DataTable();
adapt.Fill(dt);
form.dataGridView1.DataSource = dt;
conn.Close();
}
I'm a student and I can't see my error and that's I use it most of the time, neither can my supervisor so... Here I am ! Thanks for your time,
ON (k.Ka = p1.Id)for all your joins.form.comboKC.SelectedValuereturning a valid value for you to select on?