?
Solved

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

Posted on 2009-05-03
5
Medium Priority
?
647 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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 200 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
Microsoft Jet database engine errors can crop up out of nowhere to disrupt the working of the Exchange server. Decoding why a particular error occurs goes a long way in determining the right solution for it.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
Suggested Courses

592 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