OdbcDataReader q = dbc.Query("SELECT * FROM `posts` WHERE `id`=" + id.ToString());
if (q.RecordsAffected < 1)
    this.Exists = false;
    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)

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;
Was it helpful?


I think you should use DataReader.Read method before you can get data from it.

this.Author = q.GetString(6);

And I recommend using a using block with you DataReader and Command objects

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow