Studentname:当用户输入Id或name并单击按钮时,应该显示详细信息....如何?
这里我的 OR 子句在 select 语句中不起作用:
public partial class StudentView : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["DBCS"].ConnectionString);
protected void Button1_Click(object sender, EventArgs e)
{
string str = "SELECT Registration.UsrFLname, Registration.UsrAddress, Students.STUID, Materials.BookID, Materials.BookName, Courses.CourseName, Courses.CourseFee FROM Courses INNER JOIN Materials ON Courses.BookID = Materials.BookID INNER JOIN Students ON Courses.STUID = Students.STUID AND Materials.STUID = Students.STUID INNER JOIN Registration ON Students.STUID = Registration.STUID AND Registration.UsrFLname = '" + TextBox1.Text + "' OR Students.STUID = '" + TextBox1.Text + "'";
con.Open();
SqlCommand cmd = new SqlCommand(str, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, str);
GDStudents.DataSource = ds;
GDStudents.DataBind();
}
}
谁能帮忙解决这个问题!!
预先感谢!!