title: QODBCResult::exec: Unable to execute statement: "[Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error
body: <p>I get this error when I try to call stored procedure in QT using QODBC:</p>
  <blockquote>
  <p>QODBCResult::exec: Unable to execute statement: &quot;[Microsoft][ODBC SQL
  Server Driver]COUNT field incorrect or syntax error</p>
  </blockquote>
  <p>Amount of parameters is correct, syntax looks alright to me. The procedure executes fine in Management Studio. What might be the problem?</p>
  <pre><code>QSqlQuery query(db1);
  query.exec(&quot;SELECT * from Teachers&quot;); //test query
  TableWidget *table = ui-&gt;tableWidget;
  for (int i = 0; i &lt; table-&gt;rowCount(); i++)
  {    
      QComboBox *combo = static_cast&lt;QComboBox*&gt;(table-&gt;cellWidget(i,0));
      qDebug() &lt;&lt; query.prepare(&quot;{CALL add_syllabus_line (?,?,?,?,?,?,?,?,?)}&quot;);
      query.bindValue(&quot;teacher_name&quot;, teacherName);
      query.bindValue(&quot;subject_name&quot;, &quot;????&quot;);
      query.bindValue(&quot;temporary_name&quot;, ratingName);
      query.bindValue(&quot;type_name&quot;, combo-&gt;currentText());
      query.bindValue(&quot;activity_name&quot;, table-&gt;item(i, 1)-&gt;text());
      query.bindValue(&quot;min_score&quot;, table-&gt;item(i, 2)-&gt;text().toInt());
      if (propertiesInstance.fixed) query.bindValue(&quot;max_score&quot;, 0);
      else query.bindValue(&quot;max_score&quot;, table-&gt;item(i, 3)-&gt;text().toInt());
      query.bindValue(&quot;max_score_exists&quot;, propertiesInstance.fixed);
      query.bindValue(&quot;evaluation_by_exam&quot;, propertiesInstance.exam);
  
      if (!query.exec())
      {
         qDebug() &lt;&lt; query.lastError();
      }
  }
  </code></pre>
  <p>The procedure:</p>
  <pre><code>ALTER PROCEDURE [dbo].[add_syllabus_line] 
  
  @teacher_name NVARCHAR(50),
  @subject_name NVARCHAR(50),
  @temporary_name NVARCHAR(50),
  @type_name NVARCHAR(50),
  @activity_name NVARCHAR(50),
  @min_score int,
  @max_score int,
  @max_score_exists bit,
  @evaluation_by_exam bit
  
  AS
  BEGIN
  SET NOCOUNT ON;
  
  DECLARE @teacher_id int;
  DECLARE @subject_id int; 
  DECLARE @type_id int; 
  
  SELECT @teacher_id = Teacher_id FROM Teachers WHERE Teacher_name = @teacher_name;
  SELECT @type_id = Activity_type_id FROM Activity_types WHERE Activity_type_name = @type_name;
  SELECT @subject_id = subject_id FROM Subjects WHERE Subject_name = @subject_name;
  
  INSERT INTO Syllabi (Teacher_id, 
                      Subject_id, 
                      Temporary_name,
                      Activity_type_id,
                      Activity_title,
                      Activity_min_score,
                      Activity_max_score,
                      Max_score_exists,
                      Evaluation_by_exam) VALUES (@teacher_id,
                                                  @subject_id,
                                                  @temporary_name,
                                                  @type_id,
                                                  @activity_name,
                                                  @min_score,
                                                  @max_score,
                                                  @max_score_exists,
                                                  @evaluation_by_exam);
  END
  </code></pre>
  <p><code>query.prepare</code> returns true.</p>
  <p>I run a profiler trace and the query doesn't even shows there, only the test one.</p>
  <blockquote>
  <p>select 504,c.name,c.description,c.definition from
  master.dbo.syscharsets c where c.id = convert(tinyint,
  databasepropertyex ( db_name() , 'sqlcharset')) go</p>
  <p>exec sp_datatype_info 11 go</p>
  <p>SET QUOTED_IDENTIFIER ON
  go</p>
  <p>declare @p1 int
  set @p1=180150003<br />
  declare @p3 int<br />
  set @p3=8
  declare @p4 int
  set @p4=1
  declare @p5 int
  set @p5=3
  exec sp_cursoropen @p1
  output,N'SELECT * from Teachers',@p3 output,@p4 output,@p5 output
  select @p1, @p3, @p4, @p5</p>
  <p>exec sp_cursorclose 180150003 go</p>
  </blockquote>