protected void Button3_Click(object sender, EventArgs e) { SQLMHXY sQLMHXY = new SQLMHXY(); if (TextBox2.Text.ToString().Trim() == "" || TextBox1.Text.ToString().Trim() == "") { Response.Write("<script>javascript:alert('请输入完整的账户名或者密码');history.back();</script>"); Response.End(); } try { sQLMHXY.openDatabase(); String i = "SELECT TOP 1000 [ID],[NAME] ,[PASSWORD] FROM [MHXY].[dbo].[login]"; SqlDataReader dr = sQLMHXY.load(i); while (dr.Read()) { TextBox1.Text = dr[0].ToString().Trim(); TextBox2.Text = dr[1].ToString().Trim(); Response.Redirect("test.aspx"); Response.End(); } sQLMHXY.closeDatabase(); } catch (Exception ex) { Response.Write(ex.ToString()); } }
/// <summary> /// 点击编号管理; /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Menu1_MenuItemClick1(object sender, MenuEventArgs e) { sQLMHXY.openDatabase(); //配置sql语句 string sqlStr = "SELECT TOP 1000 [ID],[NAME] ,[PASSWORD] FROM [MHXY].[dbo].[login]"; //初始化查询所有编号 SqlDataAdapter da = sQLMHXY.gridViewData(sqlStr); sQLMHXY.closeDatabase(); DataSet data = new DataSet(); da.Fill(data, "table"); this.GridView1.DataSource = data; this.GridView1.DataBind(); Session["TaskTable"] = data; }
/// <summary> /// 查询表格并填充 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button5_Click(object sender, EventArgs e) { SQLMHXY sQLMHXY = new SQLMHXY(); sQLMHXY.openDatabase(); //配置sql语句,查询登录表所有信息 string sqlStr = System.Configuration.ConfigurationManager.AppSettings["sqlLogin1"].ToString(); SqlDataAdapter da = sQLMHXY.gridViewData(sqlStr); sQLMHXY.closeDatabase(); DataSet data = new DataSet(); da.Fill(data, "table"); this.GridView1.DataSource = data; this.GridView1.DataBind(); }