用户“用户名”登录失败;

发布于 2024-08-16 04:41:47 字数 4285 浏览 5 评论 0原文

我有一个表单,它从 MSSQL 服务器中的表中选择一堆行,现在,该表单用于更新数据,它做得正确,但是在我使用表单更新数据后,它会重定向回带有以下内容的页面:该表中所有行的数据网格,并允许我选择另一行进行更新,如果我再次选择刚刚更新的行,我会收到“用户‘slehan_ticketadmin’登录失败”。

现在我知道用户名/密码是正确的,因为我一分钟前使用了该表单来更新数据。我无法查看 SQL 错误日志,因为我的主机限制了我,但这是我的更新表单后面的代码。

namespace YakStudios_Support.ys_admin
{
    public partial class UpdateTicket : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                int ticketID = Convert.ToInt32(Request.QueryString["ticketID"]); // Grabs the ?ticketid number from the URL
                Ticket ticketBeingUpdated = TicketDatabase.selectTicketFromDatabase(sqlErrorLabel, ticketID); // Creates a new Ticket object to be used by the form to populate the text boxes

                /* Form Field Population */
                // Email
                emailTxt.Text = ticketBeingUpdated.getEmail();

                // Date Submitted
                dateSubText.Text = ticketBeingUpdated.getDateSubmitted().ToString();

                // Ticket Class
                classDropDown.SelectedValue = ticketBeingUpdated.getTicketClass();

                // Ticket Status
                statusDrop.SelectedValue = ticketBeingUpdated.getStatus();

                // Subject
                subjectTxt.Text = ticketBeingUpdated.getSubject();

                // Text
                textTxt.Text = ticketBeingUpdated.getTicketContent();
            }
        }

        protected void editBtn_Click(object sender, EventArgs e)
        {
            emailTxt.Enabled = true;
            dateSubText.Enabled = true;
            classDropDown.Enabled = true;
            statusDrop.Enabled = true;
            subjectTxt.Enabled = true;
            textTxt.Enabled = true;
        }

        protected void submitBtn_Click(object sender, EventArgs e)
        {
            int ticketID = Convert.ToInt32(Request.QueryString["ticketID"]); // Grabs the ?ticketid number from the URL
            DateTime convertedDate = Convert.ToDateTime(dateSubText.Text);
            Ticket ticketUpdated = new Ticket(emailTxt.Text, convertedDate, subjectTxt.Text, textTxt.Text, statusDrop.SelectedValue, classDropDown.SelectedValue);
            TicketDatabase.updateTicketInDatabase(ticketUpdated, sqlErrorLabel, ticketID);
            Response.Redirect("ticketqueue.aspx");
        }
    }
}

您看到的 Ticket 类只是一个保存从 SQL Server 更新/选择/删除的票证数据的类,这只是我以结构化方式修改/保存数据的一种简单方法。我想引起您的注意:

Ticket ticketBeingUpdated = TicketDatabase.selectTicketFromDatabase(sqlErrorLabel, ticketID);

我有另一个名为 TicketDatabase 的类,它有很多从数据库中插入/选择/更新/删除票证的方法。这是 selectTicketFromDatabase() 方法存根。

        public static Ticket selectTicketFromDatabase(Label sqlErrorLabel, int ticketID)
    {
        SqlCommand sqlCmd = new SqlCommand("SELECT * from yak_tickets");

        using (SqlConnection selSqlConn = new SqlConnection(sqlConn.ConnectionString))
        //using (sqlConn)
        {
            sqlCmd.Connection = selSqlConn;
            selSqlConn.Open(); // Open the SQL connection
            //sqlCmd.Connection = sqlConn;
            //sqlConn.Open(); // Open the SQL Connection

            SqlDataReader reader = sqlCmd.ExecuteReader();
            Ticket ticketReturning = null; // Initializes the ticketReturning but it's not allocated

            // Call during reading
            while (reader.Read())
            {
                /* Objects to hold values from reader */
                string emailString = reader["email"].ToString();
                DateTime dateSubbed = Convert.ToDateTime(reader["dateSubmitted"].ToString());
                string subjectString = reader["subject"].ToString();
                string textString = reader["ticketText"].ToString();
                string statusString = reader["statusid"].ToString();
                string classString = reader["ticketClass"].ToString();

                ticketReturning = new Ticket(emailString, dateSubbed, subjectString, textString, statusString, classString);
            }
            selSqlConn.Close();
            return ticketReturning;
        }
    }

我将在本地主机服务器上对此进行测试,看看是服务器还是我的代码导致了错误,但我仍然愿意接受对此特定问题的建议/支持。

提前致谢!

I have a form that selects a bunch of rows from a table in my MSSQL server, now, this form is used to update data, which it does correctly, after I update the data using the form however, it redirects back to a page with a datagrid of all the rows in that table, and allows me to select another row to update, if I select the row I just updated again, I'm greeted with "Login failed for user 'slehan_ticketadmin'."

Now I know the username/password are correct, because I used the form a minute ago in order to update the data. I can't view the SQL Error Logs because my host limits me, but here is my code behind for the update form.

namespace YakStudios_Support.ys_admin
{
    public partial class UpdateTicket : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                int ticketID = Convert.ToInt32(Request.QueryString["ticketID"]); // Grabs the ?ticketid number from the URL
                Ticket ticketBeingUpdated = TicketDatabase.selectTicketFromDatabase(sqlErrorLabel, ticketID); // Creates a new Ticket object to be used by the form to populate the text boxes

                /* Form Field Population */
                // Email
                emailTxt.Text = ticketBeingUpdated.getEmail();

                // Date Submitted
                dateSubText.Text = ticketBeingUpdated.getDateSubmitted().ToString();

                // Ticket Class
                classDropDown.SelectedValue = ticketBeingUpdated.getTicketClass();

                // Ticket Status
                statusDrop.SelectedValue = ticketBeingUpdated.getStatus();

                // Subject
                subjectTxt.Text = ticketBeingUpdated.getSubject();

                // Text
                textTxt.Text = ticketBeingUpdated.getTicketContent();
            }
        }

        protected void editBtn_Click(object sender, EventArgs e)
        {
            emailTxt.Enabled = true;
            dateSubText.Enabled = true;
            classDropDown.Enabled = true;
            statusDrop.Enabled = true;
            subjectTxt.Enabled = true;
            textTxt.Enabled = true;
        }

        protected void submitBtn_Click(object sender, EventArgs e)
        {
            int ticketID = Convert.ToInt32(Request.QueryString["ticketID"]); // Grabs the ?ticketid number from the URL
            DateTime convertedDate = Convert.ToDateTime(dateSubText.Text);
            Ticket ticketUpdated = new Ticket(emailTxt.Text, convertedDate, subjectTxt.Text, textTxt.Text, statusDrop.SelectedValue, classDropDown.SelectedValue);
            TicketDatabase.updateTicketInDatabase(ticketUpdated, sqlErrorLabel, ticketID);
            Response.Redirect("ticketqueue.aspx");
        }
    }
}

The Ticket class you see, is just a class that holds the data for the tickets that are updated/selected/deleted from the SQL Server, it's just an easy way for me to modify/hold data in a structured way. I want to bring your attention to the line:

Ticket ticketBeingUpdated = TicketDatabase.selectTicketFromDatabase(sqlErrorLabel, ticketID);

I have another class called TicketDatabase that has a bunch of methods that insert/select/update/delete tickets from the database. Here is the selectTicketFromDatabase() method stub.

        public static Ticket selectTicketFromDatabase(Label sqlErrorLabel, int ticketID)
    {
        SqlCommand sqlCmd = new SqlCommand("SELECT * from yak_tickets");

        using (SqlConnection selSqlConn = new SqlConnection(sqlConn.ConnectionString))
        //using (sqlConn)
        {
            sqlCmd.Connection = selSqlConn;
            selSqlConn.Open(); // Open the SQL connection
            //sqlCmd.Connection = sqlConn;
            //sqlConn.Open(); // Open the SQL Connection

            SqlDataReader reader = sqlCmd.ExecuteReader();
            Ticket ticketReturning = null; // Initializes the ticketReturning but it's not allocated

            // Call during reading
            while (reader.Read())
            {
                /* Objects to hold values from reader */
                string emailString = reader["email"].ToString();
                DateTime dateSubbed = Convert.ToDateTime(reader["dateSubmitted"].ToString());
                string subjectString = reader["subject"].ToString();
                string textString = reader["ticketText"].ToString();
                string statusString = reader["statusid"].ToString();
                string classString = reader["ticketClass"].ToString();

                ticketReturning = new Ticket(emailString, dateSubbed, subjectString, textString, statusString, classString);
            }
            selSqlConn.Close();
            return ticketReturning;
        }
    }

I'm going to test this on a localhost server to see if it's the server or my code causing the error, but I'm still open to suggestions/support to this particular issue.

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

有深☉意 2024-08-23 04:41:47

这看起来像是与 SQL 登录相关的错误(与 Windows 身份验证无关)。

打开 SSMS,尝试打开一个查询窗口:

  • “SQL Server 身份验证”
  • 登录 =“slehan_ticketadmin”
  • 密码 = 您期望的密码。

会失败吗?

如果是,这里有一些选项(以其他方式连接后):

  • 锁定(检查 SSMS 中的 slehan_ticketadmin 安全/用户节点)
  • 不存在(参见上文)
  • 密码已更改/错误(更改为安全/用户节点)
  • 默认数据库不同(应该在错误消息中告诉您)
  • SQL Server 设置为仅 Windows 身份验证

如果不是,您的应用程序存储了错误的凭据

在注释后进行编辑。

在查询窗口中,右键单击、连接、更改连接...使用上面的第一个项目符号指令列表重新连接到同一 SQL Server 实例。

This looks like an error associated with a SQL login (not Windows Authentication related).

Open SSMS, try and open a query window with:

  • "SQL Server Authentication"
  • Login = "slehan_ticketadmin"
  • Password = what you expect the password to be.

Does it fail?

If yes, here are some options (after connecting another way):

  • locked out (check slehan_ticketadmin Security/Users node in SSMS)
  • does not exists (see above)
  • password has changed/is wrong (change it in Security/Users node)
  • default database is different (should tell you in the error message)
  • SQL Server is set to Windows Authentication only

If not, your app has the wrong credentials stored

Edit, after comment.

In a query window, right click, connection, change connection... reconnect to the same SQL Server instance using the 1st bullet point instruction list above.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文