system.data.sqlclient.sqlexception类型的未经处理的异常出现在system.data.dll
贴上源代码usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSyst...
贴上源代码
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 宾馆客房管理系统
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (IsUserIdentify() == true)
{
Form2 form1 = new Form2();
form1.Show();
this.Visible = false;
}
else
{
MessageBox.Show("用户名或密码错误");
}
}
private bool IsUserIdentify()
{
SqlConnection Conn = new SqlConnection("Data Source=.;Initial Catalog=客房管理系统;Integrated Security=True");
Conn.Open();
string sql = "SELECT Name,PassWord FROM Admin WHERE Name='" + this.textBox1.Text + "'and PassWord='" + this.textBox2.Text + "'";
SqlCommand Cmd = new SqlCommand(sql, Conn);
SqlDataReader reader = Cmd.ExecuteReader();
if (reader.Read())
{
return true;
}
else
{
return false;
}
Conn.Close();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
} 展开
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 宾馆客房管理系统
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (IsUserIdentify() == true)
{
Form2 form1 = new Form2();
form1.Show();
this.Visible = false;
}
else
{
MessageBox.Show("用户名或密码错误");
}
}
private bool IsUserIdentify()
{
SqlConnection Conn = new SqlConnection("Data Source=.;Initial Catalog=客房管理系统;Integrated Security=True");
Conn.Open();
string sql = "SELECT Name,PassWord FROM Admin WHERE Name='" + this.textBox1.Text + "'and PassWord='" + this.textBox2.Text + "'";
SqlCommand Cmd = new SqlCommand(sql, Conn);
SqlDataReader reader = Cmd.ExecuteReader();
if (reader.Read())
{
return true;
}
else
{
return false;
}
Conn.Close();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
} 展开
2个回答
展开全部
SqlConnection Conn = new SqlConnection("Data Source=.;Initial Catalog=客房管理系统;Integrated Security=True");
添加.\\SqlExpress
SqlConnection Conn = new SqlConnection("Data Source=.\\SqlExpress;Initial Catalog=客房管理系统;Integrated Security=True");
添加.\\SqlExpress
SqlConnection Conn = new SqlConnection("Data Source=.\\SqlExpress;Initial Catalog=客房管理系统;Integrated Security=True");
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
您可能需要的服务
百度律临官方认证律师咨询
平均3分钟响应
|
问题解决率99%
|
24小时在线
立即免费咨询律师
17928人正在获得一对一解答
昆明彩云之南5分钟前提交了问题
郑州都市传说6分钟前提交了问题
郑州都市传说6分钟前提交了问题