How to connect to local SQL Server?

How to connect to local SQL Server?

Alex1Alex1 Posts: 18Questions: 8Answers: 0

I tried

$sql_details = array(
    "type" => "Sqlserver",
    "user" => "",
    "pass" => "",
    "host" => "(local)\SQLEXPRESS",
    "port" => "",
    "db"   => "accounting",
    "dsn"  => ""
);

which didn't work. Unsure as to correct format. It is SQL Server 2016 Express on local host using normal Windows Authentication.

Answers

  • allanallan Posts: 61,971Questions: 1Answers: 10,160 Site admin

    Can you show me the connection string that you would normally use to make a connection and I'll try working it back from there.

    Also, what was the error that you were getting from the above?

    Thanks,
    Allan

  • Alex1Alex1 Posts: 18Questions: 8Answers: 0

    @allan here is what I use in another plain PHP page

    $serverName = "(local)\sqlexpress";  
    
    /* Connect using Windows Authentication. */  
    $conn = new PDO( "sqlsrv:server=$serverName ; Database=accounting", "", "");  
    

    Trying to move over from SQLite, have converted the database, now I just need to get this thing connected! :-)

This discussion has been closed.