Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Connecting to SQL Server from Android and iOS in Direct Mode

DZone's Guide to

Connecting to SQL Server from Android and iOS in Direct Mode

Here's how to connect to a SQL server using Android and iOS, with a look at design-time, and how to set up Direct Mode for Android.

· Mobile Zone
Free Resource

Let's see how to connect to SQL Server from Android and iOS in RAD Studio XE7. For this task we will use SQL Server data access components -  SDAC.

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.

Topics:
delphi ,sql server ,android ,ios

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}