1

I am trying to connect sql server 2008 from visual studio 2010 for a windows phone app (SDK 7.8). But cannot add below written line on mypage.xaml.cs:

    using System.Data.SqlClient; 

and because of this I cannot open a sqlconnection.

I have tried adding reference but there was no system.data.dll or system.data.sqlclient.dll. I have also installed microsoft sql server compact 4.0 but even after that I couldnot find System.Data.Sqlclient.dll.

Do someone know how to solve this problem/ have faced same problem.

Thanx in advance.

1 Answer 1

0

There is no SQL Server connector available for Windows Phone. As a workaround, I would suggest exposing the data through a webservice, and consuming this webservice from your mobile app.

6
  • Are you suggesting that we cannot add a sqlconnection in xaml.cs page for Window phone app. But I have seen various codes where you can access remote database opening a sqlconnection. I simply can't add reference to system.data.sqlclient Isn't there any solution to that?
    – Mr. Wayne
    Jul 19, 2013 at 7:05
  • Those codes are for the desktop version of .NET. System.Data.SqlClient isn't available for Silverlight, and therefore for Windows Phone. Jul 19, 2013 at 7:12
  • Actually I dont know how to consume a webservice by app. Can you suggest me something(Like how to proceed)?? Thank You!
    – Mr. Wayne
    Jul 19, 2013 at 7:24
  • @Mr.Wayne I don't have a link to give you, but calling a webservice is straightforward. Add a "service reference" in your project, pointing to the address of the webservice. Then Visual Studio will generate all the boilerplate code to call the service. To you, it will almost be like you're calling a function locally on the phone. Jul 19, 2013 at 7:53
  • Ok thank you alot! I wanted to know will add service reference work like add web reference works for .aspx?
    – Mr. Wayne
    Jul 19, 2013 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.