Sunday, November 24, 2024
HomeProductsDelphi DACConnecting to SQL Server from Android and iOS in Direct Mode Using...

Connecting to SQL Server from Android and iOS in Direct Mode Using SDAC

Using SDAC in Direct Mode for access to SQL Server from iOS and Android platforms doesn’t significantly differ from the one on Mac OS X or Windows platforms. Let’s see how this works in a sample below for RAD Studio XE7.

Note: those, who have already read our previous article Connecting to SQL Server on Mac OS X in Direct Mode Using SDAC can skip the description of creating a new project and move on to the Project configuration for Android and iOS platforms step.

Design-time

Let’s create a new Android / iOS application, that will work with SQL Server. For this, in the File|New menu select Multi-Device Application – Delphi.

In the appeared dialog select Blank Application.

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 settings for Direct Mode have been done.

Complete Project

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;

Setting up Direct Mode for Android

When developing Android applications working with SQL Server in Direct Mode, SDAC doesn’t require any additional settings for deployment and execution. For my sample, I have just selected Target Platform – Android and a device.

Application execution in Direct Mode on Android

In RAD Studio press F9 and in a few seconds get the application running on Android, that works with SQL Server in Direct Mode with the help of SDAC.

Setting up Direct Mode for iOS

When developing iOS applications working with SQL Server in Direct Mode, SDAC doesn’t require any additional settings for deployment and execution. For my sample, I have just selected Target Platform – iOS and a device.

Application execution in Direct Mode on iOS (Simulator)

The application running on iOS Simulator looks like the following.

Application execution in Direct Mode on iOS Device

And finally a screenshot of running application on an iOS device

In such a way, we have demonstrated how easy to use SDAC functionality – Direct Mode for SQL Server when developing applications for Android and iOS. The source code of this demo can be found in the SDAC Demo folder on your PC.

RELATED ARTICLES

7 COMMENTS

    • Hello, FAhd!
      To get familiar with Direct Mode work in SDAC open the demo project included in the samples supplied with SDAC – [SDAC install folder]\Demos\Mobile . Then using Project Manager select the required platform, go to the menu item “Project” and select “Deploy”

  1. Hi, I’m trying to create a first mobil app by using sdac MSConnection and MSQuery. Unfortunatelly I can not find any DBGrid component to present the selected data. Is there no DBGRID component available for mobile apps?

    • Hello, Jens!
      Unfortunately, TCRDBGrid is a VCL component, therefore, you won’t be able to use it in FMX applications. To display tabular data, you can use the TGrid component from a standard set of FMX components.

  2. Hello.

    We are contemplating to buy SDAC. In fact, we already have downloaded trial version for Delphi XE6, however the component works fine with Android 4 but it doesn´t work in other versions such Android 7. Are there any solution about that?

    Thanks.

    • Hello, Raul!

      Unfortunately, RAD Studio XE6 does not support Android 7.0 (API Level 24), you can read more about compatibility of RAD Studio XE6 with Android by the following link:

      docwiki.embarcadero.com/RADStudio/XE6/en/Android_Devices_Supported_for_Application_Development

Comments are closed.

Whitepaper

Social

Topics

Products