Click here to Skip to main content
13,259,194 members (50,885 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi Everybody,

I have a website which take advantage of MySQL database and PhpMyAdmin. I've created a database (My_db) and assigned a username and password to it as an admin (db_admin). This username is differed from my control panel username (CPanel_user). I also created a table and inserted some data to it (tbl_test).

What I want to do is develop a client program using this database. The problem is that I don't know the proper connection string to this remote database. I downloaded MySQL connector for windows and installed it in order to add my database to ODBC data sources but it wasn't successful because I don't know what parameters I should use in the needed fields.

I used try and error method too but it didn't help.

Can anyone help me and answer how can i add a remote MySQL database to ODBC data sources and gain access to it via a remote client?
Posted 21-Apr-11 22:55pm
Updated 22-Apr-11 1:27am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

MySQL connecting in e.g. C# is advance coding. It's easier to connect an MS SQL database to your system. But with this piece of code it should work. Good luck!!

using namespace sql;
Driver *driver;
Connection *con;
try {
    driver = get_driver_instance();
    con = driver -> connect("tcp://", "root", "admin");
} catch (..) {
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

It may not be a connection string issue here. The remote server may not be setup for accepting outside connections. If so an outside client will not be able to see or connect to the database.

You could expose the database indirectly through a web-service, even something as simple as a JSON service. And your clients talk to the database through this service.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

first of all, u need to make sure the database server accept remote connection, and then you have the MySQL connector installed, and then you can just make a new MySqlConnection with the server name (ip address of the remote server and the port the mysql is installed), username, password, and database name.

you can read more on how to enable remote connection on mysqlhere[^]

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171114.1 | Last Updated 22 Apr 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100