How to connect to local SQL-Server in Visual Studio
Posted: July 19th, 2017, 4:14 pm
Hello everyone,
It's really a shame to post this question, but I am a complete PHP newbie and I stumbled upon thousands of different approaches to connect PHP to MSSQL, but not in Visual Studio. Apparently, this is still a bit uncommon...
So, now I have set up a MSSQL-Server from within Visual Studio 2017, where PHP Tools for Visual Studio is installed. The server is hosted locally in a .mdf file. There are already some tables created and VS tells me there's a functioning connection to MSSQL. It also gives me a connection String.
Now I tried to connect using
where the whole string within this connect command is the given connection string I retrieved from VS (in Server-Properties).
So, conclusion is, the program runs this command and returns a null Object.
Most sources I found have stated I should use 'sqlsrv_connect' instead, but this command isn't recognized by VS.
What am I doing wrong?
Help of every kind is highly appreciated.
Regards
It's really a shame to post this question, but I am a complete PHP newbie and I stumbled upon thousands of different approaches to connect PHP to MSSQL, but not in Visual Studio. Apparently, this is still a bit uncommon...
So, now I have set up a MSSQL-Server from within Visual Studio 2017, where PHP Tools for Visual Studio is installed. The server is hosted locally in a .mdf file. There are already some tables created and VS tells me there's a functioning connection to MSSQL. It also gives me a connection String.
Now I tried to connect using
- Code: Select all
$server_db = mysqli_connect('(localdb)\\v13.0', array('Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename="D:\Users\Username\Documents\Visual Studio 2017\Projects\MyProject\SQL_DB.mdf";Integrated Security=True;Connect Timeout=30'));
where the whole string within this connect command is the given connection string I retrieved from VS (in Server-Properties).
So, conclusion is, the program runs this command and returns a null Object.
Most sources I found have stated I should use 'sqlsrv_connect' instead, but this command isn't recognized by VS.
What am I doing wrong?
Help of every kind is highly appreciated.
Regards