以下是登陆procedure:
private void button1_Click(object sender, System.EventArgs e)
{
SqlConnection sqlConnection1=new SqlConnection("Persist
Security Info=False;User ID=NIRVANA;Initial Catalog=yifufang;Data Source=(local)");
SqlCommand sqlCommand1=new SqlCommand();
sqlCommand1.Connection=sqlConnection1;
sqlConnection1.Open();
sqlCommand1.CommandText="select count(*) from operator where 管理员姓名 = '" + textBox1.Text + "' and 管理员密码 = '" + textBox2.Text + "'";
string returnValue=sqlCommand1.ExecuteScalar().ToString();
if (returnValue=="0")
MessageBox.Show("您输入的用户名或者密码错误,请重新输入!","登录",MessageBoxButtons.OK,MessageBoxIcon.Warning);
else
{
Form1 MainForm=new Form1();//进入主界面
MainForm.Show();
}
sqlConnection1.Close();
}运行以后可以编译成功,但是输入用户名和密码以后,发生异常,提示系统错误!
各位达人,帮忙啊
private void button1_Click(object sender, System.EventArgs e)
{
SqlConnection sqlConnection1=new SqlConnection("Persist
Security Info=False;User ID=NIRVANA;Initial Catalog=yifufang;Data Source=(local)");
SqlCommand sqlCommand1=new SqlCommand();
sqlCommand1.Connection=sqlConnection1;
sqlConnection1.Open();
sqlCommand1.CommandText="select count(*) from operator where 管理员姓名 = '" + textBox1.Text + "' and 管理员密码 = '" + textBox2.Text + "'";
string returnValue=sqlCommand1.ExecuteScalar().ToString();
if (returnValue=="0")
MessageBox.Show("您输入的用户名或者密码错误,请重新输入!","登录",MessageBoxButtons.OK,MessageBoxIcon.Warning);
else
{
Form1 MainForm=new Form1();//进入主界面
MainForm.Show();
}
sqlConnection1.Close();
}运行以后可以编译成功,但是输入用户名和密码以后,发生异常,提示系统错误!
各位达人,帮忙啊
解决方案 »
- 用socket接收数据,如何判断结束或别的解决方法?
- 怎么让dos窗口的状态信息实时显示在winform界面上
- byte类型数组,转换为string!!!怎么弄?
- 关于用C#编写软件的一些问题请教!
- 弱弱地问,c#.net重置页面(刷新页面)的语句是?
- 使用NDoc1.3生成文档时,LangID选了2052后,有些空格的地方变成了“?”,怎么解决?
- Devpress控件中的Grid网格如何在其中直接添加数据,绑定后不像Mircrosoft中DataGrid类似可直接进行文本输入?
- C# DES加密问题.
- WPF,这个控件的宽度为什么没有效果?
- 请问如何设置文件过滤器?
- 我就像知道如果我用socket监听之后,又想让机子停止监听,并且已经建立的socket连接都关掉,
- 在C#中读数据库数据的问题
Security Info=False;User ID=NIRVANA;Initial Catalog=yifufang;Data Source=(local)");
是否少了password等
SqlConnection sqlConnection1=new SqlConnection("Server=localhost;UID=NIRVANA;pwd=pwd;database=yifufang;");
编译依然可以通过,输入用户名密码以后提示系统错误,程序停在
sqlCommand1.CommandText="select count(*) from operator where 管理员姓名 = '" + textBox1.Text + "' and 管理员密码 = '" + textBox2.Text + "'";
这一句,就不执行了!急。
未处理的“System.Data.SqlClient.SqlException”类型的异常出现在 system.data.dll 中。其他信息: 系统错误。