While executing the following code in ASP.NET with C#, I am 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. I'm using MySql ODBC connector 5.1 and MDAC2.8.
Please guide me how to resolve this.