command.CommandText = "SELECT * FROM student details WHERE StudentID=@StudentID";
如何修改它以在上述程序语句中包含用户输入学生ID?
答案 0 :(得分:1)
如果我理解正确,请使用:
command.Parameters.AddWithValue("@StudentID", int.Parse(yourTextBox.Text));
答案 1 :(得分:1)
我猜你想要这个(虽然你的问题有点模糊):
int studentId;
if (int.TryParse(textbox1.Text, out studentId)) {
command.Parameters.AddWithValue("@StudentID", studentId);
}