ASP.NET做检索系统遇到的问题
来源:百度知道 编辑:UC知道 时间:2024/05/16 18:15:38
public partial class Search : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
String zhutici = Request.Form.Get("TextBox1");
String aim = DropDownList1.SelectedValue;
String sqlconn = "server=localhost;uid=sa;pwd=gao;database=VS2007;Trusted_Connection=no";
SqlConnection myConnection = new SqlConnection(sqlconn);
//打开数据库
myConnection.Open();
if( aim =="标题")
sql = "select * from Thesis where Thesis_title='" + zhutici + "'";
else if( aim=="作者")
sql = "select * from Thesis where Thesis_aut
protected void Button1_Click(object sender, EventArgs e)
{
string sql;
String zhutici = Request.Form.Get("TextBox1");
String aim = DropDownList1.SelectedValue;
String sqlconn = "server=localhost;uid=sa;pwd=gao;database=VS2007;Trusted_Connection=no";
SqlConnection myConnection = new SqlConnection(sqlconn);
//打开数据库
myConnection.Open();
if (aim == "标题")
sql = "select * from Thesis where Thesis_title='" + zhutici + "'";
else if (aim == "作者")
sql = "select * from Thesis where Thesis_author='" + zhutici + "'";
else if (aim == "种属")
sql = "select * from Thesis where Thesis_type='" + zhutici + "'";