I have 2 tables in an Access database:
- tblMachine
- fields:
- MachineID
MachineDescription
tblProblem
- fields
- ProblemID
- MachineID
- ProblemDescription
I am trying to add a new record into tblProblem, using the MachineDescription to find the MachineID from tblMachine
However, my SQL statement throws an error on the sub-select statement
Here is my statement:
string sql = "INSERT INTO tblProblem" +
" ([MachineID], [ProblemDescription], [ProblemOrder])" +
" VALUES (" +
"(SELECT ([MachineID] FROM tblMachine WHERE MachineDescription = @MachineDescription))," +
" @ProblemDescription, @ProblemOrder);";
The problem being highlighted is this part:
"(SELECT ([MachineID] FROM tblMachine WHERE MachineDescription = @MachineDescription)),"
Have I done something wrong? It is telling me there is a syntax error...