更改密码时出现问题 [英] Problem in changing the password

查看:58
本文介绍了更改密码时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码用于更改密码。有一个问题: -

The code is for changing password.There is a problem :-

System.Data.OleDb.OleDbException: Incorrect syntax near ','.//Line 83:  da.Fill(ds);

代码如下: -

Code is as below:-

edit.aspx:-
        OLD PASSWORD

        <asp:TextBox ID="TextBox1" runat="server" Width="209px" TextMode="Password"></asp:TextBox>

        NEW PASSWORD

        <asp:TextBox ID="TextBox2" runat="server" Width="209px" TextMode="Password"></asp:TextBox>

        CONFIRM PASSWORD
        <asp:TextBox ID="TextBox3" runat="server" Width="209px" TextMode="Password" ></asp:TextBox>


        <asp:Button ID="Save" runat="server" Text="Save" onclick="Save_Click" />

 edit.aspx.cs:-

protected void Save_Click(object sender, EventArgs e)
    {
        string a, b;
        cn.Open();
        OleDbDataAdapter da = new OleDbDataAdapter("select Name,Password from staff where User_Id='" + Session.Contents["txtuid"].ToString() + "',Password='" + TextBox1.Text + "'",cn);
        DataSet ds = new DataSet();
        da.Fill(ds);
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)

        {

            a = ds.Tables[0].Rows[i]["User_Id"].ToString();

            b = ds.Tables[0].Rows[i]["Password"].ToString();



            if (a == Session.Contents["txtuid"].ToString() && b == TextBox1.Text)

            {

                OleDbDataAdapter sda = new OleDbDataAdapter("update staff set Password = '" + TextBox2.Text + "',cpassword='" + TextBox3.Text + "' where User_Id ='" + Session.Contents["txtuid"].ToString() + "'", cn);

                sda.Fill(ds);



                Response.Write("&lt;script>alert('Password Changed');</script>");
            }
            else
            {
                Response.Write("&lt;script>alert('Password Mismatch');</script>");
             }
        } cn.Close();
}









[Agent_Spock]

- 更改了问题的标题

- 在问题中添加了内容

- 使问题的内容相关





[Agent_Spock]
- Changed the header of the question
- Added content to the question
- Made the content of the question relevant

推荐答案

嗯异常很清楚。



你说:

Well the exception is very clear.

You state:
OleDbDataAdapter da = new OleDbDataAdapter("select Name,Password from staff where User_Id='" + Session.Contents["txtuid"].ToString() + "',Password='" + TextBox1.Text + "'",cn);





之前,密码应该用AND替换



the , before Password should be replace with AND


这篇关于更改密码时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆