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
Loading

Pravin MorePosted Oct 21, 2011, 2:32 AM
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.
Sam HobbsPosted Oct 20, 2011, 3:22 PM
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.
sumaira manzoor hussain khanPosted Oct 20, 2011, 2:04 PM
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
regards
sumaira manzoor
Sam HobbsPosted Oct 20, 2011, 1:11 PM
Mayur DighePosted Oct 20, 2011, 11:14 AM
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");
sumaira manzoor hussain khanPosted Oct 20, 2011, 10:13 AM
hello sir;
this is my connection class. you can check this.
regards
sumaira manzoor
Pravin MorePosted Oct 20, 2011, 9:49 AM
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.