Jump to content

OS-independant client program to communicate with web server database

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
steph03

steph03

    Newbie

  • Members
  • Pip
  • 8 posts
Hello, I am about to start a new project and any feedback would be appreciated on it.

I am creating a client-based application that will be accessing a database on a remote web server. It needs to run on any OS. What programming language would be best fit for this and what type of database should I store my data in on the web server? I would personally prefer using a mySQL database, since I will also be accessing it with PHP scripts on a web server.

Thank you in advance for any help/suggestions.


Steph

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
C++ is a good cross-OS compatible language which can run on UNIX (HP-UX, IRIX, ...), Linux, OSX and Windows. What you will need to do is ensure the MySQL database allows remote connections, I'll whip up a quick example of a client for you..

#include <iostream>
#include <my_global.h>
#include <mysql.h>

using namespace std;

int main(int argc, char **argv)
{

  MYSQL *conn;

  conn = mysql_init(NULL);

  if (conn == NULL) {
      printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
  }

  if (mysql_real_connect(conn, "mysqlwebhost", "user", "password", "database", 0, NULL, 0) == NULL) {
      printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
  }

  if (mysql_query(conn, "foo query")) {
      printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
  }

  mysql_close(conn);

}
the MySQL headers should come with the official MySQL package (for example be in /usr/include/mysql/mysql.h)
Info sheets: MySQL :: MySQL 5.0 Reference Manual :: 20.8 MySQL C API

Edited by Alexander, 20 August 2010 - 08:47 AM.

Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
steph03

steph03

    Newbie

  • Members
  • Pip
  • 8 posts
Thank you very much for the quick reply! It's been a while since I've programmed in C++, over 6-7 years. Has it become easier to program a GUI in C++? Will Visual Studios cut it ?

#4
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
Some new .NET frameworks came out but it's pretty much remained the same since '02, VC++ for winforms should bunker down nice with this project.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#5
steph03

steph03

    Newbie

  • Members
  • Pip
  • 8 posts
Perfect, thanks again for the help. This will be a great starting point.

#6
PsychoCoder

PsychoCoder

    Learning Programmer

  • Members
  • PipPipPip
  • 92 posts
Remember, even if using C++ if you use any part of the .NET Framework in your VC++ application it will not run on anything other than Windows so I would stick with native C++ and stay away from the .NET Framework (Boy from a C# developer that was hard to say lol). Another option you have is Java, which will run on the OS's you listed, and Java may be easier when working with the GUI.
SELECT * FROM Users WHERE Clue > 0;
ERROR: 0 results returned
Posted Image

#7
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
WinAPI would deal with the networking not .NET
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.