Advertisement

08.10.2005 at 11:44PM PDT, ID: 21523296
[x]
Attachment Details

Mysql, C# and PHP, remote connection to MySQL db with C#

Asked by loranne in C# Programming Language

Tags: mysql, remote, connection

I am experienced in the SQL query language and PHP and I am learning C#.  I would like to write a program in C# to connect to a remote Mysql database.  I already easily access the database using php and the following code.  The php code is run on the same server as where the Mysql db resides:

<?php
require_once("config_ip.php");
$dbpoint = mysql_pconnect("$dbhost", "$dbuname", "$dbpass");
$dbnpoint= mysql_select_db ("$dbname")or die(mysql_error());
$result=mysql_query("select player_name,count(*),IP_add,IP_ind_add from xxxdata GROUP BY IP_ind_add,player_name ") or die (mysql_error());
echo "<br><table border=\"1\">";

while ($row=mysql_fetch_array($result,MYSQL_ASSOC)) {
echo "<tr>";
while (list ($key,$value) = each($row)) {
 echo "<td>". $value."</td>"; }
echo "</tr>";}
echo "</table>";
//}    
?>

I would like to do essentially the same thing with a C# program or some flavor of C.  I have downloaded: MySQLDriverCS and am trying to use it.  But I am not sure if using MySQLDriverCS and C# is the best approach.   Any ideas would be greatly appreciated.

So I am trying to sort out the proper connection string:

 con = new MySQLConnection( new MySQLConnectionString("localhost",
                                                        "xxxdata",  //tablename
                                                        "theusername",
                                                        "thepassword").AsString );

I am pretty sure the tablename, theusername and thepassword settings are correct.  But I am not sure what to put for a host name.  Is it the IP address of the MySQL server I am connecting to, followed by the default port for MySQL 3306?  i.e. "205.166.305.6:3306".  I want to run this as a windows executable file, that will only work on an Internet connected computer.    

Input on the correct connection string would be great :)  I don't know if this is even possible to do in this manner with MySQLDriverCS, whether or not a remote connection is possible?Start Free Trial
[+][-]08.11.2005 at 12:05AM PDT, ID: 14649404

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: C# Programming Language
Tags: mysql, remote, connection
Sign Up Now!
Solution Provided By: Tasneem
Participating Experts: 3
Solution Grade: A
 
 
[+][-]08.11.2005 at 09:44AM PDT, ID: 14653289

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]01.24.2006 at 08:03AM PST, ID: 15776623

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.28.2006 at 02:14PM PST, ID: 15814455

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32