im trying to get the specialization identifier from the Specializationtbl table using C # MSVS 2008, and the table includes SpecializationName and SpecializationID next to some other lines, and my question is related to some error “No data to present”, the command goes like below:
SqlCommand READSpecID = new SqlCommand("SELECT * FROM Specializationtbl WHERE SpecializationName='" + comboBox1.Text + "'" , DBcnction);
DBcnction.Open();
SqlDataReader ReadSpecID_ = READSpecID.ExecuteReader();
ReadSpecID_.Read();
int SpecID_ = Convert.ToInt16(ReadSpecID_["SpecID"].ToString());
DBcnction.Close();
I also tried to select “SpecID” instead of all the lines, but can not seem to have sealed the request correctly and kept getting the “Missing data” error, any idea where I am making the error?
source
share