I figured out that I was comparing the wrong things. You can't compare the strings you have to compare the dataAdapters. Unfortunatly I'm still getting thame results.
Here is my new code. I am comparing myTestcom and myTestcom2. Any ideas why they aren't being seen as equal by the if statement?
string SelectTest = "SELECT Smile_results.student_ID, smile_results.Held_Key FROM smile_results WHERE ((smile_results.Student_ID = '"+StudentID+"') and (smile_results.Held_Key = '"+HeldKey+"'))";
string SelectTest2 = "SELECT Smile_results.student_ID, smile_results.Held_Key FROM smile_results WHERE ((smile_results.Student_ID = null) and (smile_results.Held_Key = null))";
SqlConnection myConnection2 = new SqlConnection(ConnectionString);
SqlDataAdapter myCommand2 = new SqlDataAdapter(SelectCommand, myConnection2);
SqlDataAdapter myTestcom = new SqlDataAdapter(SelectTest, myConnection2);
SqlDataAdapter myTestcom2 = new SqlDataAdapter(SelectTest2, myConnection2);
if (myTestcom==myTestcom2)
{
DataSet ds = new DataSet();
myCommand2.Fill(ds);
DataGrid2.DataSource = ds;
DataGrid2.DataBind();
}
|