Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
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();
Posted
Comments
Malli_S 28-Sep-12 7:57am    
Check your connection string. Does it have required credentials ? Verify the Credentials used.

1 solution

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).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900