Page 1 of 1

Azure SQL connection working on win32, not Android

Posted: Mon 13 Feb 2017 16:08
by MortVader
Hello there.

I've just installed SDAC, anxious to get started :)

I'm trying to connect to an Azure SQL using the code below.
This works fine when executed on Win32.

However, when I run the same from Android, I get the following error message..

I've tried commenting the line in, where I am setting options.provider to prDirect. But this results in the same error message:
Unknown host 'tcp:mydatabasename.database.windows.net,1433'.
Socket Error Code: 0($0)

Code: Select all

msconnection1.ConnectString:='Server="tcp:mydatabasename.database.windows.net,1433";Initial Catalog=myDB;Persist Security Info=False;User ID=my_login;password=xxxMYPASSWORDxxx;Encrypt=True;TrustServerCertificate=False;';
msconnection1.LoginPrompt:=false;
//msconnection1.Options.Provider:=tmsprovider.prdirect;
msconnection1.open;
caption:='CONNECTED';

     with tmsquery.create(nil) do begin
       connection:=msconnection1;
       SQL.text:='select * from deb_signin';
       open;
       if not eof then caption:=fieldbyname('info').asstring;
       close;

       free;
     end;

     msconnection1.close;
Can anybody help me? :)

Thanks in advance,
Morten

Re: Azure SQL connection working on win32, not Android

Posted: Wed 15 Feb 2017 08:21
by azyk
On Android device the 'Unknown host' error can occur when the Internet provider used on this device cannot resolve DNS server.

To solve the problem, try instead of DNS server specify IP address corresponding to this server.

Re: Azure SQL connection working on win32, not Android

Posted: Wed 15 Feb 2017 13:38
by MortVader
azyk wrote:On Android device the 'Unknown host' error can occur when the Internet provider used on this device cannot resolve DNS server.

To solve the problem, try instead of DNS server specify IP address corresponding to this server.
I've just tried replacing the address with the direct IP.
This did not change anything. Still the same error message (with the address replaced by the IP)

I might add that both my Windows laptop and my android device are on the same wifi network.. (connecting to the same ISP)

What can I do to work around this bug?

/Morten

Re: Azure SQL connection working on win32, not Android

Posted: Thu 16 Feb 2017 08:20
by azyk
Please specify the full version of Android and RAD Studio which you use.

Re: Azure SQL connection working on win32, not Android

Posted: Thu 16 Feb 2017 13:48
by MortVader
Hello Azyk.

Thankyou for taking time to look at my connectivity issue here!

The tablet I am using is a Samsung SM-T230 running Android 4.4.2
I am also testing on a Huawei phone model SCL-L01 running Android 5.1.1

Both devices display the same error message when trying to connect.
(same result with and without Provider:=prDirect)

I use Delphi RAD studio 10.1 Berlin version 24.0.24468.8770

/Morten

Re: Azure SQL connection working on win32, not Android

Posted: Fri 17 Feb 2017 10:32
by azyk
To solve the problem, try in the connection string to specify the server name and port using the Data Source and Port options instead of the Server option. For example:

Code: Select all

msconnection1.ConnectString:= 
  'Provider=TDS;Data Source=mydatabasename.database.windows.net;Port=1433;'+
  'Initial Catalog=myDB;User ID=my_login;Password=xxxMYPASSWORDxxx;Login rompt=False;'+
  'TrustServerCertificate=False;Encrypt=True';
msconnection1.open;

Re: Azure SQL connection working on win32, not Android

Posted: Fri 17 Feb 2017 12:51
by MortVader
Thanks, Azyk.
This worked on the Android 4.4.2 tablet, but not on the Android 5.1.1 phone.

On the phone, this message is displayed in stead of connecting:
The certificate is not valid
I wonder what certificate this is about?

EDIT:
Oh wait, i edited the "TrustServerCertificate" from False to True in the connectionstring, and now it works on both devices.

Thanks for your help :)

/Morten

Re: Azure SQL connection working on win32, not Android

Posted: Fri 17 Feb 2017 13:06
by MortVader
Oh, just one little question:

What is TDS?

Provider=TDS

What is that?

Thanks in advance :)

/Morten

Re: Azure SQL connection working on win32, not Android

Posted: Wed 22 Feb 2017 12:17
by ViktorV
The substring "Provider=TDS" in connection string means using Direct mode.