简体   繁体   English

从Windows Forms App和Windows Phone App访问SQL数据库

[英]Accessing SQL Database from Windows Forms App and Windows Phone App

I have a project assignment from the university and want to ask you if you can show me the right approach. 我有大学的项目任务,想问你是否可以向我展示正确的方法。 I'm not asking for any code or to write me something. 我不要求任何代码或不给我写东西。 I just want some guidelines to follow. 我只想遵循一些准则。

Firstly, to explain a bit.. I have to design and implement an Info System in .NET. 首先,要解释一下。我必须在.NET中设计和实现一个信息系统。 It should have a Desktop App (based on Windows Forms), a Mobile App (Windows Phone 7.1) and a database (MS SQL). 它应该具有一个桌面应用程序 (基于Windows窗体),一个移动应用程序 (Windows Phone 7.1)和一个数据库 (MS SQL)。 The idea is to have a database, hosted on a remote machine. 想法是将数据库托管在远程计算机上。 The desktop and mobile apps should be able to connect to that database and do some stuff with it (mobile app will be only for viewing data, not modifying). 桌面和移动应用程序应该能够连接到该数据库并对其进行一些处理(移动应用程序仅用于查看数据,而不能进行修改)。 The system must be multi-client - the database should be able to be accessed from multiple desktop and mobile clients at a time. 该系统必须是多客户端的-数据库应该能够一次从多个台式机和移动客户端访问。

I'm ready with the GUI and it's time to do some real work. 我已经准备好使用GUI,现在该做一些实际的工作了。 What's the easiest way to get that communication done? 完成交流的最简单方法是什么? I thought of a WCF Service Application, which will provide the clients' access to the DB. 我想到了WCF服务应用程序,它将为客户提供对数据库的访问。 My idea is to have the database and the service on a machine with a public IP address. 我的想法是将数据库和服务放在具有公共IP地址的计算机上。 The apps (desktop and mobile) will connect to that machine and respectively to the SQL through the WCF. 这些应用程序(台式机和移动设备)将通过WCF连接到该计算机,并分别连接到SQL。

I saw some tutorials around, but didn't find one that shows how to make that WCF Service work with both Windows Forms app and Windows Phone app. 我看到了一些教程,但没有找到说明如何使WCF Service与Windows Forms应用程序和Windows Phone应用程序一起使用的教程。 I'm not very familiar with WCF - should I have IIS to run the service? 我对WCF不太熟悉-我应该让IIS运行该服务吗? I'm also not sure what kind of techniques I have to use on the client side to do the connection... 我也不确定客户端必须使用哪种技术来建立连接...

Is this approach rght? 这种方法是否正确? Can this be done in the way I explained? 可以按照我的解释来完成吗? What should I be aware of? 我应该注意些什么? I will appreciate every kind of advise and reproach. 我将不胜感激每一种建议和责备。

The easiest (and in your case, most efficient) way would be to use Windows Azure . 最简单(也是您的情况,最有效)的方法是使用Windows Azure For the purpose of your project, you can always sign up for the free trial. 对于您的项目,您可以随时注册免费试用。

Specifically, you can leverage Windows Azure SQL Database . 具体来说,您可以利用Windows Azure SQL数据库 Or, if you are so inclined, you could use Mobile Services , which also relies on SQL databases but you will have a much better time setting it up in your Windows Phone app (doesn't matter whether you want to read or write data). 或者,如果您愿意,可以使用Mobile Services ,该服务也依赖于SQL数据库,但是您将有更多的时间在Windows Phone应用程序中进行设置(无论您要读取还是写入数据都没有关系) 。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM