Devart Company released SDAC and UniDAC for RAD Studio with a new functionality – Direct Mode for connection to SQL Server. The existing providers for SQL Server by Microsoft use the OLE DB interface, that allows using client applications only on Windows platforms. Due to absence of native solutions by Microsoft for Mac OS X, SDAC Direct Mode was the only opportunity to support SQL Server for Mac OS X.
Devart provides a ready solution for work with SQL Server from Mac OS X – Direct Mode. Let’s consider a simple sample of using Direct Mode.
Design time
Here we create a new Mac OS X application in Delphi XE7 working with SQL Server. For this, in the File|New menu select Multi-Device Application – Delphi.
In the appeared dialog select Blank Application.
Connection settings in Direct Mode
Place the TMSConnection component onto the form, which will be named as MSConnection1. Set up the MSConnection1 component by setting the Options.Provider ProviderName property to prDirect. Open MSConnection1 editor and fill in the required properties: Server, Port, Authentication (the SQL Server value), Username, Password and Database.
MSConnection1 configuration for Direct is finished.
If you want to set up a connection for the Direct mode at run-time, the code will be look like the following:
MSConnection1.Options.Provider := prDirect;
MSConnection1.Server := 'Server';
MSConnection1.Port := 1433;
MSConnection1.Authentication := auServer;
MSConnection1.Database := 'FISH_FACTS_DEMO';
MSConnection1.Username := 'sa';
MSConnection1.Password := '*************';
Opening connection and dataset in Direct Mode
The complete project in the IDE looks as shown below:
Now we just have to write event handlers for the Connect and Disconnect buttons:
procedure TMainForm.ConnectClick(Sender: TObject);
begin
MSConnection1.Connect;
MSQuery1.Open;
end;
procedure TMainForm.DisconnectClick(Sender: TObject);
begin
MSQuery1.Close;
MSConnection1.Disconnect;
end;
Application execution in Direct Mode on Mac OS X
For application deployment and execution, the Direct mode requires no libraries, etc. This is our example running on Mac OS X.
The following post will show how to use SDAC to develop applications for Android and iOS working with SQL Server in Direct Mode. The source code of this demo can be found in the SDAC Demo folder on your PC.