如何从Windows 10 UWP应用程序连接到SQL Server数据库 [英] How to connect to SQL server database from a Windows 10 UWP app

查看:1714
本文介绍了如何从Windows 10 UWP应用程序连接到SQL Server数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从一个万能的Windows应用程序连接到的预置型MS SQL数据库。我使用UWP,支持台式机,平板电脑和手机的使用作出LOB应用程序。当试图连接到本地(Intranet)SQL Server数据库,我已经习惯了使用的的SqlConnection 连接到本地服务器,但由于在UWP使用的.NET子集不包括SqlConnection的,这是怎么做到的时候使用UWP?

I'm trying to connect to an on-prem MS SQL database from a universal windows app. I'm making a LOB app using UWP, to support desktop, tablet and mobile use. When trying to connect to a local (intranet) SQL server database, I'm used to using an instance of SqlConnection to connect to a local server, but since SqlConnection is not included in the .NET subset used in UWP, how is this done when using UWP?

我看过了的微软官方样品的还有操作指南,发现有关这不是一个Azure数据库的数据库连接什么也没有。 的DbConnection 看起来像它可能是一个很好的路要走,但不能使用,因为它是抽象的,它的儿童(例如的 Data.SqlClient.SqlConnection )似乎并没有被列入UWP的.NET子集。

I've looked over the official Microsoft samples as well as the how-to guides, and found nothing there about database connection that is not an Azure database. DbConnection seemed like it could be a good way to go, but can't be used since it's abstract, and it's children (for instance Data.SqlClient.SqlConnection) does not seem to be included in the .NET subset for UWP.

我缺少的东西超明显吗?顺便说一句,有没有人知道UWP一个很好的命名空间引用

Am I missing something super obvious here? As an aside, does anyone know a good namespace reference for UWP?

编辑非重复:链接的问题,建议为重复的是Windows 8 / 8.1的应用程序,虽然有一些相似之处,在接受的答案的代码,这个问题将不会UWP工作。其原理是一样的,但是,但应该有一个Windows更好的技术参考10应用程序建立与UWP。

Edit for non-duplicate: The linked question suggested as a duplicate is for Windows 8/8.1 apps, and while there are some similarities, the code in the accepted answer for that question won't work on UWP. The principle is the same, however, but there should be a better technical reference for Windows 10 apps build with UWP.

推荐答案

下面是简单的样品并的视频。不知道这是否足以让你。

Here is a simple sample and a video. Not sure if it's enough for you.

下面是一个难点是


  • 如何消费,序列化和反序列化JSON数据。作为一名.NET开发人员,您可以考虑使用的HttpClient来实现这一点。这里是另一个样品并的供你参考影片。有另一个官方样片展示了如何使用Windows。 Data.Json命名空间。

  • how to consume, serialize and deserialize json data. As a .net developer, you can consider using the HttpClient to implement this. And here is another sample and video for your reference. There is another official sample shows how to use Windows.Data.Json namespace.

这篇关于如何从Windows 10 UWP应用程序连接到SQL Server数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆