Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

PDOStatement::errorCode

SQL Server 2008 R2

Retrieves the SQLSTATE of the most recent operation on the database statement object.


string PDOStatement::errorCode();

Returns a five-char SQLSTATE as a string, or NULL if there was no operation on the statement handle.

Support for PDO was added in version 2.0 of the Microsoft Drivers for PHP for SQL Server.

This example shows a SQL query that has an error. The error code is then displayed.

<?php
$conn = new PDO( "sqlsrv:server=(local) ; Database = AdventureWorks", "", "");
$stmt = $conn->prepare('SELECT * FROM Person.Addressx');

$stmt->execute();
print $stmt->errorCode();
?>

Reference

Other Resources

PDO
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.