While executing the following code in Asp.net with C#,getting an exception like "No data exists for the row/column."
OdbcConnection DbConnection = new OdbcConnection(ConfigurationManager.AppSettings["ConnectionStr"]);
DbConnection.Close();
string cmdText = "SELECT Team_ID FROM team_details WHERE Team_Code=?";
OdbcCommand cmd = new OdbcCommand(cmdText, DbConnection);
cmd.Parameters.Add("?Code", OdbcType.VarChar).Value = tbCode.Text; DbConnection.Open(); OdbcDataReader DR = cmd.ExecuteReader();
DR.Read();
if (DR.GetValue(0) != DBNull.Value)
{ args.IsValid = false; } else { args.IsValid = true; } DbConnection.Close();
I'm using Visual Studio 2008 and MySQL. and MySql ODBC connector 5.1 and MDAC2.8.
Please guide me how to resolve this.

Suthish NairRank #92 · 22.8K reputationPosted Jun 25, 2011, 3:37 AM EDT
//if(DR.HasRows)
//{
while(DR.Read())
{
if (DR.GetValue(0) != DBNull.Value)
{ args.IsValid = false; } else { args.IsValid = true; }
}
//}
Sam HobbsRank #108 · 20.5K reputationPosted Jun 25, 2011, 8:51 PM EDT
Able Alias3 reputationPosted Jun 25, 2011, 8:55 PM EDT