using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace demo_Builder1
{
public partial class Form1 : Form
{
SqlConnection connection=new SqlConnection();
SqlCommand command=new SqlCommand();
SqlDataReader reader;
public Form1()
{
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.FixedSingle;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
connection.ConnectionString = "Data Source=.;Initial Catalog=Test_QQ;User ID=testassword=1";
command.Connection = connection;
string temp= string.Format("select count(*) from QQ_User where USER_NAME='{0}' and User_Password='{1}'", this.textBox1.Text, this.textBox2.Text);
command.CommandText = temp;
command.CommandType = CommandType.Text;
try
{
connection.Open();
// MessageBox.Show("数据库打开成功");
int test =Convert.ToInt32(command.ExecuteNonQuery());
if (test>0)
{
MessageBox.Show("登陆成功");
}
else
{
MessageBox.Show("登陆失败");
}
}
catch (Exception ex)
{
MessageBox.Show("数据库异常"+ex);
}
finally
{
connection.Close();
}
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
|