Solved

Login failed for user ''. The user is not associated with a trusted SQL Server connection

Posted on 2009-05-03
5
614 Views
Last Modified: 2012-05-06
Anyone.

Login failed for user ''. The user is not associated with a trusted SQL Server connection
-----------------------------------------------------------------------------------------------------------

This is the error that I am getting using a very simple program written in C#.

I am very new to both C# and SQL Server 2005 Express environment. This is a learning phase that I am going through. I read on the internet that I need to make the SQL serve have a Mixed Mode so that the Windows and SQL server authintactions both are applied.

I did that but the error remains. Also, I created a new user to start a fresh. That did not do well either. I am back on the drawing board and now I feel cornered and without knowledge.

Please help. I appreciate all of you in advance
Code:

            // Create a SQL adapter to Access/Update the values in the database

            SqlDataAdapter DBAdapter = new SqlDataAdapter("select * from User", SQLDb);
 

            // Create a Command Builder object to execute SQL             

            DBAdapter.SelectCommand = new SqlCommand("");

            SqlCommandBuilder DBCommBuilder = new SqlCommandBuilder(DBAdapter);

            DataSet DBDataSet = new DataSet();
 

            // Fill the dataset using the SQL Command specified within the Database Adapter 

            DBAdapter.Fill(DBDataSet, "User");
 

            // Reset the password to blank 

            DBDataSet.Tables["User"].Rows[1]["Password"] = "***";

Open in new window

0
Comment
Question by:ems180
  • 4
5 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 50 total points
Comment Utility
the code posted is not the relevant code.
what you need to check is the part that set's up SQLdb, aka the connection string.

now, 2 questions:
* what does the connection string look like?
* is this for a windows forms application, or a web (iis) application?
0
 

Author Comment

by:ems180
Comment Utility
The code is Windows Form. I tried to change the SQL Server auth. from Windows Authentication to Mixed mode and also changed the sa password in SQL server.

The connection string is as follows:
SqlConnection SQLDb = new SqlConnection(@"Data Source=MyComputer;" +
                                                @"Initial Catalog=MyDatabase" +
                                                @"Integrated Security=SSIP");

Even I tried Integration Security=True and also tried the user id and password combination.

I think that the problem is with SQL server settings. I have never administered the server myself and this is the first time that I am doing everything from scratch. I hope this will help
0
 

Author Comment

by:ems180
Comment Utility
One thing i missed. I used the entity object using LINQ to the server with windows authentication to display the values and that works fine. When I try to update any value of use a DataAdapter to fill, I  get this error. The error comes up on the following line of code:

DBAdapter.Fill(DBDataSet, "User");
0
 

Author Comment

by:ems180
Comment Utility
Never Mind. I think I resolved the problem. The issue was that the connection string was coded incorrectly. User Name and Password were not being supplied properly when using the sa login.

Thank You for your hint angelIII
0
 

Author Closing Comment

by:ems180
Comment Utility
Thank You for your help. It gave me a hint to revisit the connection string and I found the problem. I can connect to the server and can see  the values. I will update the database as well.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I guess that all of us know that caching the data usually increase the performance, but I worried if all of us are aware about the risk that caching the data provides and how to minimize this.  That’s the reason why I decided to write this short art…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now