I created localhost website in asp.net in Visual Studio
and i added there a MSSQL
connection.
My problem is that I created an app for windows phone 8
but i dont know how to connect this app with database which is on this website.
Can you help me with this?
First of all: your Windows Phone app can't connect to a SQL Server database, so you'll have to create an API.
Since you're using ASP.NET, I suggest to have a look at Web API. In short: you'll have several URL endpoints which return json/xml to your Windows Phone app. It's your job to query the database and return a single item/list of items in the controller of that URL endpoint (this sentence will make sense if you read into creating a Web API).
Next task is connecting to this API. Normally you would host it on a public url, so your phone device can connect to it (a phone doesn't know about your pc's localhost). If you want to use localhost with the emulator for testing, you'll have to execute the tasks mentioned in the quote below as this doesn't work out of the box.
When you create a WCF web service in Visual Studio, by default the service is hosted in IIS Express and only accepts connections at http://localhost/. Apps that target Windows Phone OS 7.1 can connect to the development computer as localhost because the Windows Phone 7.1 emulator uses the network connection of the development computer. The Windows Phone 8 Emulator, however, configures itself as a separate device on the network. As a result, an app running on the Windows Phone 8 Emulator can’t connect to the development computer as localhost. Before you can connect successfully from the emulator to the local web service, you have to make two changes:
- You have to configure the local web service and web server to accept connections from other devices on the network.
- You have to configure the service reference in the Windows Phone app to connect to the service by using the IP address of the development computer on which the service is running.
Source: https://msdn.microsoft.com/en-us/library/windows/apps/jj684580(v=vs.105).aspx