开发者

How to connect from android to sql server using MonoDroid

I'm using MonoDroid for android development (meaning using visual开发者_如何转开发 studio 2010 and c#) and trying to connect to sql server. can i use java.sql or system.data in my code and deploy it? or if anyone has a better solution? (and please not the solution - "use eclipse")


Mono for Android provides System.Data.dll and the System.Data.SqlClient namespace, so you can use your existing System.Data code to connect to Microsoft SQL Server via Mono for Android.

However, you do need to enable TDS support within SQL Server, mixed-mode authentication, and other things. See also Mono's SQLClient documentation and (only indirectly related) my instructions to configure SQL Server for use by Mono with the NerdDinner sample.


Another option is to build a web service, create a reference from your mono project to the web service and use that web service to pass data objects to and from your application. This way you can use the normal .NET environment for getting the data and reuse that web service for other projects like an iOS version of your application without having to rewrite the data calls.

http://docs.xamarin.com/guides/cross-platform/application_fundamentals/web_services


Natively Android supports java.sql package, to connect with sql server , mysql or oracle, you required JDBC Type-3/4 driver. as per my knowledge currently available drivers are not compatible with Android. If you found any compatible driver then it is not advisable to use it because JDBC driver are optimized to work in LAN, Not WAN (Internet). the possible option is to create web service which act as bridge between Android and Database

Andorid <====> Web Service <====> Database

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜