IN Microsoft SQL server Management Studio when I run
EXEC sp_helplogins @LoginNamePattern='mmanlapig\martin'
I get this :
LoginName DBName UserName UserOrAlias
1 mmanlapig\martin homis db_owner MemberOf
2 mmanlapig\martin homis dbo User
Then in my code I have :
define('DBHOST', 'localhost\SQLEXPRESS');
define('DBNAME', 'homis');
define('DBUSER', 'dbo');
define('DBPASS', '');
$dbname = "`" . str_replace("`", "``", DBNAME) . "`";
$dbh1 = new PDO("odbc:Driver={SQL Server};Server=" . DBHOST . ";Database=$dbname;", DBUSER, DBPASS);
When I run this code
Select sp.name as LoginName, sp.type_desc as LoginType,
dp.name as DBUser, dp.type_desc as UserType
from sys.server_principals sp
join sys.database_principals dp on dp.sid = sp.sid
where sp.name = 'mmanlapig\martin';
I get
LoginName LoginType DBUser UserType
1 mmanlapig\martin WINDOWS_LOGIN dbo WINDOWS_USER
Tried these steps from here
The issue was that the server was set to "Windows Authentication Mode" only. To fix this I
Still same issues
Hope this article helps you: Using PDO's odbc to connect to a MSSQL server instance with Windows Authentication
$conn = new PDO(
'odbc:
Driver=SQL Server;
Server=MyServer\MyInstance;
Database=MyDatabaseName;
Trusted Connection=Yes;'
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.