62,047
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;
public partial class Admin_AdminLogin : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void AdminButton1_Click(object sender, EventArgs e)
{
string us = TextBox1.Text;
string pw = TextBox2.Text;
SqlConnection conn = new SqlConnection();
conn.ConnectionString= "Data Source=.;Initial Catalog=ASP.NET_project;Persist Security Info=True;User ID=sa;Password=123456";
conn.Open();
using (OleDbConnection cmd = new OleDbConnection())
{
cmd.Connection = conn;
string sql = "SELECT ASP.NET_project FROM AdminTable WHERE username" + TextBox1 + "AND password" + TextBox2 + "'";
cmd.CommandText = sql;
if (Convert.ToInt32(cmd.Executescalar()) > 0)
{ Label1.Text = "登录成功"; }
else
{ Label1.Text = "登录失败"; }
}
}
}