Connection to local SQL Server database works on emulator but fails on real device

后端 未结 2 552
一整个雨季
一整个雨季 2021-01-26 06:30

I am trying to connect to an SQL Server database that is currently hosted on my local machine. I am using the following code to connect:

public class DBConnect {         


        
相关标签:
2条回答
  • 2021-01-26 07:03

    Your problem might get solved by simply TURNING OFF the WINDOWS FIREWALL. Firewall will prevent your real device from establishing connection with your local MS SQL server. By doing so it worked fine for me.

    BUT since turning off firewall is not a good idea, configure the Windows Firewall for Database engine access, click this link and follow the steps.

    https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/configure-a-windows-firewall-for-database-engine-access?view=sql-server-ver15

    0 讨论(0)
  • 2021-01-26 07:09

    Two possible solutions to your problem that i can see:

    1. your are using a Genymotion emulator which is probably working on a different network
    2. check if your SQL Server database is accessible in online mode by setting this:

      ALTER DATABASE database-name SET ONLINE

    0 讨论(0)
提交回复
热议问题