Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Posted

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.
 
Share this answer
 
Comments
Annamalai09 16-Jul-13 0:21am    
So, for android app in phonegap, i have to write webservice in java and have to call it from javascript right...????
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.
 
Share this answer
 
Yes, you needs to use web services, as far as i know.
 
Share this answer
 
Comments
Annamalai09 17-Jul-13 4:23am    
ok.. Thank you.
I develop a plugin to connect with an external SQL Server directly without any services, here is the link

GitHub - SergioDosSantos/cordova-plugin-sqlserver: Cordova Plugin to connect to SQL Server without services[^]
 
Share this answer
 
Comments
OriginalGriff 30-Sep-17 1:44am    
Reopening a 4 year old question - particularly one marked solved - to post links to your work is a bad idea: it looks a lot like rep point farming which we count as abuse. That can get your account banned from the site, so you do need to be careful.
In this case, I don't think it is intended that way, so I won't start the process, but I would strongly suggest that you don't do it again, as our more trigger happy members will not be so lenient...
Member 14615882 11-Feb-20 16:09pm    
Does anyone know how to connect phonegap app to online hosting mysql database....i tried its working while creating the app
But after building the app its not working...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900