简体   繁体   English

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

[英]Login failed for user 'username'

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'." 我有一个从MSSQL服务器中的表中选择一堆行的表单,现在,此表单用于更新数据,它可以正确执行,但是在我使用表单更新数据后,它会重定向回带有该表中所有行的数据网格,并允许我选择另一行进行更新,如果我选择刚刚再次更新的行,则会受到“用户'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. 我无法查看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");
        }
    }
}

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. 您看到的Ticket类只是一个类,其中包含从SQL Server更新/选择/删除的票证数据,这只是我以结构化方式修改/保留数据的一种简便方法。 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. 我还有另一个名为TicketDatabase的类,该类具有一堆从数据库中插入/选择/更新/删除票证的方法。 Here is the selectTicketFromDatabase() method stub. 这是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'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! 提前致谢!

This looks like an error associated with a SQL login (not Windows Authentication related). 这看起来像是与SQL登录相关的错误(与Windows身份验证无关)。

Open SSMS, try and open a query window with: 打开SSMS,尝试使用以下命令打开查询窗口:

  • "SQL Server Authentication" “ SQL Server身份验证”
  • Login = "slehan_ticketadmin" 登录=“ 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) 锁定(检查SSMS中的slehan_ticketadmin安全性/用户节点)
  • 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 SQL Server设置为仅Windows身份验证

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. 在查询窗口中,右键单击,连接,更改连接...使用上面的第一个项目符号指示列表重新连接到相同的SQL Server实例。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SQL异常 - 用户“UserName $”登录失败 - SQL Exception - Login failed for user “UserName$” 无法打开登录请求的数据库“ dbname”。 登录失败。 用户“ machinname \\ username”的登录失败 - Cannot open database “dbname” requested by the login. The login failed. Login failed for user “machinname\username” 使用Dynamics GP用户名和密码的SqlConnection-用户登录失败 - SqlConnection using Dynamics GP username and password — Login failed for user C#-“用户'用户名'登录失败(SQL Server 2014) - C# - "Login failed for user 'Username'(SQL Server 2014) 如何修复“用户'Username.sql'登录失败。”? - How do I fix “Login failed for user 'Username.sql'.”? 用户“ DomainName \\ Username”的登录失败 - Login fail for user 'DomainName\Username' 由于用户不存在/密码/用户名正确而导致尝试登录网站失败时如何返回消息? - How to return a message when a try to login to the website failed, because the user does not exist/password/username arent correct? 天蓝色的成员资格System.Data.SqlClient.SqlException:Azure中用户“ {your_username}”的登录失败 - azure membership System.Data.SqlClient.SqlException: Login failed for user '{your_username}' in Azure 在连接字符串中未指定用户名的情况下,获取“用户Microsoft \\ my@email.com的登录失败” - Getting a “Login failed for user Microsoft\my@email.com” without having specified username in connection string 用户“XX”登录失败 - Login failed for user 'XX'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM