Jump to content

Chris87

New Members
  • Posts

    4
  • Joined

  • Last visited

Chris87's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Got it! - with the help of this article... https://stackoverflow.com/questions/16735898/the-active-result-contains-no-fields-using-pdo-with-ms-sql In the query - nocount had to be enabled (e.g. $DBH2->query("SET NOCOUNT ON; EXEC pEmplo...............") --- thats a bit of a strange one, because I had already enabled nocount against the database handler like this... $DBH2->query("SET NOCOUNT ON"); - but regardless of that, it had to be in the query statement itself. I now get data! There is still a minor annoyance; If i make the parameters dynamic and un-comment the bindparam line as you can see in my example, it resorts to failing again. the variables are not user inputs and are safe to hard code, so that's what i've gone with for now but i'm still not happy with accepting that.... my next challenge - if anyone has any thoughts please let me know Thanks for your help
  2. Just tried that - The active result for the query contains no fields. I'm ready to throw my laptop - this is one of those! Not having much luck inserting into another table either..!
  3. Thanks for the reply - I've tried using call from SSMS and it doesnt like that, so I think it needs to remain as 'exec'... i've also tried to capture the result like you have - removing the loop and having a single record..: $STHA->execute(); $result = $STHA->fetch(); var_dump($result); But still no luck - it seems to throw an error at $STHA->fetch(); and again it's reporting no data returned.... but there is most definitely data returned from the query! Since it appears to run the query and just simply doesn't return a result, i'm going to try and update another table from within the SP, and then run a separate query to simply read a table - I have no idea if it will work but I'm running short of ideas
  4. Hi All, I'm hitting brick walls while trying to run a stored procedure query with PDO (linking to MSSQL) If I run the query from SSMS (SQL Server Management Studio) I get a result every time (one single row is returned, as expected) - I'm placing the same query into PHP without any dynamic variables etc - its just a straight query... when it runs the query in PDO it fails every time with this error: PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[IMSSP]: The active result for the query contains no fields.' in index.php:195 Stack trace: #0 index.php(195): PDOStatement->fetch(2) #1 {main} thrown in index.php on line 195 The code is as follows: $SQLSTMTA="exec pEmployeeGetData @EmployeeID='1',@Year='2020'"; $STHA = $DBH2->prepare($SQLSTMTA); //$STH->bindParam(':EMPID', $EmployeeID); $STHA->execute(); while($result = $STHA->fetchAll()) { //(row 195) var_dump($result); } I've also tried a few variations on the above such as ->Fetch (as opposed to FetchAll) without any luck. Any ideas on how I can get around this? Thanks in Advance!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.