Page 1 of 1

No associative arrays for MySQL?

Posted: Mon 12 Feb 2007 15:22
by Fuitad
Hello,

I'm playing with the Trial and I'm comparing it with the MySQL .net connector (version 5).

Right now I use the following functions

Code: Select all

LoggedInID = sqldr.GetInt32("userid");
LoggedInAs = sqldr.GetString("realname");
(sqldr being a MySqlDataReader)

I tried to run the same commands in mysqldirect and was suprised to see that it didin't work. By looking in the help file, I saw this:

Code: Select all

public override int GetInt32(int i);
public override string GetString(int i);
Now, I'm asking, did I get all of this wrong? Is there no way to refence to a data column by it's name? Because frankly, I've always thought that reading data by column index was a bad move as it's not as reliable as column name.

Thank you for your answer.

Posted: Wed 14 Feb 2007 12:49
by Alexey
SqlDataReader doesn't have such overloads as well.
You can use something like this:

Code: Select all

LoggedInAs = sqldr["realname"];

Posted: Thu 15 Feb 2007 20:17
by Fuitad
Even better! :)

Thanks

Posted: Fri 16 Feb 2007 08:24
by Alexey
You are welcome.