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
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