我在 c# 中有我的 windows 应用程序的登录页面。即使我以大写形式输入用户名和密码,即打开大写字母,登录仍然成功。
这不应该是这种情况,因为数据库中的条目是小写的。
public partial class frmlogin : Form
{
SqlConnection con = new SqlConnection("Data Source=TH07L019;Initial Catalog=procurement;Integrated Security=True");
DataTable dt = new DataTable();
SqlCommand cmd = new SqlCommand();
SqlDataAdapter adp = new SqlDataAdapter();
public frmlogin()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
cmd.Connection = con;
}
private void button1_Click(object sender, EventArgs e)
{
con.Open();
cmd.CommandText = "select * from login where username='" + txtusername.Text + "' and password='" + txtpassword.Text + "'";
adp.SelectCommand = cmd;
adp.Fill(dt);
if (dt.Rows.Count > 0)
{
frmmain main = new frmmain();
main.Show();
}
else
{
MessageBox.Show("Please enter correct name and passowrd", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtusername.Clear();
txtpassword.Clear();
}
con.Close();
}
}
如何解决这个问题呢