Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi, i have an error whene i want to connect to my DB this's part of code plz help mee

C#
public static void Connecter()
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
        }


the eror apear in ligne con.Open();
Posted
Updated 1-Apr-15 19:56pm
v2
Comments
Arkadeep De 1-Apr-15 14:23pm    
http://www.codeproject.com/Questions/743721/Access-is-denied-Exception-from-HRESULT-x-E-ACCESS

check this one..
ZurdoDev 1-Apr-15 15:17pm    
Access denied is likely due to wrong username and/or password.

1 solution

Have a good look at your connection string: the chances are that it is using the wrong credentials.

Try setting up a connection in VS with the Server Explorer pane:
1) Open Server Explorer.
2) Right click "Data connections" and select "Add connection"
3) In the dialog that follows, select your DataSource, and database, specify the security info, and press the "Test connection" button.
4) When the connection works, press "OK"
5) Highlight your database in the Server Explorer pane, and look at the Properties pane. A working example of the connection string will be shown, which you can copy and paste into your app or config file.
 
Share this answer
 
Comments
Member 11573837 2-Apr-15 11:00am    
thank's to all who help me the eroor dosen't apear i did not do any think and now i connect to DB with out eroor

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