![](https://iknow-base.cdn.bcebos.com/lxb/notice.png)
vs编辑测试时出错:System.Data.SqlClient.SqlException:“用户 'sa' 登录失败。”
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Da...
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 HotelManagerBLL;
using HotelManagerModel;
namespace HotelManagerUI
{
public partial class frmLogin : Form
{
UserInfo user;
public UserInfo User
{
get { return user; }
set { user = value; }
}
public frmLogin()
{
InitializeComponent();
}
private void btnLogin_Click(object sender, EventArgs e)
{
string username = txtUsername.Text;
string pwd = txtPwd.Text;
user = UserInfoManager.Login(username, pwd); 此处出错出错出错出错!!求解
if (user == null)
{
MessageBox.Show("用户名不存在!!");
}
else
{
if (user.UserInfoId == -1)
{
MessageBox.Show("密码错误!!");
}
else
{
//MessageBox.Show("超级管理员");
frmMain main = new frmMain();
main.User = this.user;
main.Show();
this.Visible = false;
}
}
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.txtPwd.Text = "";
this.txtUsername.Text = "";
}
private void btnLogin_KeyPress(object sender, KeyPressEventArgs e)
{
}
}
} 展开
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HotelManagerBLL;
using HotelManagerModel;
namespace HotelManagerUI
{
public partial class frmLogin : Form
{
UserInfo user;
public UserInfo User
{
get { return user; }
set { user = value; }
}
public frmLogin()
{
InitializeComponent();
}
private void btnLogin_Click(object sender, EventArgs e)
{
string username = txtUsername.Text;
string pwd = txtPwd.Text;
user = UserInfoManager.Login(username, pwd); 此处出错出错出错出错!!求解
if (user == null)
{
MessageBox.Show("用户名不存在!!");
}
else
{
if (user.UserInfoId == -1)
{
MessageBox.Show("密码错误!!");
}
else
{
//MessageBox.Show("超级管理员");
frmMain main = new frmMain();
main.User = this.user;
main.Show();
this.Visible = false;
}
}
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.txtPwd.Text = "";
this.txtUsername.Text = "";
}
private void btnLogin_KeyPress(object sender, KeyPressEventArgs e)
{
}
}
} 展开
1个回答
2017-09-09
展开全部
vs编辑测试时出错:System.Data.SqlClient.SqlException:“用户 'sa' 登录失败。”
把你的ConnectionString 换成这个试试,
conn.ConnectionString = @"Data Source=localhost;database = 你的数据库名;Integrated security = true";
把你的ConnectionString 换成这个试试,
conn.ConnectionString = @"Data Source=localhost;database = 你的数据库名;Integrated security = true";
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询