Android访问Sqlserver
由于公司需求,要做安卓软件实现查询企业Erp系统的报表资料, 在网上找了各种资料,想实现手机直接连接Sqlserver,折腾很久都以失败告终。 目前,安卓不能直接连接Sqlserver,安卓不能用PC的JDBC驱动Jar包提供的API连接数据库。 比较快捷的方法是利用WebServi
由于公司需求,要做安卓软件实现查询企业Erp系统的报表资料,
在网上找了各种资料,想实现手机直接连接Sqlserver,折腾很久都以失败告终。
目前,安卓不能直接连接Sqlserver,安卓不能用PC的JDBC驱动Jar包提供的API连接数据库。
比较快捷的方法是利用WebService作为桥梁,安卓端获得WebService提供的数据然后进行xml解析。
使用Visual Stuido能很快捷的创建、发布WebService服务,安卓只要根据SOAP协议和提供的函数接口 向WebService发送请求,就能得到xml数据。
在Visual Stuido 2012下创建、发布WebService方法:
步骤一 创建WebService项目
新建-选择“Web”-选择“ASP.NEt 空 Web应用程序”
步骤二 添加Web服务
右击项目名,选择“添加”-选择“Web服务”,输入项名称,确定。
接着在asmx.cs文件中编写安卓要访问的函数。
发布至iis方法:(前提是先安装IIS,建立一个站点,安装配置iis方法网上教程很多)
右击项目名-选择“发布”-在配置文件中新建配置文件-下一步,发布方法选择“文件系统”-下一步,选择“目标位置”发布到IIS已创建好的站点中-下一步,“配置”选择release,最后发布。
到此为止,只要打开IIS服务,在浏览器输入你电脑的IP:端口号/webservice文件,就能访问到WebService的接口了
若要将安卓应用在广域网下查看Sqlserver数据,必须配置WebService的Web.config文件,允许远程访问函数接口
在Web.config文件的
<!-- 添加如下代码,允许远程调用函数接口--> <webservices> <protocols> <add name="HttpSoap"></add> <add name="HttpPost"></add> <add name="HttpGet"></add> <add name="Documentation"></add> </protocols> </webservices>
ps:后期会补充WebService和安卓客户端的代码

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In recent days, Ice Universe has been steadily revealing details about the Galaxy S25 Ultra, which is widely believed to be Samsung's next flagship smartphone. Among other things, the leaker claimed that Samsung only plans to bring one camera upgrade

OnLeaks has now partnered with Android Headlines to provide a first look at the Galaxy S25 Ultra, a few days after a failed attempt to generate upwards of $4,000 from his X (formerly Twitter) followers. For context, the render images embedded below h

Alongside announcing two new smartphones, TCL has also announced a new Android tablet called the NXTPAPER 14, and its massive screen size is one of its selling points. The NXTPAPER 14 features version 3.0 of TCL's signature brand of matte LCD panels

In recent days, Ice Universe has been steadily revealing details about the Galaxy S25 Ultra, which is widely believed to be Samsung's next flagship smartphone. Among other things, the leaker claimed that Samsung only plans to bring one camera upgrade

The Vivo Y300 Pro just got fully revealed, and it's one of the slimmest mid-range Android phones with a large battery. To be exact, the smartphone is only 7.69 mm thick but features a 6,500 mAh battery. This is the same capacity as the recently launc

Motorola has released countless devices this year, although only two of them are foldables. For context, while most of the world has received the pair as the Razr 50 and Razr 50 Ultra, Motorola offers them in North America as the Razr 2024 and Razr 2

The Redmi Note 14 Pro Plus is now official as a direct successor to last year'sRedmi Note 13 Pro Plus(curr. $375 on Amazon). As expected, the Redmi Note 14 Pro Plus heads up the Redmi Note 14 series alongside theRedmi Note 14and Redmi Note 14 Pro. Li

Samsung has not offered any hints yet about when it will update its Fan Edition (FE) smartphone series. As it stands, the Galaxy S23 FE remains the company's most recent edition, having been presented at the start of October 2023. However, plenty of
