Click here to Skip to main content
12,820,208 members (23,885 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET SQL-Server , +
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 28-Sep-12 2:45am
Malli_S 28-Sep-12 7:57am
Check your connection string. Does it have required credentials ? Verify the Credentials used.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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).

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170308.1 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100