CodeIgniter on Win10記得裝ODBC Driver 11 for SQL Server

在新的Win10上裝上XAMPP後發現CI連不上SQL Server,於是先用原生的方式找到解決的方法

$serverName = "localhost\sqlexpress";
$connectionInfo = array( "Database"=>"Pos", "UID"=>"sa", "PWD"=>"");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
echo "Connection established.
";
}else{
echo "Connection could not be established.
";
die( print_r( sqlsrv_errors(), true));
}

才知道WIN10預設沒有ODBC Driver 11 for SQL Server

https://www.microsoft.com/zh-TW/download/details.aspx?id=36434

Delphi 動態呼叫ODBC連結對話框

ConnectionPromptDataSource
撰寫Ado(dbgo)程式時,常常會做設定ODBC動作,那程式執行時期可以動態指定嗎?答案是可以的!

procedure TForm1.BtnCreateODBCClick(Sender: TObject);
var
  AdoConStr : WideString;
begin
  AdoConStr := PromptDataSource(self.Handle,AdoConnection1.ConnectionString);
  AdoConnection1.ConnectionString := AdoConStr;
end;