做了一个简单的登录页面 但是点击登录按钮时 程序没有反应 并且自动关闭
我有三个窗体登录 Menu_Form.cs
管理员admin_Form.cs
用户user_Form.cs
管理员和用户窗体还没有编码
代码如下:
Menu_Form.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace activity
{
public partial class Menu_Form : Form
{
public Menu_Form()
{
InitializeComponent();
}
private string sqlconnection()
{
string mysqlconstr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=" + AppDomain.CurrentDomain.BaseDirectory + @"database\sql_gqproject.mdf;Integrated Security=SSPI;Connect Timeout 30;User Instance=True";
return mysqlconstr;
}
private void button1_Click(object sender, EventArgs e)
{
if (user_comboBox.Text.Length == 0)
{
MessageBox.Show("请选择用户名!", "用户名提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Asterisk);
return;
}
using (SqlConnection con = new SqlConnection(this.sqlconnection()))
{
con.Open();
SqlCommand cmd = new SqlCommand(@"SELECT pwd FROM user_Table WHERE name='" + user_comboBox.Text + @"'", con);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adapter.Fill(ds);
con.Close();
if (this.pwd_textBox.Text == ds.Tables[0].Rows[0].ItemArray.GetValue(0).ToString().Trim())
{
if (this.user_comboBox.Text == "admin")
{
admin_Form tmp = new admin_Form();
tmp.Show();
}
else
{
user_Form tmp = new user_Form();
tmp.Show();
}
}
else
{
MessageBox.Show("您输入的密码有误,请核对后再登陆,谢谢使用!", "提示!", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Asterisk);
}
}
}
private void button2_Click(object sender, EventArgs e)
{
if (MessageBox.Show("是否退出系统?", "退出", System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Asterisk) == DialogResult.OK)
Application.Exit();
else
return;
}
private void user_comboBox_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
admin_Form.cs
user_Form.cs
暂时为空 --------------------编程问答-------------------- 就是点击登录的时候 没有反应 请问要怎样修改? --------------------编程问答-------------------- 断点调试 --------------------编程问答--------------------
补充:.NET技术 , C#