locked
Parsing error on a db.Execute - RRS feed

  • Question

  • User483055775 posted

    sql reports a parsing error on this - Could I get another set of eyes on it - my four cant see anything wrong.

    DonnieS

     

        var deleteCommand = "DELETE FROM FP_BudgetDetails ON FP_BudgetDetails.BudCatSysID = FP_BudgetCategory.BudgetCatSysID WHERE FP_BudgetCategory.BudgetMasterSysID = @0";
            db.Execute(deleteCommand, BudgetMasterSysID);
    
    Tuesday, May 21, 2013 8:43 PM

Answers

  • User-821857111 posted

    Santosh, the command you wrote doesnt handle the last piece of the statement that I listed below: 

    WHERE FP_BudgetCategory.BudgetMasterSysID = @0";

    Add it on:

    "DELETE FROM FP_BudgetDetails JOIN  FP_BudgetCategory ON FP_BudgetDetails.BudCatSysID = FP_BudgetCategory.BudgetCatSysID WHERE FP_BudgetCategory.BudgetMasterSysID = @0";

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 22, 2013 12:31 AM

All replies

  • User-1469158370 posted

    There is no join You ha

    DELETE FP_BudgetDetails FROM
    FP_BudgetDetails 
    JOIN 
    FP_BudgetCategory
    ON FP_BudgetDetails.BudCatSysID = FP_BudgetCategory.BudgetCatSysID WHERE FP_BudgetCategory.BudgetMasterSysID = @0";
            db.Execute(deleteCommand, BudgetMasterSysID);

    ven't joined with FP_BudgetCategory table. You need to fix that.

    Tuesday, May 21, 2013 10:31 PM
  • User1849925139 posted

    Hi,

    Your T-SQL statement should be like below:

    var deleteCommand = "DELETE FROM FP_BudgetDetails JOIN  FP_BudgetCategory ON FP_BudgetDetails.BudCatSysID = FP_BudgetCategory.BudgetCatSysID

     You have missed the JOIN.

    However it's an best practice to white the T-SQL statemets in "Stored Procedure".

    Thanks,

    /Sanrosh G

    Tuesday, May 21, 2013 11:06 PM
  • User483055775 posted

    Santosh, the command you wrote doesnt handle the last piece of the statement that I listed below: 

     

    WHERE FP_BudgetCategory.BudgetMasterSysID = @0";

    Tuesday, May 21, 2013 11:44 PM
  • User483055775 posted

    Suneeld,  I dont understand your statement, "there is no join"  - do you mean I have not related the two tables? 

    Tuesday, May 21, 2013 11:46 PM
  • User-821857111 posted

    Santosh, the command you wrote doesnt handle the last piece of the statement that I listed below: 

    WHERE FP_BudgetCategory.BudgetMasterSysID = @0";

    Add it on:

    "DELETE FROM FP_BudgetDetails JOIN  FP_BudgetCategory ON FP_BudgetDetails.BudCatSysID = FP_BudgetCategory.BudgetCatSysID WHERE FP_BudgetCategory.BudgetMasterSysID = @0";

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 22, 2013 12:31 AM
  • User-1469158370 posted

    Yeah..that's what i meant

    Friday, May 24, 2013 10:53 AM
  • User483055775 posted

    Thanks so much all of you.  I much prefer to work in a telecommute mode - mostly because I dont like being confined by 8-5 or 6-2:30 schedule. If something needs to be worked on - you work, as long as it takes.  And having all of you to converse with - really is great , its like a large virtual water cooler to hang around and talk over issues.  Thanks to all of you.

     

    DonnieS

    Friday, May 24, 2013 11:12 AM