Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1073465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:59:46+00:00 2026-05-16T20:59:46+00:00

I’m using the SQL Server Driver for PHP to connect to an SQL Server

  • 0

I’m using the SQL Server Driver for PHP to connect to an SQL Server 2008 Express. Right now, I’m trying to replace all SELECT, UPDATE and INSERT statements by stored procedures. This is working fine for SPs that just contain a SELECT statement. But now I tried to do one with an update, and I keep getting the error message “Executing SQL directly; no cursor.”. I can call the SP fine from Management Studio with the same parameter values.

Any ideas?

Cheers
Alex

EDIT: here’s one update procedure. The funny part is, the procedure is actually executed fine and updates the data like it’s supposed to. But it still returns an error, resulting in an exception.

First, the PHP code that fails:

if (! $this->Result = sqlsrv_query($this->Conn, $strQuery, $arrParameters, array("Scrollable"=>SQLSRV_CURSOR_STATIC)))
{
    $this->sendErrorMail($strQuery, $arrParameters);
    throw new Exception(4001);
}

SQL

USE [testsite]  
GO  
/****** Object:  StoredProcedure [dbo].[Items_countDownload]    Script Date: 09/09/2010 18:03:28 ******/  
SET ANSI_NULLS ON  
GO  
SET QUOTED_IDENTIFIER ON  
GO  
-- =============================================  
-- Author:      Alexis Hildebrandt  
-- Create date: 2010-09-09  
-- Description: Increases the download count by 1  
-- =============================================  
ALTER PROCEDURE [dbo].[Items_countDownload]  
    @Id INT  
AS  
BEGIN  
    -- SET NOCOUNT ON added to prevent extra result sets from  
    -- interfering with SELECT statements.  
    SET NOCOUNT ON;  

    DECLARE @DownloadCount INT = 0, @MaxCount INT = 0, @Id2 INT = 0  

    DECLARE itemCursor CURSOR SCROLL
    FOR
        SELECT Id, Downloads
        FROM Items
        WHERE Id = @Id
        OR SKU IN 
        (
            SELECT SKU FROM Items WHERE Id = @Id
        )
    FOR UPDATE OF Downloads

    OPEN itemCursor

    FETCH NEXT FROM itemCursor
    INTO @Id, @DownloadCount;

    -- Find the largest Download count across all versions of the item
    WHILE @@FETCH_STATUS = 0
    BEGIN
        IF @MaxCount < @DownloadCount
            SET @MaxCount = @DownloadCount;
        FETCH NEXT FROM itemCursor
        INTO @Id, @DownloadCount;
    END

    -- Increase the download count by one for all versions
    FETCH FIRST FROM itemCursor
    INTO @Id, @DownloadCount;
    WHILE @@FETCH_STATUS = 0
    BEGIN
        UPDATE Items 
        SET Downloads = @MaxCount + 1
        WHERE CURRENT OF itemCursor
        FETCH NEXT FROM itemCursor
        INTO @Id, @DownloadCount;
    END

    CLOSE itemCursor;
    DEALLOCATE itemCursor;
END
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:59:46+00:00Added an answer on May 16, 2026 at 8:59 pm

    Try removing "Scrollable"=>SQLSRV_CURSOR_STATIC option from the call. The procedure you’re calling doesn’t return any open cursors to PHP code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I'm trying to select an H1 element which is the second-child in its group
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.