1

I seem to be having great difficulty in executing a ms sql server stored procedure that contains parameters, I am able to execute either simple select statements or stored procedures without parameters but as soon as I try to bind parameters i get the message :

"An error occured: SQLSTATE[HY000]: General error: 102 General SQL Server error: Check messages from the SQL Server [102] (severity 15) [(null)]"

code from php is:

    $pdo = new PDO($dsn, $user, $password);

    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    try {
    $sql = $pdo->prepare("EXEC [contractor].[sync_licence] (?)");
    $params = 5;
    $sql->bindParam(1, $params, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 4000);
    $sql->execute();
    $results = $sql->fetchAll();
    var_dump($results);
    } catch (PDOException $e) {
    echo 'An error occured: ' . $e->getMessage();
    }

Can anybody help with where I am going wrong?

2
  • have you checked your prepared statement ... Commented Dec 22, 2013 at 7:23
  • how do you mean checked the prepared statement Christopher? my apologies if this is obvious but i am a little new to pdo. Thanks Commented Dec 22, 2013 at 10:56

1 Answer 1

2

For anybody interested I have found the issue with the above statement. The error message returned was basically pointing towards a syntax issue with the t-sql statement, in this case the problem was the () surrounding the ?, therefore by removing the () the procedure now works, hope this helps anybody having the same issue

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.