无法打开数据库"testhost"登录要求.登录失败. [英] cannot open database "testhost" requested by the login. The login failed.

查看:92
本文介绍了无法打开数据库"testhost"登录要求.登录失败.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,
我该如何解决这个问题?
我在托管网站时遇到此错误.

hi friends,
how can i solve this problem??
I encountered this error during hosting a website.

Server Error in '/' Application.

Cannot open database "testhost" requested by the login. The login failed.
Login failed for user 'BJAC-GLOBEDNS\IWAM_plesk(default)'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Cannot open database "testhost" requested by the login. The login failed.
Login failed for user 'BJAC-GLOBEDNS\IWAM_plesk(default)'.

Source Error:


Line 16:     protected void Button1_Click(object sender, EventArgs e)
Line 17:     {
Line 18:         cs.con.Open();
Line 19:         SqlCommand cmd = new SqlCommand("insert into reg(username,password)values('" + TextBox1.Text + "','" + TextBox2.Text + "')", cs.con);
Line 20:         cmd.ExecuteNonQuery();

推荐答案

您尚未在问题中包含相关代码,但答案似乎很明确:您的凭据错了.根据错误消息,用户"BJAC-GLOBEDNS \ IWAM_plesk(默认)"的登录失败.首先,您的网站是否托管在BJAC-GLOBEDNS域上?否则,它将无法识别这些凭据(除非您具有包含多个域的复杂设置,否则极有可能).其次,(默认)看起来不对.也许您输入了凭据并意外保留了多余的部分?第三,您是否已验证此用户在SQL中具有适当的权限?

听起来好像您的连接上正在运行Windows身份验证.在您的开发人员机器上,这意味着您的帐户.但是,在您的Web服务器上,这意味着负责运行您的网站的应用程序池的帐户.这将是一个完全不同的帐户(或应该是该帐户).
You have not included the relevant code in your question, but the answer seems fairly clear: your credentials are wrong. According to the error message, your login failed for the user ''BJAC-GLOBEDNS\IWAM_plesk(default)''. First, is your website hosted on the BJAC-GLOBEDNS domain? Otherwise it won''t be able to recognize those credentials (most likely unless you have a complex setup with multiple domains, etc.) Second, the (default) looks wrong. Maybe you typed in the credentials and kept that extra part accidentally? Third, have you verified that this user has the proper permissions in SQL?

It sounds like maybe you were running Windows authentication on your connection. On your developer machine, that would mean your account. However, on your web server, it would mean the account that is responsible for the app pool you are running your site in. That will be an entirely different account (or should be).


这篇关于无法打开数据库"testhost"登录要求.登录失败.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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