GithubHelp home page GithubHelp logo

Comments (4)

v-mabarw avatar v-mabarw commented on July 19, 2024

On 2010-08-20 01:46:31 UTC, AshayC commented:

We are not able to repro this in-house, it appears that the connection string you use is incorrect in some way. Please post the connection code:

$conn = new PDO(""); // feel free to abstract the alphanumeric parts of the string

from msphpsql.

v-mabarw avatar v-mabarw commented on July 19, 2024

On 2010-08-24 19:23:30 UTC, rphilip commented:

Thanks for looking at this. Here is the connection string I use:
$server = "hydrotel\sqlexpress";
$db_name = "mydb";
try {
$dbh = new PDO( "sqlsrv:$server", NULL, NULL, array('Database' => $db_name) );
$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
printf("Connected to Server:%s, database:%s\n",$server,$db_name);
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "";
die();
} // catch

from msphpsql.

v-mabarw avatar v-mabarw commented on July 19, 2024

On 2010-08-25 11:49:58 UTC, AshayC commented:

As we suspected, the usage of the API is incorrect. We have blogged numerous times on this change (see
http://blogs.msdn.com/sqlphp) for the CTP2 release as well as RTW, somehow you missed them. Our API reference documentation was also updated for this design change.

Please change the code from:
$dbh = new PDO( "sqlsrv:$server", NULL, NULL, array('Database' => $db_name) );

to:
$dbh = new PDO( "sqlsrv:$server;Database=$db_name"); // you have to pass in the "NULL, NULL" only if you set any of the Connection Options

from msphpsql.

v-mabarw avatar v-mabarw commented on July 19, 2024

On 2010-11-01 16:06:55 UTC, rphilip commented:

Actually, your recommended change was incorrect:
$dbh = new PDO( "sqlsrv:$server", NULL, NULL, array('Database' => $db_name) ); //Wrong - Obsolete CTP1 //

$dbh = new PDO( "sqlsrv:$server;Database=$db_name"); //Still wrong! //
$dbh = new PDO( "sqlsrv:server = $server;Database = $db_name"); //Works! //

BTW, finding the PHP PDO driver documentation on the Microsoft sites is VERY difficult and obscure. Maybe you could add a link to the online manuals at php.net...

from msphpsql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.