Azure SQL connection working on win32, not Android

Azure SQL connection working on win32, not Android

Postby MortVader » Mon 13 Feb 2017 16:08

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
MortVader
 
Posts: 6
Joined: Mon 13 Feb 2017 14:40
Location: Denmark

Re: Azure SQL connection working on win32, not Android

Postby azyk » Wed 15 Feb 2017 08:21

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.
azyk
Devart Team
 
Posts: 811
Joined: Fri 11 Apr 2014 11:47

Re: Azure SQL connection working on win32, not Android

Postby MortVader » Wed 15 Feb 2017 13:38

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
MortVader
 
Posts: 6
Joined: Mon 13 Feb 2017 14:40
Location: Denmark

Re: Azure SQL connection working on win32, not Android

Postby azyk » Thu 16 Feb 2017 08:20

Please specify the full version of Android and RAD Studio which you use.
azyk
Devart Team
 
Posts: 811
Joined: Fri 11 Apr 2014 11:47

Re: Azure SQL connection working on win32, not Android

Postby MortVader » Thu 16 Feb 2017 13:48

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
MortVader
 
Posts: 6
Joined: Mon 13 Feb 2017 14:40
Location: Denmark

Re: Azure SQL connection working on win32, not Android

Postby azyk » Fri 17 Feb 2017 10:32

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;
azyk
Devart Team
 
Posts: 811
Joined: Fri 11 Apr 2014 11:47

Re: Azure SQL connection working on win32, not Android

Postby MortVader » Fri 17 Feb 2017 12:51

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
MortVader
 
Posts: 6
Joined: Mon 13 Feb 2017 14:40
Location: Denmark

Re: Azure SQL connection working on win32, not Android

Postby MortVader » Fri 17 Feb 2017 13:06

Oh, just one little question:

What is TDS?

Provider=TDS

What is that?

Thanks in advance :)

/Morten
MortVader
 
Posts: 6
Joined: Mon 13 Feb 2017 14:40
Location: Denmark

Re: Azure SQL connection working on win32, not Android

Postby ViktorV » Wed 22 Feb 2017 12:17

The substring "Provider=TDS" in connection string means using Direct mode.
ViktorV
Devart Team
 
Posts: 1608
Joined: Wed 30 Jul 2014 07:16


Return to SQL Server Data Access Components