SQL SERVER – Fix : Error: 18452 Login failed for user ‘(null)’. The user is not associated with a trusted SQL Server connection.

Some errors never got old. I have seen many new DBA or Developers struggling with this errors.

Error: 18452 Login failed for user ‘(null)’. The user is not associated with a trusted SQL Server connection.

Fix/Solution/Workaround:
Change the Authentication Mode of the SQL server from “Windows Authentication Mode (Windows Authentication)”
to “Mixed Mode (Windows Authentication and SQL Server Authentication)”.

Run following script in SQL Analyzer to change the authentication

LOGIN sa ENABLE
GO
ALTER LOGIN sa WITH PASSWORD = '<password>'
GO

OR

In Object Explorer, expand Security, expand Logins, right-click sa, and then click Properties. On the General page, you may have to create and confirm a password for the sa login. On the Status page, in the Login section, click Enabled, and then click OK.

Reference : Pinal Dave (http://blog.SQLAuthority.com) , BOL

About these ads

180 thoughts on “SQL SERVER – Fix : Error: 18452 Login failed for user ‘(null)’. The user is not associated with a trusted SQL Server connection.

    • Hi,

      We are having Application running on Local machine and

      database Sql2008R2 with Windows authentication. One

      domain user having issue/ gets untrusted user sql

      connection error manytimes and it works fine for somtime

      when you log off and log back In.

      Error details. Error 18452 (not associated

      with a trusted sql server connection) sql 28000

      Please advise.

      • Hi Sukh,
        We are having the same issue here at work in a very similar situation. Were you ever able to resolve the issue? Thanks.
        -Karen
        UCSD

        • No karan, I am still having the same issue.

          I tried many things so far didn;t work.

          Please let me know if you find a solution.

          Thanks

          • @ Sukh

            Can you provide more details.

            I am not sure why is it happening, but did you check, what is the value set for Maximum No of Concurrent connections at Server Level ?

            You can check this, Right Click Server Name in SSMS, Select Properties, Go to Connections tab.

            Other scenario could be, if you have used that windows Login to run any service, and you recently changed password for that Windows Account but for got to change password at the service logon. Then for every 5 attempts of the service, the Windows Account will be locked because of incorrect password attempt made by the service. And as per Windows Policy Set, Windows Account are reset after some times, (most of the times this will be 30 minutes).

            Try checking if you have used this windows Account in any of the service, if you did then change the password at the service logon to new password of windows account. Checking Event Viewer could give you more information.

            ~ IM.

          • Hi Imran, I have checked it and we assign 0 for unlimited connections.

            Other thing is we are using window authentication for sql2008r2 and we have an application running which uses sql2008 as a backend .

            All the user are domain user using the domain account. It works fine with some users but some user have an issue Error 18452(Untrusted Domain connection).If you log off and Log back in , it starts working fine.

            Please advise

          • Imran, We have only one database SQL2008r2 and the log off is from OS not the application.

            User connect through the application with window authentication.

            Please tell me if you have any question. I am tired of this error.

            Thanks

          • Hi Sukh, Hi All,
            The network – guru’s did finally figure out at least what the problem was we were having. For those of you running on an “authenticated” network this may be useful:
            They changed a few parameters – the ID of which I don’t know – but the basic error message stayed the same.
            The “Fix” that caused the error message to go away and everything to work was to make sure that the UserID and password with which I was signing into my computer – and thus onto the Microsoft Active Domain server – was the same as the UserID and password entered into the Sql2008 database server.

            From what I can understand – I was signing into the AD server and the AD server was signing me in to the SQL server – but it was giving the SQL server my ACTIVE DOMAIN UserID and Password. As soon as the UserID and password being provided to the SQL server matched the UserID and password it was expecting – then it knew me and let me in.

            Hope that help someone –
            Regards,
            Karen RS
            Calit2 at UCSD

    • Hi

      If you are getting this for an AD account then try following

      1) Go to windows security in the server where you get the error and then set a new password from there

      2) If above doesnt work,set it back to old password,login to SQL and logoff from all places and set new password

      Regards
      Rakesh

  1. I am getting this error when try connecting with SQL server 2000 using Query Analuzer on XP machine.

    Server: Msg 18452, Level 16, State 1
    [Microsoft][ODBC Server Driver][SQL Srver]Login failed for user ‘(null)’. Reason: Not associated with a trusted SQL Server connection.

  2. Your artical really help me, when I am trying this in the production. Because I wrongly selected Authentication Mode of the SQL server from “Windows Authentication Mode (Windows Authentication)” with the help of your script I have change to “Mixed Mode (Windows Authentication and SQL Server Authentication)”, its work out…

  3. Hi,
    why should I change the authentication??
    Actually, I am trying to run a query thru linked server. I linked the server by windows login and my target SQL server is running under windows authentication only and I am getting the same error.

    Please clear my doubt why should we use only mixed mode? Why it is not working with windows authentication, even I am using a domain account to connect?

    • I had a similar kind of problem, finally this give me clue, that one of the linked server do not have authentication rights for the user so when I execute the view I was getting error invalid login

  4. Rizwan,

    There should not be any need to change the authentication in theory. However, this error is quite generic and this way it can be fixed first and then you can work backwards towards your original configuration and see what is the issue.

    Regards,
    Pinal Dave (SQLAuthority.com)

    • Dear Sir,
      I would to discuss a problem with you. I used sql SERVER 2000. in this server when I work on server itself than it work properly and i connect a client to it than client not working. “error server not found”

      but sir both systm ping and share properly
      kindly suggest
      Thanks

  5. I am using linked server and getting same error when trying to access linked server. I have Server1 with linked Server2. I am connected to Server1 using management studio remotely and trying to access linked server Server2. If I connect locally to Server1 and try to access linked Server2 this works. Any help will be appreciated.

  6. Hi,

    Things were working quite happily locally on my machine with Windows Authentication .. I tried setting up an ODBC connection to the database; this did not work

    Upon trying to reaccess the database, via SQL Server Management Studio, the system reported, “Login failed for user . The user is not associated with a trusted SQL Server connection”

    Luckily I was able to connect using 127.0.0.1 rather than my machines DNS name and was able to create the sa account to regain access. How is it then that I re-enable Windows Authentication mode?

    Thanks

    mrplatypus ..

  7. This is for WINDOWS AUTHENTICATION:

    I received this error when connecting to the SQL Server remotely via my application. After researching, I found that you had to both enable trusted authentication on my SQL Server machine and grant the User Right “Enable computer and user accounts to be trusted for delegation” (Group Policy…under Local Policies\User Rights Assignment) to the Windows account you are using. I just granted it for the Administrators group.

    For the SQL Server machine, I set the property in Active Directory (check the box labeled “Trust computer for delegation” in the computer’s properties).

    Make sure you for the group policy changes (gpupdate /force).

  8. I have clustered SQL 2005 Enterprise 64 bit and SQL 2005 SP2 on a Windows 2003 server and I can log in fine with domain credentials, but not with ‘sa’. SQL is installed in mixed auth mode and has all the default protocols, including Named Pipes and TCP/IP. I get error 18452 and I have read many, but not found any articles or discussions on the Internet or from Microsoft that solves the problem. My head hurts.

    Any help is appreciated.

  9. I’m trying to switch from windows authentification mode to sql server authentification.

    Have doen all as you’ve written.

    and it still gives me error Error 18452 (not associated with a trusted sql server connection)

  10. Are there any problem if the server is on different network than client?
    In my scenario my client is working into a network without Windows servers (so any AD is running or required for validation) but the SQL server (that is an SQL server 2000 SP3 running on a Windows 2003 server R2) is into another network WITH AD.
    The connection is transparent through router. All other network services runs fine between both networks.
    I’ve followed all steps but I’m still having the same problem.
    2 clients running same OS with same ODBC have different behaviors. The client connected on same server’s network runs fine but the other one raises this error.

    Any help will be appreciated

  11. Please check the Server name is in Sink with server name of SQL Server. The host name should be the same as
    Select @@Servername. If they are not the same, then use SP_Dropserver ‘oldServername’ and then Supply SP_addserver ‘Servername’,’Local’. then restart the server (OS) to take effect.

  12. sql express05 does allow me change password when
    iam logged with windows authentification,on next restart doesnt allow me to login with sa(by the way it shows some long password with asterixs).meaning it is not changing the password and
    reports below error.this is LOG
    TITLE: Connect to Server
    ——————————
    Cannot connect to BLEEDING-DESKTO\SQLEXPRESS.
    ——————————
    ADDITIONAL INFORMATION:
    Login failed for user ‘sa’. The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452)
    —————–
    any way to change to mixed mode authentification?

  13. This is nice work around .

    It helped me ‘N’ times .. i did it several times on several times ..for got the solution referred this article and got back to work and implemented it .

    Thanks
    Ravi Srinivas

  14. Hi,

    I fogtot to create sa authentication mode at the time of installation. How to create sa authentication. Is it possible at this time. I am able to access windows authentication only. Pl

  15. I have an ASP.NET 2.0 Application on machine A. I am using forms authentication with Active Directory. My SQL 2K database is on machine B. On machine A, I can access my application, with no problem. When i try to access the application over the network from different machines, i get this error.

    Server Error in ‘/EXACT-WHRM’ Application.
    ——————————————————————————–
    Login failed for user ‘sa’. Reason: Not associated with a trusted SQL Server connection.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException: Login failed for user ‘sa’. Reason: Not associated with a trusted SQL Server connection.
    ======================================

    please help. am at my wits end.

    moseti

  16. I am finding the issue while try to connect/create database in SQL Server 2005 from different application.

    Login failed for user ’’. Reason: Not associated with a trusted SQL Server connection.

    I tried with the above mentioned but it is failing to connect.

    Pointers please.

    Regards,
    Dev

  17. Hello,
    i am using sql server 2005 and installed in mixed mode withe user name sa and password #sa
    and from Sql Server Surface Area Configuration i select the Using both TCP/IP and named pipes for remote settings under Database Engine
    version is [@@version]
    Microsoft SQL Server 2005 – 9.00.1399.06 (Intel X86) Oct 14 2005 00:33:37 Copyright (c) 1988-2005 Microsoft Corporation Enterprise Evaluation Edition on Windows NT 5.1 (Build 2600: Service Pack 2)

    My os is Xp with service pack2

    I am using asp.net 2.0 and using connection string in web.config

    SOURAV is my local Database Server name.

    I can connect server with the user name password from the SQL Server Management Studio,
    But the problem arise when i hit con.open() from asp.net page

    error message show login failed for user ‘sa’

    Please help how to solve,
    Thanks in advance
    Sourav

  18. the sql server registertration failed user and the two user in different operating system but in the same network group

  19. I have the same problem, but in my case, changing to Mixed Mode authentication did not fix the problem.

    I can login under Windows Authentication without problem, but any attempt to use SQL Server Authentication results in the “not associated” error.

    I have also tried using the “sa” account, changing “sa” passwords, and even dropping password policy on the “sa” account… no joy. I have also tried creating new users, with explicit server authentication permission and passwords, but still no luck.

    Any suggestions?

  20. hi
    I am trying to configure log shipping on sql server2000 on a domain with a machine with same sql server 2000 on different domain but i m getting the error :

    Microsoft (R) SQLMaint Utility (Unicode), Version Logged on to SQL Server ‘ANKUR-BZOPEK2PX’ as ‘ANKUR-BZOPEK2PX\sqladmin’ (trusted)
    Starting maintenance plan ‘log_ship’ on 3/18/2008 10:20:00 AM
    [1] Database log_ship: Transaction Log Backup…
    Destination: [E:\backup\log_ship_bakup\log_ship_tlog_200803181020.TRN]

    ** Execution Time: 0 hrs, 0 mins, 1 secs **

    [Microsoft SQL-DMO (ODBC SQLState: 28000)] Error 18452: [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user ‘(null)’. Reason: Not associated with a trusted SQL Server connection.
    [2] Database log_ship: Delete Old Backup Files…
    0 file(s) deleted.

    Deleting old text reports… 0 file(s) deleted.

    End of maintenance plan ‘log_ship’ on 3/18/2008 10:20:00 AM
    SQLMAINT.EXE Process Exit Code: 0 (Success)

    please suggest me
    thankyou

  21. Another thing to check is the information you add to your Add Connection box.

    Make sure you have the correct path of the servername. You may need to do something like this: MYCORPSERVER/SQLEXPRESS

    The wrong path will also give that ugly “Login failed…” error

  22. hiiii
    i have given the userid as “sa” itself…..and mode of authentication is mixed mode itself……but still i am getting the error…..”login failed for the user ‘sa’ ” while connecting to sql server.

  23. The problem is usually the security tab in the link server.
    use the correct connection setting.
    I always recomend login maping and use the current login security context. hope this help. :-)

  24. Really lots of Thanks for this solution.

    I m facing this problem from long time and had no solution.

    This is really working solution which works for me.

    Thank you very much.

    Post this kind of Fixes of error in future.

  25. Hi,

    Problem:

    I am getting this error when try connecting with SQL server 2000 using Link Servers on XP machine.

    Server: Msg 18452, [SQL Srver]Login failed. Reason: Not associated with a trusted SQL Server connection.

    Solution:

    Corect My DNS (Main Domain) and Change the Authentication Mode of the SQL server from “Windows Authentication Mode (Windows Authentication)”
    to “Mixed Mode (Windows Authentication and SQL Server Authentication)”.

    Thanks,

    Mahesh.

  26. Hi
    Thank you for the solution. I tried many ways to change the authentication mode from Windows to Sql Server Authentication mode. But there is no use. But after trying the above, the problem solved immediately. Thank you for the code.

  27. hi

    I am using Vista as an OS. I am currently working on VS 2005 and SQL Server 2000. i am tired of working wiht this error and m really screwed up. can u please help??

    Login failed for user ‘Anubhav-PC\Anubhav’.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException:
    Login failed for user ‘Anubhav-PC\Anubhav’.

    Source Error:

    Line 48: cn = New SqlConnection(“data source=localhost;initial catalog=payroll;integrated security=sspi;”)
    Line 49:
    Line 50: cn.Open()
    Line 51: eid = TextBox1.Text
    Line 52: ename = TextBox5.Text

    I have tried creating a new user named ‘anubhav’ and have changed mode to Mixed. Yet the problem persists.

    Please help!!!!

    Thanx in Advance
    Anubhav

  28. Hello sir,
    I am getting following error when i m creating system dsn for sql server 2005.
    I HAVE ASLO DONE THE AUTHENTICATION MODE FROM WINDOWS TO MIXED MODE.
    Connection failed:
    SQL state: ’28000′
    SQL server error:18452
    [Microsoft][ODBC SQL server driver][SQL server] login failed for user ‘asdf’. User is not associated with a trusted SQL server connection.

  29. Hi All
    i am using SQL Server 2005 SP2 mixed mode of authentication is in use still getting this error
    Login failed for user ”. The user is not associated with a trusted SQL Server connection
    Error: 18452, Severity: 14, State: 1.

    any help will be appreciated.
    Regards

  30. Hi,

    This article is useful but because of some security requirements we have to use windows authentication only. So, i wanted to ask whether there is a possiblity to solve it by using the windows authentication mode.

    Thanks.

  31. Hi All,

    Me also facing this kind of problem. I executed the following sql statement. But still I am getting ”
    ” Msg 156, Level 15, State 1, Line 1
    Incorrect syntax near the keyword ‘user’. ”

    while runing this SQL statement. Please forgive me for this silly qstn. I am a new boy to this SQL Server world.

    SQL Statement I executed :
    ALTER LOGIN user ENABLE
    GO

    Thanks
    Arun J

  32. I have SQL SERVER 2005 (EXPRESS) running on my home desktop machine. However, on this desktop machine there is no Query Analyzer and neither SQL Server Management Studio. It’s my first time to use SQL Server 2005.

    On my office laptop, I have SQL Server Management Studio. When I try to connect to the SQL server on my desktop machine, I get this error.

    Error: 18452 Login failed for user ‘(null)’. The user is not associated with a trusted SQL Server connection.

    Here is a screenshot of the error I am getting.

    http://i303.photobucket.com/albums/nn134/s1mpl3k1d/sql_loginerror.gif

    Any help would be greatly appreciated.

  33. I don’t know if my error is the same as everyone else:
    Access 2003 on a Windows Vista Pro PC. Everyone else can access the Access program on their PC but they have Windows xp. I have admin rights.

    Since the user switched to Windows Vista Pro from XP, he gets Microsoft SQL Server Login error:

    Connection failed
    SQLState’28000′
    SQL Server Error 18452
    [Microsoft][ODBC SQL Server Driver][SQL Servr] login failed for user (null). Reason Not asscociated with a trusted SQL Servr Connection.

    He was able to use the Access program before. I did set up the ODBC connection as I always do on everyone else’s pc.

    I also tried to log into the sql server at the prompt with my userid and password as I have admin rights, but I still get the error. I also tried the administrator logon id / pw and still get the error.

    Why can’t he use the Access database on Vista Pro? Is there something I need to download? Is there something I need to update from Microsoft?

    Thanks in advance for any help.

  34. OK just to update. I didn’t know that the user was not logging into the domain. The user was setup by our IT person to log into the local laptop for some reason.

    Once the user logs into the domain it worked.

    :D

  35. Hi All,

    while reinstalling the SQL server getting an error like all the components are already installed but there is no components are showing let any one give a solution for this problem.

  36. To change security authentication mode

    1.

    In SQL Server Management Studio Object Explorer, right-click the server, and then click Properties.
    2.

    On the Security page, under Server authentication, select the new server authentication mode, and then click OK.
    3.

    In the SQL Server Management Studio dialog box, click OK, to acknowledge the need to restart SQL Server.

    Ref: http://technet.microsoft.com/en-us/library/ms188670.aspx

  37. Dim linkTable As TableDef
    Set linkTable = CurrentDb.CreateTableDef(tableName, dbAttachSavePWD)
    linkTable.Connect = “ODBC;Driver={SQL Server};Server=SERVERNAME;” _
    & “Database=DATABASENAME;Uid=USERNAME;Pwd=PASSWORD;”
    linkTable.SourceTableName = tableName
    CurrentDb.TableDefs.Append linkTable

  38. Hello Sir ,

    This article was really helpful .
    But I am not able to connect to database from VB.Net using Windows Authentication . I am able to do it using “sa” account . Meanwhile I am also able to get in Sql Management Studio using local as well as sa account .

    Mixed Mode Authentication Used

    In the below code if i change UserId to sa then my task is accomplished .

    Am I missing Something?????????

    Code Used :

    Sub Main()
    Try
    Dim cbs As New SqlConnectionStringBuilder()
    cbs.DataSource = “Franklin”
    cbs.Add(“Initial Catalog”, “Sharepoint”)
    cbs(“Integrated Security”) = False
    cbs.UserID = “Francis”
    cbs.Password = “”
    Dim conn As New SqlConnection(cbs.ConnectionString)
    Console.WriteLine(“Opening Connection”)
    conn.Open()
    Console.WriteLine(“Connection Opened”)
    Console.WriteLine(“Closing Connection”)
    conn.Close()
    Console.WriteLine(“Connection Closed”)

    Catch ex As Exception
    Console.WriteLine(ex.Message)
    End Try
    Console.ReadLine()
    End Sub

  39. SQLServer running on Win2k3. Ran sysprep to generate a new SID in attempt to fix blue-screen problem with domain authentication (another story…).

    Anyway, since generating the new SID, Windows authentication to SQL Server is broken. The sa account is disabled. I can log in with a read-only SQL user and that is all I can do. The agent won’t start – fails to authenticate as Local System.

    I need to re-initialize SQL security so I can log in via Windows (Administrator). Or enable ‘sa’ somehow. Any ideas?

  40. I tried to create new users from security login and give the database which allow the user access, but the user could not login from application. I do not know why?

    Ting

  41. I have developed ASP.net 2005 website. It has connectin with SQL server 2000 SP4. Whwn I run the site from VS 2005, it runs perfactly. But when I upload it on the IIS server (OS Win2000), the SQL server is not getting connected the error is… Not associated with trusted SQL Server connection.

    I have tried will all following options :
    1. Changed the authentication mode to SQL Server and Windows mode with audit option None.
    2. Included Integrated security=SSPI in connection string
    3. Included Trusted_Connection=True in connection string
    4. Tried with user name and password in connection string
    5. Created a new user and assigned dbo.owner permission to the user and provided user id and password in conncetion string.

    Still the error persists.
    Can anyone help me ???

  42. Hello,

    I have an Access 2003 DB with an ODBC connection to a SQL 2000 Server. There are about 4 different people with similar security rights who use this and 3 are able to use the db with no problem.

    One person has the same error as described on this page

    Error: 18452 Login failed for user ‘(null)’. The user is not associated with a trusted SQL Server connection.

    This user claims that he usually does not log into the domain but he claims that in this case he was logged in and it still did not work. I submitted a ticket to IT to take a look at his account and they verified that he has admin rights to his PC.

    Do you know why one person would have this error when others with the same security rights do not have problems? Would this indicate a domain issue perhaps?

    Thanks,
    Creed

  43. Scenario: You are using SQL Server 2005/2008 management studio to connect to a SQL Server. In management studio, you are trying to set up a linked server. When trying to access the linked server, you receive the error message in this plog.

    Problem: Because you are remotely connected to your SQL Server and trying to access a linked server, you are engaged in a double-hop authentication. IE, your credentials are passed to your SQL Server and your SQL server is trying to pass them to the linked server. This requires Kereberos authentication.

    Solution: A domain admin must enabled delegation of your SQL server via Active Directory so your credentials can be passed through.

  44. i have installed SQL SErver 2000, when i try connect using ‘SQL server authentication’ mode with ‘SA’ or my username, it is giving me 18452 – user not assoiciated with a trusted connection. i noticed ‘Mixed authentication’ mode set to disabled. how should i fix this issue?

  45. Does anyone know what might cause this error to occur sporadically? I have a service which makes a connection every few minutes to several servers. If the connection fails, I get paged. Once it’s able to connect, I get paged again. This error is occurring randomly on a few of the servers; the service is able to reconnect after a few minutes. So I’ve had many sleepless nights lately!

  46. Hi Sue,

    I am having similar issues where my application would occassionally lose connection to SQL Server. After a few mins, the connection would be restored automatically but it is definitely cauing problems in the production environment.

    My SQL is clustered but no failover occurred when the connection was lost.

    Anyone can help? Much appreciated.

    SQL Log says:

    Error: 17806, Severity: 20, State: 2.
    2008-11-03 07:54:25.63 Logon SSPI handshake failed with error code 0×80090311 while establishing a connection with integrated security; the connection has been closed. [CLIENT: 10.1.64.44]

    2008-11-03 07:54:25.63 Logon Error: 17806, Severity: 20, State: 2.
    2008-11-03 07:54:25.63 Logon SSPI handshake failed with error code 0×80090311 while establishing a connection with integrated security; the connection has been closed. [CLIENT: 10.1.64.41]

  47. I am try to use the following script to open some linked tables from an SQL 2005 Server from a client with Access 2003. I can do it manually with no problem, but when running the script I get the following error.

    Could not find installable ISAM

    Can Anyone Help Me Please?

    Option Compare Database

    Private Sub Command0_Click()
    On Error GoTo Err_Command0_Click

    Call LinkToSQL(“dbo_Batch”, “Riegos”, “dbo_Batch”, “AAA”, “sa”, “INFO121″)

    Exit_Command0_Click:
    Exit Sub

    Err_Command0_Click:
    MsgBox Err.Description
    Resume Exit_Command0_Click

    End Sub

    Sub LinkToSQL(strAccessTable, strDBName, strTableName, strDataSourceName, strUserID, strPassword)
    Dim cat As ADOX.Catalog
    Dim tbl As ADOX.Table

    Set cat = New ADOX.Catalog
    cat.ActiveConnection = CurrentProject.Connection
    Set tbl = New ADOX.Table
    tbl.Name = strAccessTable
    Set tbl.ParentCatalog = cat
    tbl.Properties(“Jet OLEDB:Create Link”) = True
    tbl.Properties(“Jet OLEDB:Link Provider String”) = “OBBC” & _
    “;Database=” & strDBName & _
    “;UID=” & strUserID & _
    “;PWD=” & strPassword & _
    “;DSN=” & strDataSourceName
    tbl.Properties(“Jet OLEDB:Remote Table Name”) = strTableName
    cat.Tables.Append tbl

    End Sub

  48. To change security authentication mode

    1.

    In SQL Server Management Studio Object Explorer, right-click the server, and then click Properties.
    2.

    On the Security page, under Server authentication, select the new server authentication mode, and then click OK.
    3.

    In the SQL Server Management Studio dialog box, click OK, to acknowledge the need to restart SQL Server.

  49. I am trying to write a Maintenance Plan history to a remote server. Nothing shows up in the table, and the text log file has the following error.

    [Microsoft SQL-DMO (ODBC SQLState: 28000)] Error 18452: [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user ‘(null)’. Reason: Not associated with a trusted SQL Server connection.

    I tried running the script at the top of this discussion and keep getting the following error.

    Server: Msg 170, Level 15, State 1, Line 1
    Line 1: Incorrect syntax near ‘LOGIN’.
    Server: Msg 170, Level 15, State 1, Line 1
    Line 1: Incorrect syntax near ‘LOGIN’.

    I have checked the login settings in Security via Enterprise Manager, and have also confirmed I can log in using SA.

    Any suggestions?

  50. Hi,

    Im using msql server 2000. My problem is i cannot connect to my server. I tried all my knowledge but it doesnt work

    1. sql network interfaces, error: 26.

    please help

    Renato

  51. Hi !!!
    Just a simple and wonderful solution. I’m migrating an application on VB6, SQLServer2000 and Windows2000 to a new server (Win2003 Server) and I got this message. I didn’t believe the solution will work, but anyway I tried and it worked perfectly.

    Thanks so much from Mexico.

    Regards

    Yan

  52. Hi
    I need to connect my C# windows Form to a SqlServer IP which is in same LAN but remote. When I try to connect it says
    “error 18452 The user is not associated with a trusted SQL Server connection”

    This is the conn string i am using

    string strSQLconnection = @”Data Source=107.2.2.10,2230;Initial Catalog=OrderPlacement;Integrated Security=True;User Id=xxx;Password=xxx;User Instance=True”;

    Can you pls help?

    Thanks
    Mohit

  53. Hi,

    Is there any way that we can change this authentication mode from windows to mixed using Scripts?

    In my case, I don’t want to use the SQLServer Management Console for this change. Because I am keeping everything (includind database creation, user creation, table creation etc) in scripts.

    I appreciate your help on this.

    Thanks,
    Gopal

  54. Hi,

    I am using the MS SQL 2005(64Bit) on Windows 2003 64Bit. SQL Server is running on cluster. So time when I restart one of the domain controler , getting the following error. SQL Server has setup on mix mode and has given the correct DNS setting

    An Error has occurred in Phoenix2, Version=1.0.3330.29344, Culture=neutral, PublicKeyToken=null
    —————————————————————-
    System.Data.SqlClient.SqlException: Login failed for user ”. The user is not associated with a trusted SQL Server connection.
    at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
    at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
    at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
    at System.Data.SqlClient.SqlConnection.Open()
    at Phoenix2.mSKFunctions.LogError(LogSeverity Severity, String& Message, String& Details) in C:\Development\Phoenix\Phoenix\Phoenix\mSKFunctions.vb:line 1137
    —————————————————————-

    Appriciate your grate help on this.

    Thanks
    Ranjith

  55. Hi Gopal,

    try this :

    USE [master]
    GO
    EXEC xp_instance_regwrite N’HKEY_LOCAL_MACHINE’, N’Software\Microsoft\MSSQLServer\MSSQLServer’, N’LoginMode’, REG_DWORD, 2
    GO

  56. I have a problem with sql server 2005. I have created a web setup project using custom action to create database at installation time. Every thing is ok. It creates prerequisites (.net farmework 2.0, sqlserver 2005 express, etc.) and database successfully during installation. I have used the connection string

    connectionString=”Data Source=.\SQLEXPRESS;Initial Catalog=TrainTrack;Integrated Security=true;” in my custom action which executes database script successfully and install web application as well.

    But when i execute my application login page and supplies Login Id and Password, It did not connect to sql server on other machine. It works fine on my development machine fine also.

    I check my application connection string in ‘Inetpub\wwwroot\Application\web.config, which is also the same as custom action connection string.

    I do not understand, actually what’s problem is?

    Any one please help me.
    Thanks

  57. I have my Server set to SQL Server and Windows Authentication Mode, but I get “Login filed for user ”.
    My app settings are as follows:

    In my web.config settings, I have the authentication mode defined within as follows:

    I have been wrestling with this problem for over a week and still don’t have a solution. My problem seems similar to the others, but I already had the authentication mode set to both Windows and SQL Server.
    Can you tell me what I need to do to correct my error?
    Thank you very much,
    Art
    P.S. The error message with stack is as follows:
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException: Login failed for user ”.

    Source Error:

    Line 28: pw = Request.Form(“password”)
    Line 29:
    Line 30: If UserLogin(reg, pw) Then
    Line 31: Response.Redirect(“MainMenu.aspx”)
    Line 32: Else

    Source File: C:\Users\Art\Documents\Visual Studio 2008\WebSites\WebSite1\Login.vb Line: 30

    Stack Trace:

    [SqlException (0x80131904): Login failed for user ''.]
    System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4846887
    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
    System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392
    System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +35
    System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +144
    System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +342
    System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +221
    System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +189
    System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +185
    System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +31
    System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +433
    System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
    System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +499
    System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +65
    System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +117
    System.Data.SqlClient.SqlConnection.Open() +122
    PC.DbAccessor.GetDR(String cSQL) +127
    PC.EDUPage.UserLogin(String aUserName, String aPassword) +176
    Login.cmdLogin_Click(Object sender, EventArgs e) in C:\Users\Art\Documents\Visual Studio 2008\WebSites\WebSite1\Login.vb:30
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

  58. Thx, mean while it works.

    I have many servers, and one of them is in different network
    We just do this

    “Frank Stevens

    This is for WINDOWS AUTHENTICATION:

    I received this error when connecting to the SQL Server remotely via my application. After researching, I found that you had to both enable trusted authentication on my SQL Server machine and grant the User Right “Enable computer and user accounts to be trusted for delegation” (Group Policy…under Local Policies\User Rights Assignment) to the Windows account you are using. I just granted it for the Administrators group.

    For the SQL Server machine, I set the property in Active Directory (check the box labeled “Trust computer for delegation” in the computer’s properties).

    Make sure you for the group policy changes (gpupdate /force).”

    so..our domain controller (on other network) had virus, virus attacking security system, sometime it grant the active directory and sometime it doesn’t (Aaarrgghh..)

  59. I had the same problem.
    SQL 2000 on a server in windows authentication mode.
    The Active Directory role set in the SQL security tab.
    My colleagues could log on to the server using the enterprice manager. I couldn’t, getting the same error “Login failed for user ‘(null)’. The user is not associated with a trusted SQL Server connection”. Setting the server in mixed mode is no option because of business policy.

    The solution:
    With the windows explorer I connected to a shared directory on the server.
    Problem solved.

    I don’t understand why or how, but it works.

  60. when we are running the insert statement with the linked server, it is working fine.
    If i create the job , it is failing with the folowing error
    Executed as user: SYNTEL\user1. Login failed for user ‘(null)’. Reason: Not associated with a trusted SQL Server connection. [SQLSTATE 28000] (Error 18452). The step failed.

    We are getting the error in sql 2000.

    Regards,
    D.RamaKrishna

  61. I am having the error
    “Login failed for user ‘sa’. The user is not associated with a trusted SQL Server connection.”.

    I have Windows XP Service Pack 2,
    I have MS SQL 2005 Express,
    I can have either ‘Windows Authentication’ or ‘SQL server Authentication’ in SQL.
    I have MS SQL Server Compact 3.5 Design, ENU,
    I have MS SQL Server Native Client

    I have just removed passwords for sa, and my login in the SQL server.

    How can I solve this error please?

  62. Solved.
    The connectionstring line was at fault, it should have been
    connectionString=”Data Source=.\SQLEXPRESS;INITIAL CATALOG=HandScanning;Integrated Security=SSPI;User Instance=False”

    Instead of “Integrate Security=SSPU;user instance=false, ”
    I had “id=PC\Aministrator;pwd=”

    So this error can also relate to errors in the constuction of the
    connectionstring

  63. This advice is great unless you are ALREADY in mixed mode on SQL 2005 and STILL receiving the same error. The services HAVE been restarted and STILL receiving the same error. I am using Rightfax. It is trying to alert the database that the fax was successful. My System DSN (ODBC connection) verifies fine using SQL user and password, but when the Rightfax program goes to run the process, It gives me the dreaded User not associated error and the user is ”. This is maddening! I have spent two full days so far, but all I find is change the mode to mixed mode, I am already there!

  64. I have already change the mode to “SQL Server and Windows Authentication mode” but I am still getting the error of “The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452).

    Why is that ?

  65. I have solved the problem, after changing the connection to “SQL Server and Windows Authentication mode”, I need to stop the SQL Server Service and SQL Server Agent Service and restart them.

  66. Hi,

    I too have the same problem. So long i am getting errors for SSPI handshake and login failed for the user etc. This blog was very helpful.. Thanks a lot…

    For me, the solution was the host had two DNS names. So, I had changed the DNS to the same which is recognized under Network (My Computer –> Properties –> Network Identification) in client network utility. (Run –> cliconfg). Restart the SQL Server. It won’t show any more errors in Agent log & event viewer … It will allow windows authentication also…

  67. Mine turned out to be a change to a registry key for Rightfax. I had to include a user and password in the registry key. Apparently Rightfax only looks at the ODBC driver for the server name, why bother at all?!

  68. Hello, I’m faced with the following problem. We are one of many applications that are being deployed to hundreds of sites. The help application is developed by one group and we have to use their help. Our application is using asp.net 2005 and SQL Server 2005. When we call the help application then try to navigate in our application we sometimes get the error below. It is random and it only effects users who are not administrators on the server. Intially our application was opening a new window for the help, after the user closed the window it would cause this error. I’ve embedded the help into our application, but that still didn’t work.

    Our connection string in the web.config is:

    I changed the connection string to include some of the following, but it didn’t make a difference.

    Max Pool Size=200; Connection Lifetime=10000; Connection Timeout=120;

    11/24/2009 8:55:07 AM|E:\InetPub\WWWRoot\FLTMPS\LOGOUT.ASPX|Login failed for user ‘COMPOSE3\James.Smith’.| at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
    at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
    at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
    at System.Data.SqlClient.SqlConnection.Open()
    at fltmps.FLTMPSCommand.FLTMPSDeleteTmpSel(String Oracle_Connection_String, String strSessionID)
    at fltmps.Logout.Page_Load(Object sender, EventArgs e)

    Any help would be greatly appreciated.

    Thank you very much,
    Lorie

  69. Hello pinal im not getting the solutionof this error in sql server 2005…
    error is Error: 18452 Login failed for user ‘(null)’. The user is not associated with a trusted SQL Server connection.

  70. Hello Anish,

    Please provide us the information for following questions:
    How are you trying to connect to server I mean from SSMS or using linkedserver or from some application?
    Where from you are trying to login, server machine itself or from remote computer?
    Is this error coming for some specific login or for all logins?
    When this error started occurring?

    Regards,
    Pinal Dave

  71. May be this will be the most weird case:
    my co-worker can use windows login to connect to all servers except this one (say, named OperationServer) from his own computer.
    It will gives the 18452 error.
    However, login on other’s workstation using his login won’t throw error. Meaning the login and security are good.

    All other co-workers don’t have problem with this OperationServer with windows authentication.

  72. Hi Saiman,

    Every SQL Server instance has its own security and login on one server does not gaurantee to login on all servers. Please verify that on SQL Server, an enabled login having proper rights exists for user.
    Also verify that defult database for the user is available on server.

    Regards,
    Pinal Dave

  73. I had the same problem and tried almost all the tips in this thread and others around the Internet. However, none of them were useful for me. In my development environment I had been using a connection string which used a DNS name (Host A record, as a matter of fact) pointing to the IP of the server where SQL 2005 is installed.

    After trying several things, I finally went to the web.config and changed the connection string to the server name. After this, I got another message: Login failed for user ‘NT AUTHORITY\NETWORK SERVICE’. [CLIENT: ]

    I had seen another article saying to give this user access to the data base under User Mappings and after that all worked like a charm.

    Hope this is helpful for anyone.

  74. I am trying to connect my client machine with sql server but the error thrown each time is
    Connection :failed
    SQL State : 28000
    Sql Server Error : 18452
    [microsoft][sql server driver][sql server][login failed for user null.
    Reason : not associated with the trusted sql server connection.

    I have tried to change the above process described (Security-Login-----]

    and the second problem is its showing the name of server two times in the same list .. so is it conflicting with the server detection.

    I appreciate your feedback
    Thank you

  75. Thanks a lot for your article, as always it’s help me to solve The Problem. I really appreciated your articles.

    Thanks,

    kosxxx

  76. Hi , I have some problem in my maintenance plan
    The error is ..

    The Execute method on the task returned error code 0×80131904
    (A network-related or instance-specific error occurred while establishing a connection to SQL Server.
    The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server
    is configured to allow remote connections. (provider: TCP Provider, error: 0 – No connection could be made
    because the target machine actively refused it.)). The Execute method must succeed, and indicate the result
    using an “out” parameter. End Error Warning: 2010-02-15 10:41:09.83 Code: 0×80019002
    Source: OnPostExecute Description: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED.
    The Execution method succeeded, but the number of errors raised (2) reached … The package execution fa…
    The step failed.

    Please help me ..
    Thanks & Regards ,
    Sahasra….

  77. hi

    I have install sql 2005 in windows authentication now i want to connect with Server authentication but i can not connect i have create user with Server authentication

    error code is 18452

    Plz help me

  78. From my experience with this issue, the real solution is to ensure that the Windows account that the client is using to connect to the SQL server has been assigned “Access this computer from the network” rights in the Computer Config\Windows Settings\Security Settings\Local Policies\User Rights Assignment part of the group policy that applies to the computers in the domain where Windows authentication is being attempted.

    Moving to Mixed Mode is a work around. As best as I can tell, when you go to mixed mode, the client uses the Network Service account to connect to the SQL sever, and passes through the SQL credentials. However when you use Windows authentication, it uses the context of the logged in user to make the initial contact with the SQL server (before attempting to log in to the SQL database itself) and if the Windows account does not have the right to even access the SQL server computer on the network, then the request is rejected. Hence the username (null) in the response.

    Some of this is just guessing, but what I know for sure is that I was getting the (null) error using Windows only authentication, and setting up a GPO to allow the user account from the client to access the SQL sever computer from the network fixed it.

  79. Hi ,

    Can anyone explain the internal procedure how the Client connects to the SQL Server using Windows Authentication?

    I have two SQL 2005 servers A and B in two different windows 2003 servers . I have changed the IP of A server to point to B in the DNS and Flushed the resolver cache. Then connecting to the SQL server A is pointing B if the client is on another machine. Bu tif I connect to the SQL Server A from the B machine it is giving the following error:

    “Login failed for the user . The user is not associated with a trusted SQL Server Connection. (Microsoft SQL Server Error: 18452)

    Found this error in the SQL ERROR LOG:

    “Logon SSPI handshake failed with error code 0x8009030c while establishing a connection with integrated security; the connection has been closed. [CLIENT: 10.0.14.11]
    Logon Error: 18452, Severity: 14, State: 1.
    Login failed for user ”. The user is not associated with a trusted SQL Server connection. [CLIENT: 10.0.14.11] ”

    Is there any workaround for this?

  80. Hi
    I am getting an below error while i try to save the data. using ASP classic with SQL Server 2008 R2

    Microsoft OLE DB Provider for SQL Server error ’80040e4d’

    Login failed for user ‘WajClt\Imran’.

    /makhazin/savePassword.asp, line 9

    1. Server Name = WajClt-L03\sqlexpress
    2. User Name = WajClt-L03\imran
    3. Password= “”; password is empty

    below is my Connection string
    =========================

    Please help me out?

  81. Microsoft OLE DB Provider for SQL Server error ’80040e4d’

    Login failed for user ‘WajClt\Imran’.

    /makhazin/savePassword.asp, line 9

    here is the Connection string
    =========================

    Please help me out?

  82. Hi
    I am getting an below error while i try to save the data. using ASP classic with SQL Server 2008 R2

    Microsoft OLE DB Provider for SQL Server error ’80040e4d’

    Login failed for user ‘WajClt\Imran’.

    /makhazin/savePassword.asp, line 9

    1. Server Name = WajClt-L03\sqlexpress
    2. User Name = WajClt-L03\imran
    3. Password= “”; password is empty

    below is my Connection string
    =========================

    dim cn
    set cn = Server.CreateObject(“ADODB.Connection”)
    dim cnStr

    cnStr = “Provider=SQLOLEDB; Data Source=WajClt-L03\sqlexpress; Initial Catalog=empdata; User ID=WajClt-L03\Imran; Password=;”

    set Session(“cn”) = Server.CreateObject(“ADODB.Connection”)
    Session(“cnStr”) = cnStr

    Please help me out?

  83. Hi everyone..

    If your problem is “Connection failed:
    SQL state: ’28000′
    SQL server error:18452
    [Microsoft][ODBC SQL server driver][SQL server] login failed for user ‘asdf’. User is not associated with a trusted SQL server connection.”

    Please follow the next steps:
    1. In Object Explorer, right-click on your server\instance.
    2. Click properties.
    3. Select “security” option.
    4. Then, select “SQL Server and Windows Authentication mode”.
    5. Finally, click OK.

    After the last steps, now you can do the steps released by pinaldave.

    jjejjejje=)

  84. Could you please help me i see error 26 when i try to login(A metworl related or instance-specific error occured while establishing a con. to sql server)

  85. Hi everyone

    I have this problem with Microsoft SQL Server
    Connection failed:
    SQLState: ’28000′
    SQL Server Error: 18456
    [Microsoft][SQL Native Client][SQL Server]Login failed

    Please help me out?

  86. i installed sql2005(x86) on serve 2008r2
    wen i connect with vb6 from winxp(x86) to sql i get error 10060

    if any one know about this problem
    thenk you yacov

  87. @”Initial Catalog=AccountMenagmenta;Integrated Security=SSPI;Persist Security Info=False; Data Source=MAINSERVER\SQLEXPRESS”;

    this string i running in my three computer to connect Remote Connection to Server
    but One Computer is showing me below Error

    TITLE: Connect to Server
    ——————————

    Cannot connect to MAINSERVER\SQLEXPRESS.

    ——————————
    ADDITIONAL INFORMATION:

    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 – No such host is known.) (Microsoft SQL Server, Error: 11001)

    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=11001&LinkId=20476

    ——————————
    BUTTONS:

    OK
    ——————————

  88. Hi im using Visual Studio 2008 & MS SQL SERVER Management Studio Express

    i don’t know where is my error

    Please help me out?

    THIS IS MY REGISTER.

    Imports System.Data.Sql
    Imports System.Data.SqlClient
    Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    ‘Dim connection As String = ConfigurationManager.ConnectionStrings(“Data Source=JED-PC;Initial Catalog=comicon;Trusted_Connection=True”).ConnectionString

    Using cn As New SqlConnection
    cn.ConnectionString = “Data Source=JED-PC;Initial Catalog=comicon;Trusted_Connection=True”
    Dim c As String
    c = “INSERT INTO Logins(First_Name,Last_Name,Password,Address,Contact_No,Email,Account) VALUES (‘” & TextBox1.Text.Trim & “‘,’” & TextBox2.Text.Trim & “‘,’” & TextBox3.Text.Trim & “‘,’” & TextBox5.Text.Trim & “‘” & “, ‘” & TextBox6.Text.Trim & “‘,’” & TextBox7.Text.Trim & “‘,’1′ )”
    Dim sqlcmd1 As New Data.SqlClient.SqlCommand
    sqlcmd1.Connection = cn
    Try
    cn.Open()
    sqlcmd1.CommandText = c
    sqlcmd1.ExecuteNonQuery()
    cn.Close()

    Catch ex As Exception
    MsgBox(ex.ToString)

    End Try

    If TextBox6.Text.Length < 7 Then
    MsgBox("contact # is too short")

    Else
    Button1.Visible = True
    MsgBox("Your Successfully Registered", 6, "Confirmation Message")
    Response.Redirect("Login.aspx")
    End If
    End Using

    End Sub
    End Class

  89. (When I Submit it won’t redirect to other..)

    Imports System.Data.Sql
    Imports System.Data.SqlClient
    Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim connection As String = ConfigurationManager.ConnectionStrings(“Data Source=JED-PC;Initial Catalog=comicon;Trusted_Connection=True”).ConnectionString

    Using cn As New SqlConnection
    Dim Account As String
    Dim login As String
    login = “Select count(*) from Logins where Email = ‘” & TextBox1.Text & “‘ and Password = ‘” & TextBox2.Text & “‘”
    Dim sqlcmd1 As New SqlCommand(login, cn)
    Try

    cn.Open()
    Account = sqlcmd1.ExecuteScalar

    If Account = 1 Then
    sqlcmd1.CommandText = login
    Account = sqlcmd1.ExecuteScalar()
    cn.Close()

    Select Case Account
    Case 0
    MsgBox(“welcome admin”)
    Session(“Logins”) = TextBox1.Text
    Response.Redirect(“/planetcomic/user/admin/Home.aspx”)
    Case 1
    MsgBox(“You are Succesfully Login”)
    Session(“Logins”) = TextBox2.Text()
    Response.Redirect(“/planetcomic/user/customer/Home.aspx”)

    Case Else
    Label6.Text = “Invalid Login or Password”
    TextBox1.Text = “”
    TextBox2.Text = “”
    Label6.Visible = True
    cn.Close()

    ‘If sqlcmd1.ExecuteScalar = “1″ Then
    ‘Session(“Login”) = TextBox1.Text
    ‘Response.Redirect(“/planetcomic/user/customer/Home.aspx”)

    End Select
    End If
    Catch ex As Exception
    MsgBox(“Welcome to Planetx”)

    End Try

    End Using
    End Sub

    End Class

  90. There is still an error raised while I’m trying to solve the problm using this method. BUt there is another way to overocme this problem by checking wheter your password has been expired.

    I restarted my computer and change the pasword and the problem solved.

  91. Initial problem resolved but now getting error “a connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 – No process is on the other end of the pipe.) (Microsoft SQL Server, Error: 233)”

  92. hi

    i am new to sql dba

    can anyone help me the difference between login and user. i am tring to create login with windows authentication but in vain.

  93. Hi Pinal,

    I have read many of your wonderful blogs.

    I am running SQL 2000 Standard edition (SP3) and am getting the error though the instance is in Mixed authentication mode.

    I am trying to access the SQL server from the domain A while the SQL server is in Domain B. But I know that both these domains trust each other and we have other servers in domain B which are accessible from the server in domain A.

    Your resolution would be a turning point to me.

  94. If none of solutions works… try this:

    1. Open “Object Explorer”
    2. Right click on instance name
    3. Properties
    4. Select a page “Security”
    5. On ‘Server authentication’, select ‘SQL Server and Windows authentication’

    After that you MUST restart the SQL instance service and, sometimes the SQL Browser.

    Just this procedure really helped me (however, maybe is not the only one).

  95. Hello,

    I have scripts develped on access 2003 linked to SQL server 2000, and now, the SQL server has being upgraded to 2008. Now every time I run the query an error box appears:

    Run-time error ‘-2147165949 (8004d903)’:
    [Microsoft][SQL Server Native Client 10.0][SQL Server]To connect to this server you must use SQL Server Management Studio or SQL Server Management Objects (SMO)…

    Anyone has a clue on what do I need to do to get this connection??…

    Thank you very much!

  96. can you please send me a MYSQL configuration pdf to my mail box.PLEASE…thanks

    please write in details were i can go on windows 7 proffesionl

  97. TITLE: Connect to Server
    ——————————

    Cannot connect to CHRISTIAN-PC\SQLEXPRESS.

    ——————————
    ADDITIONAL INFORMATION:

    Login failed for user ‘sa’. The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452)

    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=18452&LinkId=20476

    ——————————
    BUTTONS:

    OK
    ——————————

  98. @ Sukh,

    You said, you have two databases one on SQL Server 2008 R2 and other on SQL Server 2008, is that right.

    And you mentioned, When Users Log Off, then their login works, Can you tell me which Log off you are referring to, OS Log off or Application Log off.

    Do Users connect to database directly using SSMS or through an Application, Does that Application uses Windows Authentication or SQL Authentication.

    Please provide more details. And Please be clear… Your explanation is bit confusing.

    ~ IM.

    • Imran, We have only one database SQL2008r2 and the log off is from OS not the application.

      User connect through the application with window authentication.

      Please tell me if you have any question. I am tired of this error.

      Thanks

  99. I’m Sankar working in a software company,_____
    I’m having the error while running the below query in sql 2000

    SELECT a.*
    FROM OPENROWSET(‘SQLOLEDB’,’jil1′; ‘sa’; ”,’SELECT * FROM whmmaindb.dbo.temptag’) AS a

    I used this for inserting data from one database to another ,But i got the error

    Server: Msg 18452, Level 14, State 1, Line 1
    Login failed for user ‘sa’. Reason: Not associated with a trusted SQL Server connection.

    please help me,….!

  100. I had the problem that I could log in as sa but when I tried my windows account I got that error about not being associated with a trusted connection even though my windows acount had all the necessary permissions.

    Turned out that when we changed our domain server the database server had been left using the wrong DNS server IP Address and so all we had to do to fix this was change the database server’s network connection to use the correct DNS server IP address for the new domain.

    Hope this helps someone.

  101. Hi pinal,

    i’ve installed sql server 2008 R2 on windows 2003 server successfully. Later i’ve created a sql login (eg: laddu) and tried to access the sql server with the sql login created. But i’m getting an error stating that “Login failed to connect to sql server”. i’ve tried many times, but unable to success. please help me out with this problem.

  102. Hi Pinal,

    Thanks for this post. I have a strange problem, I’m using a VB6 application to connect to a SQL Server 2005 database. I set up a DSN connection which I use in the code. It connects with no problem when the SQL Server is on the same computer. But when the database in on a remote server, it gives me the error “Login failed for user ”. The user is not associated with a trusted SQL Server connection.

    The SQL Server has Mixed Mode enabled, and when I set up the DSN it connects ok when I put in the correct sa login and password. However, when the VB6 application tries to connect using this same DSN, it fails with that error. What could be the problem?

  103. Hi, If you’ll look for my post I think you’ll find your problem similar. Try making sure your SQL is looking for the username and password your system login uses.

  104. Hi,
    We are about to DR setup using Window Server 2003 and MSSQL 2005 SP3.
    Our PRD and DR server domains are differ but they do have a trusted relationship between each other.
    DB restoration is completed on DR server but I am stuck when I am applying Log shipping method to make PRD and DR server in sync.
    At the point when I have to select DR as a secondary server, I am not getting my DR server name only PRD server name is there.
    While if I tried the same thing on DR server (just for check) I got PRD server SID as a secondary server.

    Could you please let me know how to resolve it?

    Regards,
    Ankit

  105. hello Sir,
    i read all the problem and reply above but my problem very strange and unique .
    i install sql server 2008 operation system window2003 and sql database connected to attendance software.

    after installation sql server2008 running very well without any problem and login sucessfuly. but after 15 to 20 days sql server not login .

    so i uninstall and again new install sql server 2008 many time but this problem comes again reaptly after 15 to 20 days sql server not login .
    please help me to solved
    Thank you.
    narendra

    Error Details ————->

    TITLE: Connect to Server
    ——————————

    Cannot connect to SCIL-SINGACH.

    ——————————
    ADDITIONAL INFORMATION:

    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 53)

    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=53&LinkId=20476

    ——————————
    BUTTONS:

    OK
    ——————————

  106. OK, this is odd. new replacement machine everything installed fine, local administrator account can connect fine. PC user account can’t connect and won’t configure ODBC. I can’t see any issues with the account name etc, It’s a replacement machine so the account is an old one. workgroup not domain.

  107. hi .im using TCP/IP address to connect pc to pc remote. anyone can help?

    1 pc stored the database. and .successfully connected.

    but the other pc can’t connect. i got this error
    Login failed for user ‘sa’. The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452)

  108. i installed sql server 2000 sp4 in windows 7 when i log in in Query analyzer a error occurred “unable to connect to server server:18452, level 16 stage 1

  109. Hi Pinal,

    My problem may not be strictly related to SQL Server, but here is my problem. I connect to SQL Server in domain using my domain account. The domain account password expires every three months. I have changed the password several times in the past without a hitch. This time around, my account gets locked out periodically. I checked all the jobs in all SQL Servers in the domain to see if any of them is using my account. I found couple of jobs running ssis packages with credentials using my account. I updated the password on them and jobs run fine. However, I keep getting locked out periodically.

    I check the error longs and I find error message:
    Error:18456, Severity:14 State:11

    State 11 refers to “valid login but server access failure”.

    I tried changing back the password to previous password (which was working fine) but didn’t help.

    I also checked if any services are running under my account, didn’t find any.

    I hope you can guide me on to resolve this issue.

    Thanks in advance for you guidance.

    –Subash

  110. Hello Pinal Sir,

    How r u ?

    I have one problem. I have two SQL Server, e.g. ‘Server1′ and ‘Server2′. Server1 is connected with windows authentication and Server2 is connected with SQL Authentication.

    I am trying to create LinkedServer of Server1 in Server 2. but i am unable to do it because i don’t know how to create linked server of Windows authenticated Server.

    I enabled and set password of sa login of Server1. I again tried to create linked server of Server1 in Server2 by giving Server1 ‘sa’ login credentials as remote login and password. but still i am getting connection failed error in linked server. When i tried to create linked server of Server 2 in Server1 following the same steps, it created successfully. I was able to run SQL command from Server2 to Server1 using Linked Server.

    I am getting error like this.

    “A Network related or instance specific error has occurred while establishing connection to SQL Server. (Microsoft SQL Server, Error : 65535)”

    Please give me the solution..

  111. Hello,

    i’ve been looking around for a solution to my issue but to no avail ! Here is the scenario:

    I am using Visual C# 2005 Express Edition and SQL 2005 Express Edition.
    I wrote a little C# windows application that is using a sql database. I tested it and published it locally and my application works locally, on, in my PC.
    Now, what i want is to be able to take this application (with all its related files to make it work after publishing) and put it (literally) in a another PC running Server 2003 so that people in my office can use this application from their PC through the LAN.

    The steps (that come from my readings in various online forums) i have done for that are:

    - i created a folder on a central PC (the one running Server 2003) and shared it so that users can access the .exe file and the related
    .mdf file along with the other linked files.
    - using SQL Server Management Studio Express (SSMSE) 2005, i changed my SQL instance (on that central PC) to allow remote
    connections and to allow for both SQL server and Windows authentication mode
    - i created a user account, on the central PC, through SSMSE -> Security -> Logins
    - i created a user: SQLServer2005SQLBrowserUser$SERVERNAME, through MY Computer -> Manage -> Local User Groups and Groups option
    - this is the connection string (took from the .config file):

    I guess that this connection string has to be changed (among other things) for my application to work on a LAN,
    would you mind helping me and show me the EXACT steps to carry out in order for my app to work on a LAN, PLEASE ?

    Thx a million !

  112. Dear All,

    For same query…we have to verify the “ERRORLOG” SQL log file and open SSMS server(RUN as ADMINISTRATOR)

    Will work.

  113. Thank you
    You often benefited from the first error I found that completed the connection to the database
    Repeat, thank you very much

  114. @Mohamad..

    I need your help..

    Problem : When i do database connectivity through java with sql server 2008 i got error tha “sql server Exception : Login failed for ”

    I tried every thing..
    1)changed from windows authenticate mode to mixed mode
    2)enabme tcp/ip port
    3)set default port number 1433
    4)created database and gave access to that database for perticular login and use

    i tried all of above things but its not working..

    Please help me out..

    Thanks in advance..

  115. hi

    i was fighting with this error..finally i found a solution…now all works fine..

    try following steps..

    Set Guest account ‘turned on’ in server machine
    Add new login ‘servername\guest’ under Security > Logins in Sql Server
    Add this login to the databases accordingly
    Give required permissions

    regards

    Harris P Nair

  116. hi friends i have used windows 7 64 bit and sql server 2005. when i run the program. i have found some errors

    [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user ‘IMRAN-PC\IMRAN’.
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at Ontology.(Ontology.java:11)
    at ServerBoard.(ServerBoard.java:19)
    at Myserver.main(Myserver.java:19)

    How to solve that error

    • For this Case : SQL SERVER – Fix : Error: 18452 Login failed for user ‘(null)’. The user is not associated with a trusted SQL Server connection.
      I try delete fin.zup and open nav app again.

  117. hi Pinal i am very new user to sql-server, I’am using sqlserver SQL 2005 Express Edition on my computer with windows authenticationm mode. i have created a user named “testUser” now i want to login with the user which i hve created bu when i try to login with “testUser” server gives an error.
    SQL SERVER – Fix : Error: 18452 Login failed for user ‘(null)’. The user is not associated with a trusted SQL Server connection.

  118. hi Pinal, im very new to sqlserver. I am using 2005 Express Edition with windows authentication mode. here i have created a new user named “testUser”. but when i’m trying to login with “testUser” server gives Error: 18452 Login failed for user ‘(null)’. The user is not associated with a trusted SQL Server connection. how can i login with “testUser”?

  119. I am getting this error on 2008 R2 when I am calling a SSRS report from another report. The report with the error has the same shared datasource as all the other reports and the dataset in the report is calling a stored procedure. This stored procedure is basically executing 14 different stored procedures in a sequential manner. Please note that all the stored procedures reside in the same database (no linked server or external server reference in the code). The SSRS reports are hosted on a different server from the database server. All reports run great except for this one report where I get the error
    “An error has occurred during report processing. (rsProcessingAborted)
    Query execution failed for dataset ‘NewRefreshMacroDataset’. (rsErrorExecutingCommand)
    Login failed for user ‘(null)’. Reason: Not associated with a trusted SQL Server connection.”

    Any help is greatly appreciated. I have tried all possible solutions listed in this blog but to no avail. Thanks in advance!!!

  120. i have local server which is running properly, but i fix static ip to that particular server machine, from that day it gives me error(login failed ‘sa’ user) after 2-3 days contentiously .pls help me.
    Regards Vijay….

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s