语句错了: SqlStr="select * from Students where StudentID='" + DropDownList_Students.SelectedItem.Value + "'";
string SqlStr="select * from Students where StudentID=" + DropDownList_Students.SelectedItem.Value; 跟踪一下DropDownList_Students.SelectedItem.Value这个值是不是存在?我估计是这个值为空造成的错误
string SqlStr="select * from Students where StudentID=" + DropDownList_Students.SelectedItem.Value; --->string SqlStr="select * from Students where StudentID=" + DropDownList_Students.SelectedItem.Value.Tostring();
ap9906133是StudentID:StudentID是字符型的吗。。如果是这样。。string SqlStr="select * from Students where StudentID=" + DropDownList_Students.SelectedItem.Value;应该是。。string SqlStr="select * from Students where StudentID='" + DropDownList_Students.SelectedItem.Value + "'";吧。。
string SqlStr="select * from Students where StudentID=" + DropDownList_Students.SelectedItem.Value改为 int id=Convert.ToInt16(DropDownList_Students.SelectedItem.Value ) string SqlStr="select * from Students where StudentID="+ id
string SqlStr="select * from Students where StudentID=" + DropDownList_Students.SelectedItem.Value; 改为string SqlStr="select * from Students where StudentID=" + "'"+DropDownList_Students.SelectedItem.Value.Tostring().Trim()+"'";
SqlStr="select * from Students where StudentID='" + DropDownList_Students.SelectedItem.Value + "'";
--->string SqlStr="select * from Students where StudentID=" + DropDownList_Students.SelectedItem.Value.Tostring();
int id=Convert.ToInt16(DropDownList_Students.SelectedItem.Value )
string SqlStr="select * from Students where StudentID="+ id