using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace 数据库
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string str = @"Data Source=XHTCS1VXKSW7AP4;Initial Catalog=book_system;Integrated Security=True";
SqlConnection conn = new SqlConnection(str);
conn.Open();
string selectsql = "select * from Login where username='" + textBox1.Text.Trim() +"' and Userpass='" + textBox2.Text.Trim() +"'";
SqlCommand cmd = new SqlCommand(selectsql,conn);
cmd.CommandType = CommandType.Text;
SqlDataReader sdr;
sdr = cmd.ExecuteReader();
if (sdr.Read())
{
label3.Text = "登录成功";
this.Close();
}
else
{
label3.Text = "登录失败";
return;
}
}
}
}