Solved

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

Posted on 2009-05-03
5
616 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
ID: 24292642
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
ID: 24311249
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
ID: 24311268
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
ID: 24311381
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
ID: 31577424
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
business objects to connect to MSSQL 6 72
How to Generate log or file on inserting duplicate records in mysql 6 44
Unrecognized Database Format 8 107
Mongo DB 18 37
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 …
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
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…

813 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

19 Experts available now in Live!

Get 1:1 Help Now