c# - 为什么数据库没有响应我的 c# PROGRAM?
问题描述
当我运行程序时显示无效登录,请检查用户名和密码。我也检查了我的数据库。数据库没问题。我使用了基于服务的数据库
这是我的登录按钮
private void btnlogin_Click(object sender, EventArgs e)
{
try {
SqlConnection conn = new SqlConnection(@"Data Source=
(LocalDB)\MSSQLLocalDB;AttachDbFilename=E:\Study
Material\c#\practicle\ColourManagement\ColourManagement\CMSdatabase.mdf;Integrated
Security=True;");
SqlDataAdapter sda = new SqlDataAdapter("select * from Authenticate where username='" + txtusername.Text + "' and password='" + txtpassword.Text + "' ", conn);
DataTable dt = new DataTable();
sda.Fill(dt);
这是我的 if 条件
if (dt.Rows.Count > 0)
{
MessageBox.Show("Login sucess Welcome to Homepage ");
}
else
{
MessageBox.Show("Invalid Login please check username and password");
}
}
catch(Exception e01)
{
MessageBox.Show("Error"+e01);
}
}
解决方案
推荐阅读
- firebase - 如何从 Firebase 动态链接访问 Ionic 应用中的特定页面?
- c++ - 我无法理解特定的语法
- typescript - 等价于部分
例如方法? - aws-lambda - “SAM 本地调用”是否支持 EFS?
- c# - SignOutAsync 不退出
- javascript - 将值传递给 ASP.NET MVC 控制器时具有空项的 JavaScript 数组
- akka - 无法让 akka 流/alpakka S3 在简单的情况下工作
- css - 导航元素未对齐+重叠问题
- docker - 使用 WSL2 时如何为 docker for windows 运行 iptables 命令
- mysql - 如何强制 MySQL 查询不返回任何内容