MY新 2013-07-29 18:10 采纳率: 25%
浏览 953

当我登录的时候点击登录按钮的事件

private void button1_Click(object sender, EventArgs e)
{
try
{
//SqlConnection con = new SqlConnection(strcon);
//DataSet ds = new DataSet();
//SqlDataAdapter sda = new SqlDataAdapter(strcon, con);
//sda.Fill(ds);
//return ds;

            string sql = string.Format("select uname,password,userrole from tb_userinfo where uname={0}", this.tb_name.Text.Trim());
            DataSet ds = sqlHple.GetDateSet(sql);
            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                //判断当前用户登录进来的密码是否与传进来的密码相等
                if (ds.Tables[0].Rows[0]["uname"].ToString().Equals(this.tb_pwd.Text.Trim()))
                {
                    //对用户名和用户角色进行赋值
                    Program.username = ds.Tables[0].Rows[0]["uname"].ToString();
                    Program.userrole = ds.Tables[0].Rows[0]["userrole"].ToString();
                    //是否显示主窗体
                    Program.isshowmina = true;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("用户密码输入错误");
                }

            }
            else
            {
                MessageBox.Show("用户名输入错误");
                return;
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
}

}
他说'='附件有语法错误 但是看来看去去也不知道有什么错误 sql语句没有错呀

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥100 关于使用MATLAB中copularnd函数的问题
    • ¥20 在虚拟机的pycharm上
    • ¥15 jupyterthemes 设置完毕后没有效果
    • ¥15 matlab图像高斯低通滤波
    • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
    • ¥15 钢筋实图交点识别,机器视觉代码
    • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
    • ¥50 400g qsfp 光模块iphy方案
    • ¥15 两块ADC0804用proteus仿真时,出现异常
    • ¥15 关于风控系统,如何去选择