MySql Data Read Problem?

D

Dakkar

I write a program for connecting to mysql database and read the values
that i want from the database so i wrote my code like this


RegistryKey uo =
Registry.LocalMachine.OpenSubKey("SOFTWARE\\Origin Worlds
Online\\Ultima Online\\1.0");
String folder =
uo.GetValue("ExePath").ToString();

String uopath = Path.GetDirectoryName(folder);
StreamWriter writer = new StreamWriter(uopath +
@"\login.cfg");
try
{
OdbcConnection mysqlcon;
OdbcCommand mysqlcom = new OdbcCommand();
mysqlcon = new OdbcConnection("DRIVER={MySQL
ODBC 3.51 Driver};" + "SERVER=localhost;" +
"DATABASE=connector;" + "UID=root;" +
"PWD=root;");
StringBuilder uobuild = new StringBuilder();
uobuild.Append("select ip,port from baglanti
where id=1");
mysqlcom.CommandText = uobuild.ToString();
OdbcDataReader resultuo =
mysqlcom.ExecuteReader(CommandBehavior.CloseConnection);
String ip =
resultuo.GetValue(0).ToString();

writer.WriteLine("LoginServer="+ip+",5631");
writer.Close();
}

catch
{
this.txt1.Text += "Dosya Bulunamadi";
}


but its not working what is the problem?

Note:My program should take both ip and port part from mysql and write
it to file that i want

Thanks
 
N

Nicholas Paldino [.NET/C# MVP]

Dakkar,

You really should be playing Worlds of Warcraft instead, much better
MMORPG IMO. =)

How is it not working? Is ip a string or is it an integer? It could be
that it is an integer made up of the four values that make up the IP ranges.
If this is the case, you will have to pull it apart, using an overload of
the IPAddress class.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Dakkar said:
I write a program for connecting to mysql database and read the values
that i want from the database so i wrote my code like this


RegistryKey uo =
Registry.LocalMachine.OpenSubKey("SOFTWARE\\Origin Worlds
Online\\Ultima Online\\1.0");
String folder =
uo.GetValue("ExePath").ToString();

String uopath = Path.GetDirectoryName(folder);
StreamWriter writer = new StreamWriter(uopath +
@"\login.cfg");
try
{
OdbcConnection mysqlcon;
OdbcCommand mysqlcom = new OdbcCommand();
mysqlcon = new OdbcConnection("DRIVER={MySQL
ODBC 3.51 Driver};" + "SERVER=localhost;" +
"DATABASE=connector;" + "UID=root;" +
"PWD=root;");
StringBuilder uobuild = new StringBuilder();
uobuild.Append("select ip,port from baglanti
where id=1");
mysqlcom.CommandText = uobuild.ToString();
OdbcDataReader resultuo =
mysqlcom.ExecuteReader(CommandBehavior.CloseConnection);
String ip =
resultuo.GetValue(0).ToString();

writer.WriteLine("LoginServer="+ip+",5631");
writer.Close();
}

catch
{
this.txt1.Text += "Dosya Bulunamadi";
}


but its not working what is the problem?

Note:My program should take both ip and port part from mysql and write
it to file that i want

Thanks
 
D

Dakkar

No that ip means
a mysql table data i'm keeping the ip inside of the mysql table as a
varchar(string) like 127.0.0.1 so i just want to pull that data from
mysql to c#
 
Top