如何使用凭据,例如:login.cs中的员工社会保险号以另一种形式反映出来,例如:expense.cs无需手动键入

问题描述

这是具有用户在登录时输入的凭据的登录页面。

private void simpleButton1_Click(object sender,EventArgs e)
{
    try
    {
        string myConnection = "datasource = localhost;database = imprest system;port = 3306;username = root;password = ''";
        MySqlConnection myConn = new MySqlConnection(myConnection);
        MySqlCommand SelectCommand = new MySqlCommand("select * from user where **employeeSSN = '" + employeeSSN_txt.Text + "'** and Password = '" + pass_txt.Text + "'",myConn);

        MySqlDataReader myreader;
        myConn.Open();
        myreader = SelectCommand.ExecuteReader();
        int count = 0;
        while (myreader.Read())
        {
            count = count + 1;
        }
        if (count == 1)
        {
            Dashboard dashboard = new Dashboard();
            dashboard.ShowDialog();
        }
        else if (count > 1)
        {
            XtraMessageBox.Show("Error logging in");
        }
        else
        {
            XtraMessageBox.Show("Incorrect Username and Password.Try Again");
        }
    }
    catch (Exception ex)
    {
        XtraMessageBox.Show(ex.Message);
    }
}

我想使用Employee社保号而无需手动输入的代码部分。

private void simpleButton1_Click(object sender,EventArgs e)
{
    string myConnection = "datasource = localhost;database = imprest system;port = 3306;username = root;password = ''";
    MySqlConnection myConn = new MySqlConnection(myConnection);
    MySqlCommand InsertCommand = new MySqlCommand("insert into expenseaccount where ExpenseType = '" + Expense_txt + "' and Amount = '" + Amount_txt + "' and **employeeSSN =** ",myConn);

    MySqlDataReader myreader;
    myConn.Open();
    myreader = InsertCommand.ExecuteReader();
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...