Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 643
  • Last Modified:

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

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
ems180
Asked:
ems180
  • 4
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
 
ems180Author Commented:
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
 
ems180Author Commented:
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
 
ems180Author Commented:
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
 
ems180Author Commented:
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now