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

3

I'm trying to get records from a table and write to another of the same type, 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();
  }'
    
asked by anonymous 27.04.2017 / 17:15

1 answer

4

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

Your code should stay:

$query->execute();
$query->closeCursor();
    
27.04.2017 / 19:12