问题
I am new to programming Metro App for Win8 using C#. I am familiar with C# already, but when I try to use the C# code for connecting and retrieving info from a SQL Database, it does not work.
Main problem is I cannot reference the "using System.Data / .SqlClient", thus I can't use the SqlConnection / DataReader. I could not find a workaround to this.
Edit: Upon further research, I found out that Windows 8 Apps does not support access to local services(hence cannot access Local SQL) based on this thread: http://social.msdn.microsoft.com/Forums/en-US/toolsforwinapps/thread/c1c6aa70-5be9-496c-9d2d-a5b0fc0890a9
Does anyone with experience can help me point in the right direction for SQL / Windows 8 App integration?
Thanks!
回答1:
As far as I'm aware, System.Data is unavailable to Metro apps. If you need to store / retrieve data then you either need to do it to a file (isolated storage) or via a service.
回答2:
You should use sqllite for WinRT as described here
http://timheuer.com/blog/
回答3:
You should implement application server which will expose all necessary methods to access data . And in this case Metro app will use these service methods to get data from DB.
来源:https://stackoverflow.com/questions/11947078/retrieving-data-from-sql-using-c-sharp-metro-app