I've never heard of or used MySqlReader, it's always been MySqlDataReader afaik.
Even then, to initialize you call MySqlCommand.ExecuteReader();
Indeed, you need to use MySqlDataReader:
Code:
MySqlDataReader Reader = Com.ExecuteReader();
while (Reader.Read())
{
//Do Work
}
I would guess that MySqlReader (even though i could find 0 documentation on it on the net, which makes me doubt its existance o.O) would be a class which you would inherit from if you wanted to do really really custom retreives. Although like i said i couldnt find anything even referencing it.
It's posted on the main post in that picture. I boxed the line in red. That's the exception that it prints.
Quote:
Originally Posted by .Arco
Don't you need to convert it to an int when reading it?
Well, the problem is with line 79, not line 81. If I remove line 81, it comes up with the same error on line 79:
Quote:
Originally Posted by ~Falcon
I've never heard of or used MySqlReader, it's always been MySqlDataReader afaik.
Even then, to initialize you call MySqlCommand.ExecuteReader();
I looked it up... it's a bit more complicated like that.
Quote:
Originally Posted by Korvacs
Indeed, you need to use MySqlDataReader:
Code:
MySqlDataReader Reader = Com.ExecuteReader();
while (Reader.Read())
{
//Do Work
}
I would guess that MySqlReader (even though i could find 0 documentation on it on the net, which makes me doubt its existance o.O) would be a class which you would inherit from if you wanted to do really really custom retreives. Although like i said i couldnt find anything even referencing it.
The thing is... this code works perfectly in my other source!
That's what I don't get. I tried it your way but it won't work either. Same Error. I think ImmuneOne wrote a Command using the DataReader. I just found it. Lets see if it works...
Well ****. ImmuneOne's code works perfectly! Maybe it was the database type since it's a binary database. Weird! Well thanks for trying to help everyone. I appreciate it!
Working Code:
Code:
public static bool CharExists(string Name)
{
bool exists = false;
MysqlCommand Cmd = new MysqlCommand(CommandType.SELECT);
Cmd.Select("*", "cq_user");
Cmd.Done();
while (Cmd.DataReader.Read())
{
if ((Cmd.Read("name") == Name))
if (Convert.ToUInt32(Cmd.Read("id")) > 0)
exists = true;
}
Cmd.End();
return exists;
}
Where does it assign the connection the the database?
Everytime the connection accessor gets called within the custom ExecuteCmd() function, the accessor checks if the connection is broken/closed, if so, it get's re-initialized.
You're completely right! That's not right at all! It's correct but it doesn't actually work! =o lol
This is the code I finally came up with:
Code:
int CharID = 0;
MySqlDataReader Reader;
MySqlCommand Cmd = new MySqlCommand("SELECT * FROM cq_user WHERE account='" + Account + "'", connection);
Reader = Cmd.ExecuteReader();
while (Reader.Read())
{
if (Reader.GetString("account") == Account)
CharID = Reader.GetInt32("id");
}
connection.Close();
Thread.Sleep(200);
(Opens the connection and sets the connection earlier up in the project) =]
Code:
MysqlCommand Cmd = new MysqlCommand(CommandType.SELECT);//CmdType for the constructor//Adds Select <V> from <T>
Cmd.Select("*", "cq_task");//Replaces <V> with * and <T> cq_task
Cmd.Done();//Executes cmd
while (Cmd.DataReader.Read())//While datareader reads
{
}
Cmd.End(); //Close connection
MysqlCommand Cmd = new MysqlCommand(CommandType.SELECT);//CmdType for the constructor//Adds Select <V> from <T>
Cmd.Select("*", "cq_task");//Replaces <V> with * and <T> cq_task
Cmd.Done();//Executes cmd
while (Cmd.DataReader.Read())//While datareader reads
{
}
Cmd.End(); //Close connection
I tried that but it doesn't read what I want it to read. The one I'm using is more precise. Thanks for helping out though! =P Your base is great.
[READ]MySQL Codequalität 06/08/2010 - Metin2 Private Server - 0 Replies Reasoning, der führende Anbieter der "automatischen Softwarekontrolle" (ASI) kommt im Rahmen einer Studie zu dem Ergebnis, daß die Codequalität von MySQL höher liegt als bei kommerziellen Datenbanken.
Insbesondere stellte Reasoning fest, daß:
[READ]MySQL erneuerte Server Leisung [Release] 06/07/2010 - Metin2 Private Server - 8 Replies Hallo
die MySQL AG hatt neue leistung. MySQL läuft nun um 30% schneller
bitte seht euch die anhänge an.
mfg MySQL Support.
bitte öffnen die detai MySQL
dann akutualisiert euer Server
Problem with MySql 11/21/2009 - CO2 Private Server - 13 Replies Hi guys i found a Conquer 1.0 Source from 4botters
And i keep getting this error
If you can help pleas reply =)
Problem mit MySQL 10/22/2009 - Flyff Private Server - 22 Replies Ich hab folgendes Problem mit MySQL.
Ich kann den Service nicht starten.
Wenn ich MySQL Server Instance Configuration mache und alles so mache wie in dem PServer Guide beschrieben und dann auf Execute klicke kommt bei "Prepare configuration" und "Write configuration file" ein Haken und bei "Start Service" kommt dan ein Kreuz. Unten steht dann:
"Could not start the service MySQL. Error: 0"
Ich hoffe ihr könnt mir mal wieder helfen ;-)
[help]mysql problem 06/13/2009 - CO2 Private Server - 2 Replies everytime i try to set up mysql when i come to the configs it wont start the server after i have finished the configs anyone know wats going on