system.data.sqlclient.sqlexception类型的未经处理的异常出现在system.data.dll

yanlong662 2011-11-18 02:51:47
源代码如下
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)
{

}


}
}


大神帮忙,小弟不胜感激
...全文
112 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
bdmh 2011-11-18
  • 打赏
  • 举报
回复
调试啊,就这么几句话
宝_爸 2011-11-18
  • 打赏
  • 举报
回复
哪里异常,以及异常信息。尤其是stack trace

111,125

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧