Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 1:45am
Comments
Malli_S at 28-Sep-12 7:57am
   
Check your connection string. Does it have required credentials ? Verify the Credentials used.

1 solution

Rate this: bad
good
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).
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 395
1 George Jonsson 349
2 CPallini 335
3 BillWoodruff 314
4 OriginalGriff 227
0 OriginalGriff 5,030
1 CPallini 4,225
2 Sergey Alexandrovich Kryukov 3,604
3 George Jonsson 2,831
4 Gihan Liyanage 2,386


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2014
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