Forum guidelines
AuthorQuestion
Login failed for user 'hp-PC\hp'
Posted on: 20 Oct 2011
public class connection.rar hello everyone;

i am making a project. in this, i am using asp.net and csharp. the situation is, on the run time this error occur "Login failed for user 'hp-PC\hp'". so what can i do? i am also sending my connection class file.

regards
sumaira manzoor

sum-khan
AuthorReply
Re: Login failed for user 'hp-PC\hp'
Posted on: 20 Oct 2011  
Hi Sumaira,

                   I think you are connecting to database through code,and your connection string is wrong. thats the reson error occuring.make sure you connection is correct or paste it here....



Thank You,
Pravin.

mark "This is correct answer" If this post help you. 
Re: Login failed for user 'hp-PC\hp'
Posted on: 20 Oct 2011  
public class connection.rar

hello sir;

this is my connection class. you can check this.

regards

sumaira manzoor


sum-khan
Re: Login failed for user 'hp-PC\hp'
Posted on: 20 Oct 2011  

Hey sumaira hussaini  ,


        you can do it.. just have make following changes...

       

new SqlConnection("Server =.\\SqlExpress;Initial Catalog = sumaira-fyp;Integrated Security=True");

                --        OR        --

new SqlConnection("Server =(local);Initial Catalog = sumaira-fyp;Integrated Security=True");



My Blog : http://ImmortalDotNet.BlogSpot.Com http://ImmortalDotNet.WordPress.Com
Re: Login failed for user 'hp-PC\hp'
Posted on: 20 Oct 2011  
It would be easier for me if the zip format was used instead of rar.
Thinking is a feeling; pleasant for some and unpleasant for others.
Re: Login failed for user 'hp-PC\hp'
Posted on: 20 Oct 2011  
hello sir;

thanks very much for your help. but this is my code. my code is running on desktop system. but it is not working in hp laptop. and the "login failed Error occurr. the error is "login failed for user hp-PC\hp".




public class connection
    {
       
            static SqlConnection my_connection = null;
            public static SqlConnection get()
            {
                if (my_connection == null)
                {
                    my_connection = new SqlConnection("Server =.;Initial Catalog = fyp;Integrated Security = True");
                    my_connection.Open();

                }
                return my_connection;
            }


    }




regards
sumaira manzoor

sum-khan
Re: Login failed for user 'hp-PC\hp'
Posted on: 20 Oct 2011  
Are you sure that "hp-PC\hp" is the SQL Server user? It could be something else, but I am not as experienced as others are and everyone else seems to consider it to be the SQL Server user.

There are various ways to use Visual Studio and/or Windows to help you to build the connection string interactively. There are about three articles about that in this web site. I think it would be useful to create the connection string that way.

Another way is to use Settings, also called application Properties, to make things easier. Those properties are for the application, not the project. Confusing? Yes, very. Go to the Solution Explorer and look for the Properties node; expand it then double-click on the Settings.settings file. You will get a big box showing project properties. In the left side will be tabs; click on the Settings tabs. You will get a table with columns for Name, Type, Scope and Value. For the name, use ConnectionStringSetting. In the dropdown box for Type, select "(ConnectionString)". The Scope will automatically be set to Application. Click in the Value column for the row and then in the far right there will be an ellipsis thing ("...") shown. Click on the ellipsis and then you will be able to create a connection string interactively.

I assume your application is not a console application but a console application does not have a Settings.Settings file unless you create one. To do that, go to the Solutions Explorer and look for a Properties node. If you open the Properties node then you will probably only see an AssemblyInfo.cs file there. So right-click on the project and click on Properties. When you click on the Settings tab you will be able to create the Settings.

Thinking is a feeling; pleasant for some and unpleasant for others.
Re: Login failed for user 'hp-PC\hp'
Posted on: 21 Oct 2011  
Hi Sumaira,
  try this line

my_connection = new SqlConnection("Server =hp-pc\\SqlExpress;Initial Catalog = fyp;Integrated Security = True,User ID=UsernameofyourSQLServer;Password=passwardofyoursqlserver");



make sure your servername,userID and passward is correct....

Thanks,i hope it will solve your problem.
Pravin.

mark "This is correct answer" If this post help you. 

SPONSORED BY

Custom Software Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.