querying database in android - sql

I am building an android app and I have an SQL database stored on a server. I need to either pull the database into android or query the database and have it return information from the tables. I have searched all over the internet but I haven't found anything that explains how to connect to the server from android. How can I do this?

You can't query database in a server from android directly. You have to write PHP scripts to query database from server. You have to keep the php scripts in a web server. And from android application you have to get the data from the php page.

I don't think there is a reasonably simple way to 'pull' the database or connect to it using some soft of ODBC connection. And I don't think it would be wise to use it even if possible.
I believe the best way to solve your problem would be to implement some sort of REST API interface to your database and fetch data as needed.

actually, despite gypsicoder's answer and several "how to"s on the internet, there is a way to connect/query an SQL database from android
you just have to download the corresponding JDCB. for mysql: http://dev.mysql.com/usingmysql/java/
then you just use the java.sql interfaces/classes to do stuff (mysql has a reference manual at above link)

Related

Deploying a Windows Form App in C# for multiple users with SQL Server. Alternatives for databases?

I'm working on a database driven program in Visual Studio 2015, in C#, Windows Form Application, and I'm using SQL Server 2014 for my databases, downloaded the most recent version from the MSDN site.
I've got it working well. But if I want other users on other computers and different versions of Windows, this would require them to have SQL Server installed, correct?
Basically the app is used for storing current medications, moods, a mood quiz, symptoms, etc.. and I store all the results in SQL Server databases. They can be edited, deleted, etc through the program's GUI. Do the users need SQL Server installed to use this app?
If so, is there an alternative to keeping databases without having to have the SQL Server connections, or is there a way to do this without the users having to have SQL Server installed? I don't want remote connections to me, I want it standalone.
Does this make any sense? If not, I can explain more. I know way back in the days of Visual Basic 4 I was making, reading and writing databases without SQL. But that was 16 years ago. So I'm wondering what the easiest solution to this is. Thanks!
In other words, you want a database that you can a) distribute to end users freely and b) that will 'connect' just to the copy of the database they have stored locally.
Here are a few options ---
SQLite over ODBC is as-easy-to-use as MSSQL, the driver can be found here:
SQLite ODBC
Use ConfigurationManager.OpenExeConfiguration to read / write your app config .xml file and use it as a key / value store. I can provide examples if needed.
Dynamically create an Access database, it should work as well as MSSQL for most things, with less overhead. Here's how:
Create an Access Database
Use SQLIte DLL. Details on SO
create-sqlite-database-and-table

Directly perform SQL queries from iPhone to an online server

I'm a newbie and tend to do a simple iOS applications.
The mission is making an app that does the registeration for a person and then upload that data to an online server.
In detail, I want to insert, delete, update data directly to online server.
Would anyone show me what I have to do with (tool, library...)?
I have worked with SQlite to make a local database for the iPhone and it worked well, now it is about dealing with an online server.
For performing remote request there are two ways:
1) https://github.com/smhuang426/MySqueakQl - this is "basic" implementation for remote access to DB. http://www.karlkraft.com/index.php/2010/09/17/mysql-for-iphone-and-osx/ - more advanced, in articles you may some instructions how use this framework. In this case you use SQL C API and you can write your own special classes. Example: http://blog.iosplace.com/?p=30 , http://zetcode.com/tutorials/mysqlcapitutorial/ and description of C API http://dev.mysql.com/doc/refman/5.0/en/c-api-function-overview.html
2) PHP script that posted on online server, you use async ASIHTTP (or ordinary NSRequest) that send to this script, and script works directly with sql DB on tis server. Example ( iOS no communication between iPhone app and MySQL database via PHP). In this case you achieved more security, but also there some limitations like decrease of app's speed and server must supply PHP.
Good luck!
What you need is some kind of remote API available which you will use to interface the iPhone application and say, a MySQL database.

Offline database solution for sql server

Here's task: We have an sql server database. which is hosted at our server. What we need to do is: we need to create a non-techy-users interface (basically insert/edit forms) and let these non-techy-users to install this database locally, since they are located in the areas without internet connection. Then when they're done using the database we get the data from them and inster it in our database.
The biggest concern is that it is not trivial for non-it people to install sql server. Can you please advise me what solution should I choose? Simple Access should work fine, but i really do not want to mess with it and have data conversion back and forth between engines.
Sync Framework for SQL Server: your application uses a lite weight, embedded SQL Server CE (no installation, just a couple of DLLs deployed along with your app) and the sync framework manages the synchronization with the 'mother ship' SQL Server.
Out of interest, why do they need their own installation? Can't you create a new database on your existing instance?
If you're looking for an easy way to create insert/edit forms on your database, have you considered looking at Microsoft's new LightSwitch product (currently in Beta) or Microsoft's Dynamic Data?

Transition from SQL Server to MySQL (no data migration) - what's the difference?

I've written my website using ASP.NET MVC and SQL Server (used a SQL Server instance which ran locally on my machine).
I'm about to upload my site to a hosting provider. However, his DB works under MySQL. I don't care about the data already in the DB itself. It's mostly mock data and a few tables which I don't mind rewriting. But how do I go about the transition from SQL Server to MySQL? How does this influence my queries inside my code? is it the same code syntax? Will I have to recreate the table definitions? In my project I used LINQ to SQL.
Am I forced to look for a host with SQL Server capabilities (i.e. licenses)? (I hope not...)
Thanks!
You may be able to transition smoothly, but I greatly doubt this will be the case.
The differences are many and whether you could depends on what features you used when developing.
If you kept to one of the standards, you may be in luck.
See a comparison sheet on wikipedia.
In regards to the Linq aspect of your question - you should be able to use a Linq provider for MySql instead of MSSql without a problem.
Here is a link to one: http://code2code.net/DB_Linq/
If you do decide to go with the MySql hosting, I suggest you test all aspects of you application to ensure they are working as expected.
LINQ to SQL works with MS SQL Server only...so if you want to keep using it, you need to find a host with a MSSQL database.

How to test if a SQL Server 2008 database can serve 200 concurent users

I have a SQL Server 2008 database in 3NF.
I must check if the db can support many concurent users.
Which is the best method ?
Is there any free tool to do this ?
Thank you very much.
SQLQueryStress - http://www.datamanipulation.net/SQLQueryStress/documentation/documentation.asp
and
SQLStress - http://www.sqlstress.com/Overview.aspx
Both look like a good fit for what you want to do.
The database design and the queries you run against it are vital; no generic answer can be reliable.
I recommend you start with the MS SQL community's benchmark tools.
Since uses are hopefully not accessing the database directly you must have some front end, that is where I would perform my load test. You can use TFS to do load tests as well as Selenium.
Assuming that you have created some kind of web front end that queries your database, then the excellent open source tool Sahi would really help you out. The test toolkit allows you to simulate multiple users using your website - and therefore your database.