OdbcDataReader q = dbc.Query("SELECT * FROM `posts` WHERE `id`=" + id.ToString());
if (q.RecordsAffected < 1)
{
this.Exists = false;
}
else
{
this.Exists = true;
this.Author = q.GetString(6);
}
The server returns No data exists for the row/column.
My database table is structured like this (screencap from phpMyAdmin)
http://1.img.anyhub.net/1243660397_6485910f8b3fc9ee3e2d93831ad554fd.png
By the way, dbc is just a database connection class of mine; the Query() function is this:
public OdbcDataReader Query(string QueryStr)
{
OdbcCommand q = new OdbcCommand(QueryStr, conn);
OdbcDataReader r = q.ExecuteReader();
return r;
}
I think you should use DataReader.Read method before you can get data from it.
And I recommend using a using block with you DataReader and Command objects