• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help with SqlServer Store Procedure

#1
I have a store procedure in Sql server2012. 
It has 1 parameter (dni)
when I try to call, if I dont write the parameter , the error say "the SP was waiting a parameter.
PHP Code:
public function llama_sp()
    {
      //  $query = $this->db->get('Personas');

        $dni'22555666';
      $this->db->trans_start();
     
      $query 
$this->db->query('execute SP_Alumnos_Mostrar');
      $this->db->trans_complete();
        return $query->result();
    
I receive this error: 

A Database Error Occurred
Error Number: 42000/201
[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]El procedimiento o la función 'SP_Alumnos_Mostrar' esperaba el parámetro '@dni', que no se ha especificado.
execute SP_Alumnos_Mostrar
Filename: C:/xampp/htdocs/CodeIgniter3/system/database/DB_driver.php
Line Number: 691


If I write the parameter: 

PHP Code:
$query $this->db->query('execute SP_Alumnos_Mostrar($dni)'); 

I receive this error: 

A Database Error Occurred
Error Number: 42000/102
[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Sintaxis incorrecta cerca de '$dni'.
execute SP_Alumnos_Mostrar($dni)
Filename: C:/xampp/htdocs/CodeIgniter3/system/database/DB_driver.php
Line Number: 691


I cant resolve. Please if somebody can help me.....
PD: sorry for my english 
Pablo
Reply

#2
Well, I don't anything about mssql, however, when you use single quotes, instead of double quotes, php variable names don't get parsed, and thus the value of $dni doesn't get passed ( assuming it's being determined by php and not some special mssql key phrase )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.