I had try to delete a row in a table using the following code, but I got an error.
{System.Data.OleDb.OleDbException: Missing ), ], or Item in query expression
'[CompanyID] not in (Select [CompanyID] from EmployeeDetails
where [CompanyID] = @cmpID'.
Here is my code:
int companyID = _cmpDetailsList[i].CompanyID;
OleDbCommand upcmd = new OleDbCommand(
"delete * from CompanyDetails where [CompanyID] not in " +
"(Select [CompanyID] from EmployeeDetails where [CompanyID] = @cmpID", conn);
conn.Open();
upcmd.Parameters.AddWithValue("@cmpID", companyID);
upcmd.ExecuteNonQuery();
conn.Close();
i modified the command to in this format
OleDbCommand upcmd = new OleDbCommand("delete * from CompanyDetails where [CompanyID]= @cmpID and not in (Select [CompanyID] from EmployeeDetails where [CompanyID] = @cmpID)", conn);
i got the following error
System.Data.OleDb.OleDbException: Syntax error (missing operator) in query expression '[CompanyID]= @cmpID and not in (Select [CompanyID] from EmployeeDetails where [CompanyID] = @cmpID)'.
please solve it
If you read the error, it tells you the problem:
OleDbCommand upcmd = new OleDbCommand(
"delete from CompanyDetails where [CompanyID] not in " +
"(Select [CompanyID] from EmployeeDetails where [CompanyID] = @cmpID)", conn);
You had a (
but no matching )
at the end.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.