SQL Server PDO error: There are no more Rows in the active result set. Since this result set is not scrollable, no more data may be retrieved

Asked

Viewed 370 times

3

I’m trying to take records from one table and record in another of the same kind, but I’m having this error:

There are no more Rows in the active result set. Since this result set is not scrollable, no more data may be retrieved.

the code is as follows:

 $gameuser = $pdo->prepare('SELECT * FROM [omegashop].[dbo].[GameUser] WHERE [token] = :token');
  $gameuser->bindParam(':token', $token, PDO::PARAM_STR);
  $gameuser->execute();

  $result = $gameuser->fetchAll();
  foreach($result as $linha)
  {
      $usuario = $linha['userid'];
      $senha   = $linha['Passwd'];
      $remote  = 0;

      $query = $pdo->prepare("INSERT INTO [accountdb].[dbo].[".( strtoupper($usuario[0]) ) ."GameUser] ([userid],[Passwd],[GPCode],[RegistDay],[DisuseDay],[inuse],[Grade],[EventChk],[SelectChk],[BlockChk],[SpecialChk],[Credit],[DelChk],[Channel]) values( :usuario, :senha,'PTP-RUD001','12-12-2020','12-12-2020','0','U','0','0','0','0','0','0', :remote)");
      $query->bindParam(':usuario', $usuario, PDO::PARAM_STR);
      $query->bindParam(':senha', $senha, PDO::PARAM_STR);
      $query->bindParam(':remote', $remote, PDO::PARAM_STR);

      $query->execute();
  }`
  • Puts a $query->closeCursor(); after the $query->execute();

  • The statement must be executed before Results can be retrieved. @Edit opa diz o inverso vou tentar novo

  • still continues the error

  • understood the logic of this method, now I got it, thank you. could post the reply describing this method?

  • Add the instantiation of your $Pdo object I believe to be a few things in your preconfiguration but without this detail there is no way to be sure.

1 answer

4


One way to resolve this is to inform the server that the query/command has ended and no synchronization type is required. Call the method closeCursor() after the execute()

Your code should be:

$query->execute();
$query->closeCursor();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.