Phonegap / cordova直接连接到MS SQL数据库(而不是通过任何Web) [英] Phonegap/cordova connect directly to MS SQL database (not through any Web)

查看:176
本文介绍了Phonegap / cordova直接连接到MS SQL数据库(而不是通过任何Web)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个任务要写一个条形码阅读器。这将直接连接到MS SQL Server以找到一个产品。

I have a task to write an Bar-code reader. Which will connect directly to an MS SQL Server to find an product.

基本上,我可以写一个ASP.net网站,并编写Javascript代码从Cordova调用它)应用程序。或者编写本地代码并从Cordova调用它。

Basically, I can write a ASP.net website and write Javascript code to call it from Cordova (Android) app. Or write an native code and call it from Cordova.

但是我的任务是通过使用Javascript代码直接连接到Ms SQL服务器。有任何方法吗?

But my task it "Directly connect" to Ms SQL server by using Javascript code. Does any way to do this ?

推荐答案

直接连接到数据库不是一个好主意。相反,您的数据库应通过 API 展示。

Connecting directly to the database is not a very good idea. Instead, your database should be exposed by an API.

在您的情况下,最好的办法是使用内置的 ASP.NET WebAPI 。您可以在此处找到有关ASP.NET WebAPI的更多信息。

In your case, your best bet is to use the built in ASP.NET WebAPI. You can find more information about ASP.NET WebAPI here.

要调用WebAPI端点,您需要使用HTTP或HTTPS调用。 jQuery 有很多不错的功能可供您使用。

To call the WebAPI endpoints, you'll want to use HTTP, or HTTPS calls. jQuery has quite a nice set of functions you can use.

您要确保应用程序的每个层都是分开的。如果你开始在你的移动应用程序中放置SQL查询,那么当涉及到任何调试,甚至重构时,这将会导致灾难。

You want to ensure that each layer of your application is separated. If you start putting SQL queries inside your mobile app, then this will spell disaster when it comes to any kind of debugging, or even refactoring.

这篇关于Phonegap / cordova直接连接到MS SQL数据库(而不是通过任何Web)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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