user9975326
user9975326

Reputation: 11

Xamarin connection string

Im new to Xamarin and am trying to connect to a SQL Server Database which is located on my PC for a Xamarin Android application. But the connection breaks every time at the connection.open line. I know the connection string credentials are correct as it works in a Windows form project. What is the correct way to state a SqlConnection in Xamarin or how can i go about connecting without using a web service?

Upvotes: 1

Views: 2240

Answers (1)

Andrew
Andrew

Reputation: 1438

In order to access your local host from an Android, use the address 10.0.2.2 in the connection string. The emulator sets up it's own network, and this address will allow you to connect to the local machine where SQL Server is running. If you're using a Genymotion emulator, you may need to use 10.0.3.2.

Upvotes: 1

Related Questions