请帮帮我,我得到 ---MessageBox.Show("登录不成功,再试一次!"); ----每次我输入正确的用户名并通过。可能是什么问题?谢谢
我似乎不想验证..
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data.OleDb;
namespace posSystem
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnLogin_Click(object sender, EventArgs e)
{
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=userName.accdb");
OleDbCommand cmd = new OleDbCommand("Select * From userAndPass Where ID = @id AND pass = @password", conn);
cmd.Parameters.AddWithValue("@id", txtBoxUserName.Text);
cmd.Parameters.AddWithValue("@password", txtBoxPassword.Text);
conn.Open();
OleDbDataReader re = cmd.ExecuteReader();
if(re.Read())
{
MessageBox.Show("Login Successfull");
}
else{
MessageBox.Show("Login NOT Successfull, Try again!");
}
}
}
}