MSSQL

QuestionsMSSQL
Rafael Prieto asked 4 years ago

Hello, sorry but new on php 4 grid , tryin to connect to MS sql server

my configuraion is

$db_conf = array();
$db_conf[“type”] = “mssqlnative”;
$db_conf[“server”] = “sqlsrv:server=192.168.0.240\SAGE100”;
$db_conf[“user”] = ‘myuser’; // username
$db_conf[“password”] = ‘mypassword’; // password

$db_conf[“database”] = ‘MAS_001’; // database

any sugestions

Error is SQLState: 08001
Error Code: -1
Message: [Microsoft][ODBC Driver 17 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online

2 Answers
Abu Ghufran Staff answered 4 years ago

If you are using PDO based connection string you need to specify pdo instead of mssqlnative.

$db_conf[“type”] = “pdo”;

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Rafael Prieto replied 4 years ago

Sorry keep tryin , try pdo not work, my sqlconnection string for sqlsrv work, not pdo,
but when I put varaibles of grid4php unable to connect. Thanks

$connectionInfo = array( “Database”=>”MAS_001”, “UID”=>”myuser”, “PWD”=>”mypass”, ‘ReturnDatesAsStrings’ => true,”CharacterSet” =>”UTF-8″,”ConnectionPooling” => “1” ,”MultipleActiveResultSets”=>true);

$conn = sqlsrv_connect( $serverName, $connectionInfo);

Abu Ghufran Staff answered 4 years ago

Hello again,

I’ve created a sample that uses a PDO based sql server connection to a testing database.
You can refer code here:

PDO SQL server connection sample (github.com)

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

8 + 14 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?