As I\'m not that skilled in Windows Phone 8 development I would like to discuss/ask what is the best way to connect my Windows Phone 8 to Sql-Server Database
Well, to achieve your goal, I would do:
Build a REST webservice with ASP.NET Web API (http://www.asp.net/web-api) which returns objects (those objects will be translated to json automatically). For example:
public class MyObject
{
public string Content { get; set; }
}
Controller for it:
public class TestController : ApiController
{
[HttpGet]
public MyObject Example() {
return new MyObject() { Content = "Hello World!" };
}
}
Use a HTTP client in your win phone project:
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("http://mywebservice.com");
client.DefaultRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
using (var result = await client.GetStreamAsync("test/example"))
{
var serializer = new JsonSerializer(); // this is json.net serializer
using (var streamReader = new StreamReader(result)) {
using (var jsonReader = new JsonTextReader(streamReader))
{
var obj = serializer.Deserialize<MyObject>(jsonReader);
// you can access obj.Content now to get the content which was created by the webservice
// in this example there will be "Hello World!"
}
}
}
Sure you can create much more complex objects which will be (de)serialized. Just take a look at the Web API tutorials.
Within your webservice you can now access any database you want.
Edit If you need a more detailed answer, leave me a comment.