PhoneGap与SQL Server [英] PhoneGap with SQL Server

查看:88
本文介绍了PhoneGap与SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是PhoneGap的新手。我想从android phonegap应用程序访问Sql Server数据库。任何人都可以告诉我如何做到这一点。请。



问候,



Annamalai

Hi, I am new to PhoneGap. I want to access Sql Server Database from android phonegap app. Can anyone tell me how to do this.? Please.

Regards,

Annamalai

推荐答案

据我所知,您不能直接连接到远程数据库。您应该托管一个Web服务,然后与SQL Server数据库进行通信。
As far as i know you cannot directly connect to a remote database. You should be hosting a web service that in turn communicate with the SQL Server database.


您好,我终于找到了解决方案。虽然很多人都知道这件事,但我只是想分享一下我的做法。我在c#中编写了一个web服务,它从SQL Server数据库中检索数据。我将数据库中的数据存储在datatable中,并通过序列化程序将其放入JSON格式。



在phonegap中,我使用jquery ajax来调用webservice。并且必须在IIS中部署Web服务。



注意:在使用jquery ajax的webservice调用中,使用url和你的机器IP地址。不要使用localhost,因为在模拟器中运行它不会工作。
Hi, i finally found the solution. Though many here knows about this, i just want to share how i did. I wrote a webservice in c# which retrieves the data from SQL Server Database. I stored the data from database in datatable and put it JSON format through serializer.

In phonegap, i used jquery ajax to call the webservice. And the webservice has to be deployed in IIS.

Note: In webservice call using jquery ajax, use url with your machine IP address. Dont use "localhost" because while running in emulator it wont work.


是的,据我所知,你需要使用Web服务。
Yes, you needs to use web services, as far as i know.


这篇关于PhoneGap与SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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