locked
invalid stored procedure name - did not store anything RRS feed

  • Question

  • User379720387 posted

    I have two query strings: sqlClientsInitial and sqlClientsLater,. I want to use one of them depending on calresponse.Count returning zero or not.

    Visual Studio gives me an error on the last line:

    Invalid stored procedure name. [ Stored Proc Name = sqlClientsLater ]

    string sqlClientsSelected = "sqlClientsLater";
    
    var calresponses = db.Query("SELECT calRSId FROM calResponses WHERE ProviderId=@0 AND ownerLocationId=@1", providerid, barnorder[i]);
    
            if (calresponses.Count() == 0) { sqlClientsSelected = "sqlClientsInitial"; clientsinitial = true; } 
    
            var clientsbarn = db.Query(sqlClientsSelected, thisweekno, providerid, thisweekno - 5, barnorder[i]);

    I am thinking I am doing some string substitutions here, but VS sees something else.

    Any suggestions to improve this?

    TIA

    Robert

    Tuesday, December 16, 2014 9:54 PM

Answers

  • User-821857111 posted

    var sqlClientisInitial = SELECT * FROM Table plus some conditions..."

    var sqlClientsLater = "SELECT * FROM Table plus some other conditions...."

    Those the two query strings.

    But you aren't using either value.

    string sqlClientsSelected = "sqlClientsLater";

    Here, you set the value of sqlClientsSelected to a string that has the value "sqlClientsLater". That's not the same thing as assigning the value of the sqlClientsLater variable to sqlClientsSelected, which is what I suspect you intended to do:

    string sqlClientsSelected = sqlClientsLater;
    
    var calresponses = db.Query("SELECT calRSId FROM calResponses WHERE ProviderId=@0 AND ownerLocationId=@1", providerid, barnorder[i]);
    
            if (calresponses.Count() == 0) { sqlClientsSelected = sqlClientsInitial; clientsinitial = true; } 
    
            var clientsbarn = db.Query(sqlClientsSelected, thisweekno, providerid, thisweekno - 5, barnorder[i]);

    You just need to remove the quotes [but you know that ;0)]

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 17, 2014 8:39 AM
  • User-735851359 posted

    Hello,

    I do not understand your code, but your question is clear:

    var sqlClientisInitial = "SELECT * FROM Table plus some conditions..."
    var sqlClientsLater = "SELECT * FROM Table plus some other conditions...."
    var clientsbarn = "";
    var calresponses = db.Query("SELECT cal..."); if (calresponses.Count() == 0) { clientsbarn = db.Query(sqlClientisInitial) }else{ clientsbarn = db.Query(sqlClientsLater) }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 18, 2014 1:32 AM

All replies

  • User-821857111 posted

    According to the code you posted, your SQL statement consists of one word: "sqlClientsLater". The database assumes this is a stored procedure but can't find it.

    Wednesday, December 17, 2014 3:04 AM
  • User379720387 posted

    var sqlClientisInitial = SELECT * FROM Table plus some conditions..."

    var sqlClientsLater = "SELECT * FROM Table plus some other conditions...."

    Those the two query strings. Thought I was dealing with strings, but VS studio apparently thinks otherwise.

    How can this be made to work?

    Wednesday, December 17, 2014 8:17 AM
  • User-821857111 posted

    var sqlClientisInitial = SELECT * FROM Table plus some conditions..."

    var sqlClientsLater = "SELECT * FROM Table plus some other conditions...."

    Those the two query strings.

    But you aren't using either value.

    string sqlClientsSelected = "sqlClientsLater";

    Here, you set the value of sqlClientsSelected to a string that has the value "sqlClientsLater". That's not the same thing as assigning the value of the sqlClientsLater variable to sqlClientsSelected, which is what I suspect you intended to do:

    string sqlClientsSelected = sqlClientsLater;
    
    var calresponses = db.Query("SELECT calRSId FROM calResponses WHERE ProviderId=@0 AND ownerLocationId=@1", providerid, barnorder[i]);
    
            if (calresponses.Count() == 0) { sqlClientsSelected = sqlClientsInitial; clientsinitial = true; } 
    
            var clientsbarn = db.Query(sqlClientsSelected, thisweekno, providerid, thisweekno - 5, barnorder[i]);

    You just need to remove the quotes [but you know that ;0)]

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 17, 2014 8:39 AM
  • User-735851359 posted

    Hello,

    I do not understand your code, but your question is clear:

    var sqlClientisInitial = "SELECT * FROM Table plus some conditions..."
    var sqlClientsLater = "SELECT * FROM Table plus some other conditions...."
    var clientsbarn = "";
    var calresponses = db.Query("SELECT cal..."); if (calresponses.Count() == 0) { clientsbarn = db.Query(sqlClientisInitial) }else{ clientsbarn = db.Query(sqlClientsLater) }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 18, 2014 1:32 AM