Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection

"[DBNETLIB] Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection"
After patches applied on patch Tuesday the database reports the above error. 
All accounts are domain accounts and SQLServer uses Windows auth.
DCDIAG show no errors
All servers and DC have been restarted,
Message in db log confirms the connection is being denied due to trust.
Event log shows same rejection
Protocols enabled: named pipes, tcpip, memory
TESTS:
PortQry: "
TCP port 1433 (ms-sql-s service): LISTENING"
Connect with domain admin accounts works from multiple clients systems to DB.
Cannot connect with newly created domain admin account
Can connect if new admin account connect to server in terminal server session and uses UDL wizard or any other tool including isql.
New standard user also fails to connect.
NOTES:
I removed the SSL patch and the IE security update to see if that was an issue.
¯\_(ツ)_/¯

Has someone left the company or has an account of some nature been dropped/replaced?
Please click "Mark As Answer" if my post helped. Tony C.
Hi Tony,
Srry but No.  We just installed the monthly updates.
I went back and found I had missed removing a patch.  I missed the rollup for Windows Server 2003:
Event Type: Information
Event Source: NtServicePack
Event Category: None
Event ID: 4382
Date:  3/12/2015
Time:  12:26:04 PM
User:  NETTEST\admin
Computer: DATA1
Description:
Windows Server 2003 KB954920 was removed from your computer, and the previous Windows Server 2003 configuration was restored.
After I removed that is still didn't work but after about five minutes it started working.
I guess I ned to report that to MS after I research what might be changed to make the patch work.
Every time I get stuck and ask for help it seems to be just before I stumble on the solution.
Thanks for replying.
Well - maybe this will help someone else.
Thanks again for replying Tony
¯\_(ツ)_/¯

Similar Messages

  • Non-SysAdmins get error 18456 Severity 14 State 11 Login Failed for user _ Reason Token-based server access validation failed with an infrastructure error.

    I have a SQL 2008 R2 system (10.50.4000) where I'm having problems connecting any user that is not a SysAdmin.  Example: I setup a new SQL Login to use Windows Authentication and grant that user db_datareader on the target database.  The user attempts
    to connect using Excel client or Access or SQL Management Studio and receives Error 18456.  The SQL Server Logs shows Error 18456 Severity 14 State 11 Login Failed for user _ Reason Token-based server access validation failed with an infrastructure error.
    The strange part is that if I temporarily grant the user the sysadmin server role then the user can connect successfully and retrieve data.  But, if I take away that sysadmin server role then the user can no longer connect but again receives the Error
    18456 Severity 14 State 11 Login Failed for user _ Reason Token-based server access validation failed with an infrastructure error.
    We've turned off UAC on the client machine to see if that was the problem, but no change.
    I have dropped and re-added the user's SQL Login (and the related database user login info).  No success.
    The Ring Buffers output shows:
    The Calling API Name: LookupAccountSidInternal
    API Name: LookupAccountSid
    Error Code: 0x534
    Thanks for any help.
    -Walt

    Yes, you understand correctly.  The user is logging onto a workstation (not the server) with a Windows Authenticated id.  The user is using either Excel or Access or SSMS and connecting to the server using a Windows Authenticated SQL Login account.
     If the account has sysadmin role (which is only for testing) then the connection is successful.  If I take away sysadmin role from the account then the connection is unsuccessful and the SQL Server Log shows Error
    18456 Severity 14 State 11 Login Failed for user _ Reason Token-based server access validation failed with an infrastructure error.
    (SQL Authentication is not an option here.  I must use Windows Authentication).
    Any other troubleshooting assistance you can offer would be appreciated.  Thanks.
    -Walt 

  • Com.microsoft.sqlserver.jdbc.SQLServerException Login failed for user '' ..

    Hi All,
    I have the following weird problem when trying to connect to MSSQL 2005 database using JDBC and windows authentication.
    I am using the following command:
    DriverManager.getConnection("jdbc:sqlserver://<<MACHINE IP>>:;database=<<DB NAME>>;integratedSecurity=true;","<<DOMAIN USER NAME>>","<<DOMAIN USER PASSWORD>>")and I get the following exception:
    com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user ''. The user is not associated with a trusted SQL Server connection.
    I tried to google this exception but all I can see is similar one but the exception also contain the user name. Please note that in the exception I get, the user name is not listed..
    I also checked it with various connection strings (I also tried to put the user name and password in the connection string, using the parameters 'user' and 'password'), but I always get the same result.
    Also, when I used SQL authentication I am able to connect to the SQL (after I remove the 'integratedSecurity' param).
    The SQL server is configured to work with both SQL and Windows authentication- I am able to log in to the SQL (with Microsoft SQL server management studio express) with the same windows user.
    The sqljdbc_auth.dll is also located in the class path.
    Does anyone have any idea what I am doing wrong?
    Thanks,
    Uri

    jschell wrote:
    TheAvalanche wrote:
    When I log in to the MySQL server, using windows authentication, I see that it use the same domain user I try to use via JDBC. Is there anything else I need to configure?
    You need to load a sqljdbc_auth.dll (or more specifically: point to it with -Djava.library.path or add it to the path), as is explained in the Microsoft SQL Server JDBC documentation on integrated security: [http://msdn.microsoft.com/en-us/library/ms378428.aspx]
    Interesting. One would hope that it would at least provide a different error message if it didn't find that.I don't know, I haven't used integratedSecurity much. With the DLL the JDBC driver will send the credentials of the currently logged in user to the database server, and maybe the parameter integratedSecurity=true is just an instruction to the database server to actually use those credentials for login if they are there, or maybe supplying a user name and password as the OP did will override the integratedSecurity setting and the DLL is never actually used.

  • SSPI handshake failed with error code 0x8009030c and Login failed for user''

    I got the following error when tried to connect to local machine in the
    non-domain environment with Windows Authentication by SSMS.
    "SSPI handshake failed with error code 0x8009030c while establishing a connection with integrated security."
    "Login failed for user''. the user is nothing associated with a trusted SQL server connection."
    questions
    1,if I saw the "SSPI handshake failed ", does it means it must used Kerberos but failed? or it is also possible used the NTLM but failed?
    2,Any ideas for this issue?
    Please click the Mark as Answer button if a post solves your problem!

    Hi Michael,
    Firstly, "SSPI Handshake Failed" error happens usually when connection failed between the server and domain controllers or failed Kerberos authentication. For more details about "SSPI Handshake Failed" error, please review this
    FAQ.
    Secondly, regarding to your error message, it could be caused by loopback check. To resolve the issue, please set the DisableLoopbackCheck registry entry to 1 by performing the following steps.
    1.Click Start, click Run, type regedit, and then click OK.
    2.Locate and then click the following registry subkey: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
    3.Right-click Lsa, point to New, and then click DWORD Value.
    4.Type DisableLoopbackCheck, and then press ENTER.
    5.Right-click DisableLoopbackCheck, and then click Modify.
    6.In the Value data box, type 1, and then click OK.
    7.Exit Registry Editor.
    8.Restart the computer.
    There is a similar blog about your scenario for your reference.
    http://www.bhcblog.com/2009/10/08/fix-for-login-failed-for-user-the-user-is-not-associated-with-a-trusted-sql-server-connection/
    Thanks,
    Lydia Zhang
    If you have any feedback on our support, please click
    here.
    Lydia Zhang
    TechNet Community Support

  • Cannot connect to SERVER. Login failed for user 'DOMAIN\user'. (Microsoft SQL Server, Error 18456) - SQL Server 2012 on Windows Server 2008 R2

    I've seen multiple blogs and forums with similar problems and SQL 2012 or 2008. But no solutions that work for me.
    I have installed SQL Server in mixed mode (SQL and Windows authentication). I can create new Login accounts in either mode. However, I cannot get an AD security group Login account to work. I am trying to add group 'DOMAIN\Domain Admins' or 'SERVER\Administrators'
    as a Login so that any of the domain's administrator accounts can open SQL Server Management Studio and act as an 'sa' account on this server.
    I have deleted the SQL account 'DOMAIN\Domain Admins'.
    I have restarted SQL.
    I have restarted the Win2K8r2 server.
    I have launched SSMS as Administrator from the desktop of SERVER.
    I have launched SSMS as another user (and used 'DOMAIN\user' to lauch it) from the desktop of SERVER.
    I can create a login account named 'DOMAIN\user' (who happens to be a member of the 'DOMAIN\Domain Admins' group) and give this account 'sa' security, and when I do that, this account works as expected...
    How do I add a security group as a Login account and give all members of that group the ability to be an 'sa' account?

    Hi geoperkins,
    Are you getting the following error message?
    Error: 18456, Severity: 14, State: 11
    Login failed for user <Domain\user>. Reason: Token-based server access validation failed with an infrastructure error.
    If that is the case, the issue could be due to that the Windows login has no profile or that permissions could not be checked due to UAC. Please disable UAC firstly and check if it is successful to log in SQL Server.
    Another reason could be that the domain controller could not be reached. You may need to resort to re-creating the login. Create a new group in AD, add users to the new group, then add the group to the local admin group and create login for the group in SQL
    Server.
    There is a connect item describing similar issue for your reference.
    https://connect.microsoft.com/SQLServer/feedback/details/680705/cant-login-to-sql-using-windows-authentication-when-user-is-in-a-domain-security-group
    For more details about above error, please review the following blog.
    http://sqlblogcasts.com/blogs/simons/archive/2011/02/01/solution-login-failed-for-user-x-reason-token-based-server-access-validation-failed-and-error-18456.aspx
    Thanks,
    Lydia Zhang
    Lydia Zhang
    TechNet Community Support

  • Login failed for user

    I am getting the below error in SQl server error log for every 15 min. I ran profiler to  find out what database it is trying to access, found that it is trying to access master.
    I am getting this error because I removed NT AUTHORITY\SYSTEM from SYSADMIN group because all my SQl server services are running with domain account and i don't want to give SYSADMIN for that account, is there any way that we can eliminate the error.
    Login failed for user 'NT AUTHORITY\SYSTEM'. Reason: Failed to open the explicitly specified database. [CLIENT: xx.xx.xx.xx]
    Error: 18456, Severity: 14, State: 38.

    Hi,
    The error message is thrown out since the login has insufficient privilege. In this case, the NT AUTHORITY\SYSTEM has not sysadmin privileges because it is moved the permission.
    I agree with Shanky. You need to address Microsoft Monitoring Agent issue first. You can get the help from System Center Operations Manager forum:
    http://social.technet.microsoft.com/Forums/en-US/home?forum=operationsmanagergeneral
    Reference:
    http://social.technet.microsoft.com/Forums/en-US/23f6b6cb-ec41-4117-8613-26d24c948827/login-failed-for-user-username-reason-failed-to-open-the-explicitly-specified-database
    Hope it helps.
    Tracy Cai
    TechNet Community Support

  • Sql Server 2012 Login Failed for user "NT Authority\System"

    I have installed SQL Server on a new server. I have been getting the following error on each of the database in it.
    Login failed for user 'NT AUTHORITY\SYSTEM'. Reason: Failed to open the explicitly specified database 'ABC'. [CLIENT: xxx.xxx.xxx.xxx]
    Here is some information on the instance:
    1) Default instance
    2) SQL Server, Sql Server Agent, Sql Server Reporting services are running / log on using a domain service account.
    3) Sql Server Browser is disabled.
    4) SQL Server VSS Writer is running / log on as Local Service.
    5) NT AUTHORITY\SYSTEM does exists in Login with just public server roles.
    I ran a trace on login failed and I get:
    ApplicationName: Microsoft Windows Script Host
    and it runs every 15 minutes.
    Help please?

    Hi,
    The error was thrown when the SCOM components connected to the backend SCOM databases.
     You can specify a domain account, grant it the sysadmin role and the error should be gone.
    Also, see the replies in your previous thread:
    http://social.technet.microsoft.com/Forums/en-US/23f6b6cb-ec41-4117-8613-26d24c948827/login-failed-for-user-username-reason-failed-to-open-the-explicitly-specified-database
    Thanks.
    Tracy Cai
    TechNet Community Support

  • SQL Error Log: Login Failed for User ''

    Hi B1 experts,
    currently i have a little problem with our SAP System or better SQL Server. Everytime when a SAP client is started, the SQL Server get the following warning message:
    Login failed for user ''. Fehler bei der Anmeldung mit der SQL Authentifizierung. Der Server ist nur für die Windows-Authentifizierung konfiguriert. Client: IP
    Fehler 18456, Schweregrad 14, Status 58.
    The same message occurs when i log into sap. The funktionality of SAP is not impaired.
    I have checked the server authentification mode and the sql server is SQL and Windows Authentification configured.
    SQL Server: 2008 R2
    SAP System: SAP B1 8.8 PL19
    Client System: Windows 7
    Someone any ideas?
    Regards,
    Sabine

    Hi Rahul, Hi Julie,
    thanks for your replys
    @Rahul:
    all named pipes are aktiv. the services are all on automatic mode
    @Julie
    Our Server is running with SQL authentication. We do not use trusted connection generally - security risk.
    Further i have disables all Addon. the error occurs again.
    We do not use the SBO Mailer, he isn't installed.
    Regards,
    Sabine

  • SQL Server Log: Login failed for user ''

    We've found in SQL Server Log many records:
    Date
    3/22/2013 11:13:03 AM
    Log
    Windows NT (Application)
    Source
    MSSQLSERVER
    Category
    Logon
    Event
    3221243928
    Computer
    SBO05
    Message
    Login failed for user ''. Reason: An attempt to login using SQL authentication failed. Server is configured for Windows authentication only. [CLIENT: <local machine>]
    The server autentification is set to "SQL Server and Windows Autentification mode". But when we open SAP, before entering login/password, we see this message in log. But we still could work in SAP.
    How could we solve this?
    Kind regards,
    Anna Shevchenko

    Hi Joseph,
    It doesn't help. The same things i've already done.
    But when I change Mixed Autentification to Windows, i see another error:
    Date
    3/22/2013 11:04:26 AM
    Log
    SQL Server (Current - 3/22/2013 12:33:00 PM)
    Source
    Logon
    Message
    Login failed for user 'sa'. Reason: Failed to open the explicitly specified database. [CLIENT: 192.168.0.145]
    Do you know why?
    Kind regards,
    Anna Shevchenko

  • Reports successfully execute but generate a login failed for user 'sa' err

    I am running Crystal Reports Server XI R2. Classic ASP is used to generate embedded reports within our application. The crystal reports use ODBC to connect to a SQL Server 2005 database. The reports successfully generate in our Classic ASP application. However in SQL Server 2005,  the following error messages are being generated each time a crystal report is ran:
    - Login failed for user 'sa'.
    - Error: 18456, Severity: 14, State: 8.
    We know that we are passing the correct username/password to the crystal reports, becuase they execute successfully.
    It appears that when the report is called, Crystal Reports appears to conect to SQL Server using a username/password that we didn't provide it at execution time, this fails and the SQL Server 'login failed for user' is generated. Then it runs the report using the username/password we provide and it successfully generates a report.
    I have ran Profiler against the SQL Server Database and the 'Login failed for user 'sa' ' errors have a ApplicationName of either 'Seagate Crystal Reports' or 'Crystal Reports'. Therefore I know it is Crystal Reports generating these errors in SQL Server.
    Does anyone have any ideas on how to stop these SQL Server 'Login failed for user 'sa' ' errors being generated?

    What happens if you use Profiler when running the report using Crystal Report Designer?
    If the report is ran through Crystal Report Designer, NO 'Login failed for user' error messages appear in profiler. Everything looks ok when ran in Designer.
    Also, need to know what patch level you are on?
    We are running Crystal Reports Server XI Release 2, Version: 11.5.8.8265
    No additional patchs have been applied since Crystal Reports Server was installed.
    We may try the SA account if one of the connections fail to log on with the credentials you provided. Verify the user you logged on with has rights to all tables.
    The reports were running through our application using the SA account. The SA account has permissions to these tables. The reports do generate results and appear perfectly fine in the application.  The issue is that when our application requests the report from Crystal Reports Server. Crystal Reports Server delivers the correct report to our application. However during the process to generate the report, 'login failed for user 'sa' ' errors are being generated in SQL Server 2005.
    Also, I have tried creating a completely new SQL user called 'crystaluser'. I ran the report using Crystal Report Designer and used the crystaluser logon and saved the report. Then I ran the same report through our application. SQL Profiler will then display 'login failed for user 'crystaluser''. 
    Its seems as though Crystal Reports Server is first executing the report using the default SQL user saved with the report, but is either sending a blank password or no password at all. This generates the 'login failed for user' in SQL Server 2005. But it then uses the SQL username/password my application gives it and successfully generates the report. Of course this is only speculation.

  • SQL Server Agent job between 2 instances fails with Error 18456 - Login Failed for user

    Hi,
    SQL Server version: 2012 EE
    OS: Windows 2008 R2 Enterprise
    In my server, i have 2 instances, and I am trying to configure a SQL Server Agent job to query one table in Instance A, and insert some modified data in Instance B, both in the same server.
    When i execute the job in instance A, i get the following error:
    Executed as user: NT SERVICE\SQLSERVERAGENT. Login Failed for user "NT SERVICE\SQLSERVERAGENT". [SQLSTATE 28000] (Error 18456). The step failed.
    I have already configure instance A as Master and disabled encryption, by changing the parameter MsxEncryptChannelOptions to 0 in regedit. I've also made my target instance (instance B) as a Target.
    What am i missing?
    Thanks for your attention and pacience

    Hello,
    The NT SERVICE\SQLSERVERAGENT (virtual) account is not available on the other as you just mentioned. That is the reason for the login
    failed error. Try using a Windows login as the
    SQL Server Agent service account in both servers, the same Windows login (not a virtual account), and run jobs as the “sa” account.
    http://msdn.microsoft.com/en-us/library/ms345578.aspx
    You can also try a proxy account.
    http://technet.microsoft.com/en-US/library/ms190698(v=SQL.105).aspx
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.

    Trying to get an admin type report working from the server.  Works fine when I run it from BIDS since I have all the associated permissions.  The report connects to multiple databases on different servers.  The servers have links between them,
    that is not the issues.  I think I would have to change the security settings on the report server itself.
    I read the similar posts, but didnt see any mention of verifying the security settings on Report Server itself, in IIS.  In my case the web site that the Report Server app is under, has "Allow Anonymous" checked, but not on the app.  So
    I think that as I hit the url, my credentials are not being carried through.  When I browse the report locally on the server, i get 
    Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.
    Im using integrated windows security for my data sources.

    Actually, I think its an issue of Kereros authentication not being enabled for some of the servers that are being referenced in the datasets of the report.
    http://blogs.msdn.com/b/sql_protocols/archive/2005/10/12/479871.aspx

  • Cannot open database "ReportServer" requested by the login. The login failed. Login failed for user 'USER LOGON'

    I want to grant permissions to all domain users to view reports on our Report Server. Domain users are able to access our Report Server URL and folder, but when they click on a report item they get an error message: 
    "Cannot open database "ReportServer" requested by the login. The login failed. Login failed for user 'USER LOGON'"
    I'm using windows authentication and configured the local service account in SSReportS Config Manager as the credentials to connect to the Report Server DB. 
    Can someone please help how I should properly do this step by step to give all domain users permissions to view a report in SSRS?
    Thanks much! - Rookie DBA

    Hi IWAR,
    The error message "Cannot open database "ReportServer" requested by the login. The login failed. Login failed for user 'USER LOGON'" means the user 'USER LOGON' does not have permissions to access the "ReportServer" database.
    To fix this issue, please verify that the user has a valid database user login. For more details, please refer to the following steps.
    In SQL Server Management Studio, open Object Explorer and expand the Databases folder.
    Expand the database in which to create the new database user.
    Right-click the Security folder, point to New, and then click User.
    On the General page, enter a name for the new user in the User name box.
    In the Login name box, enter the name of a SQL Server login to map to the database user.
    Click OK.
    Reference:
    http://technet.microsoft.com/en-us/library/ms156468(v=sql.105).aspx
    Hope this helps.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Deployment issue - Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

    I am attempting to deploy a site from my development PC to my server. I have no issues running the site on the server using VS2010 Express Web in debug. All page queries are working within the debugger. The connection strings are identical between the PC
    and Server, except the host name.
    connectionString
    ="Data
    Source=SOCIALSERVER;Initial Catalog=Intake_be;Integrated Security=True"
    However, when using the site normally via IIS, the pages containing data access are failing with a permissions problem. The non-data access pages render normally.
    Login failed for user 'NT AUTHORITY\NETWORK SERVICE'
    Looking at the SQL2005 instance via SQL Management Studio, I see security folder with Logins under the Server. NTA\NS is listed as a user login. But, I also see similar folders under each
    of 3 databases. NTA\NS is not listed as a login specific to my target dB.
    My site is for internal (intranet) use only. There is no internet access into my IIS. This is my first deployment into production. I think I only need Windows Authentication but I lack the experience to make a good decision. My goal is to allow domain users
    to access pages that produce read only data. But, I also need controlled access to pages that can modify data. I used the native winform template for ASP.NET 4, which includes some roles based security.
    How do I grant permissions for internal users on the pages that access SQL data? How does that security model work with the native roles based security? i.e.
    add
    name="AspNetSqlMembershipProvider"type="System.Web.Security.SqlMembershipProvider"connectionStringName="ApplicationServices"...
    etc.
    Thanks for your time and patience on this Deployment 101 type issue.
    Kurt

    hi,
    You receive either of these error messages specifically when you use integrated security.
    To resolve you can use one of below.
    Method 1: Programmatically change the security context of the ASP.NET worker process to a user who has the correct SQL Server permissions.
    Method 2: Change the default configuration of ASP.NET so that the ASP.NET worker process starts and runs under the context of a user who has the correct permissions in SQL Server.
    Method 3: Grant the correct permissions in SQL Server so that the ASPNET account (or NetworkService account, for an application that runs on IIS 6.0) has the appropriate access to the required resources.(Go to the Computer Management >> Local User and
    Groups >> Groups >> Right Click and go to properties on IIS_IUSRS >> Add appropriate user.
    Thanx, Mark as answered if you are ok ..

  • Unhandled Exception Error - Login Failed for User

    Hello,
    I am receiving an error when I run my application stating “Unhandled exception has occurred. If you click continue, the application will ignore the error………..Login failed for MyUser.
    When I click the Continue button the application runs and seems to work properly. This application used to run without receiving the error and I did not make any changes. I have another application that is using basically the exact same code and does not
    receive the error. The only difference is the application is querying a different DB but using the exact same connection string. The error only occurs when I run the exe file created from the build. When I run (debug) the application from within the VS 2013
    IDE I do not receive the error.
    Here are the details to the error message:
    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.
    ************** Exception Text **************
    System.Data.OleDb.OleDbException (0x80040E4D): Login failed for user 'jobrunner'.
       at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
       at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
       at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.OleDb.OleDbConnection.Open()
       at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
       at LoanOrig_FDIC_Codes.DataSet1TableAdapters.I_LoansTableAdapter.Fill(I_LoansDataTable dataTable) in u:\Visual Studio Projects\LoanOrig_FDIC_Codes\LoanOrig_FDIC_Codes\LoanOrig_FDIC_Codes\DataSet1.Designer.cs:line 1668
       at LoanOrig_FDIC_Codes.Form1.Form1_Load_1(Object sender, EventArgs e) in u:\Visual Studio Projects\LoanOrig_FDIC_Codes\LoanOrig_FDIC_Codes\LoanOrig_FDIC_Codes\Form1.cs:line 152
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    ************** Loaded Assemblies **************
    mscorlib
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR
        CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
    LoanOrig_FDIC_Codes
        Assembly Version: 1.0.0.0
        Win32 Version: 1.0.0.0
        CodeBase: file:///U:/Visual%20Studio%20Projects/LoanOrig_FDIC_Codes/LoanOrig_FDIC_Codes/LoanOrig_FDIC_Codes/bin/Debug/LoanOrig_FDIC_Codes.exe
    System.Windows.Forms
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    System.Drawing
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    System
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.34238 built by: FX452RTMGDR
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
    System.Configuration
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
    System.Xml
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.34234 built by: FX452RTMGDR
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
    System.Data
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
    System.Data.DataSetExtensions
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Data.DataSetExtensions/v4.0_4.0.0.0__b77a5c561934e089/System.Data.DataSetExtensions.dll
    System.Numerics
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
    System.Transactions
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll
    ************** JIT Debugging **************
    To enable just-in-time (JIT) debugging, the .config file for this
    application or computer (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging
    enabled.
    For example:
    <configuration>
        <system.windows.forms jitDebugging="true" />
    </configuration>
    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the computer
    rather than be handled by this dialog box.
    I'm not sure what the JIT debugger is but to my knowledge my other apps are not using that. The production username and password are correct in the connection string so I'm not clear why I am receiving this error especially since I'm not receiving the
    error on my other application. I have also attached the code just in case it is needed. Any assistance will be greatly appreciated. Thank you.
    Dave
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.Data.SqlClient;
    using ClosedXML.Excel;
    using DocumentFormat.OpenXml;
    using System.IO;
    namespace LoanOrig_FDIC_Codes
    public partial class Form1 : Form
    SqlCommand sqlCmd;
    SqlDataAdapter sqlDA;
    DataSet sqlDS;
    DataTable sqlDT;
    SqlCommand sqlCmdCnt;
    public Form1()
    InitializeComponent();
    //BEGIN BUTTON LOAD CLICK EVENT
    private void btnLoad_Click(object sender, EventArgs e)
    string sqlCon = "Data Source=FS-12345; Initial Catalog=ExtractGenerator; User ID=MyUser; Password=MyPW";
    //Set the 2 dateTimePickers to today's date
    DateTime @endDate = End_dateTimePicker.Value.Date;
    DateTime @startDate = Start_dateTimePicker.Value.Date;
    //Validate the values of the 2 dateTimePickers
    if (endDate < startDate)
    MessageBox.Show("End Date must be greater than or equal to the Start Date OR Start Date must be less than or equal to the End Date ", "Incorrect Date Selection",MessageBoxButtons.OK,MessageBoxIcon.Error);
    //Reset both dateTimePickers to todays date
    Start_dateTimePicker.Value = DateTime.Today;
    End_dateTimePicker.Value = DateTime.Today;
    return;
    //End of date validation
    string sqlData = @"SELECT AcctNbr,
    CurrAcctStatCD,
    Org,
    MJAcctTypCD,
    MIAcctTypCD,
    NoteOriginalBalance,
    ContractDate,
    FDICCATCD,
    FDICCATDESC,
    PropType,
    PropTypeDesc
    FROM I_Loans
    WHERE CAST(ContractDate AS datetime) BETWEEN @startdate AND @enddate ORDER BY ContractDate";
    SqlConnection connection = new SqlConnection(sqlCon);
    SqlCommand sqlCmd = new SqlCommand(sqlData, connection);
    sqlCmd.Parameters.AddWithValue("@startDate", startDate);
    sqlCmd.Parameters.AddWithValue("@endDate", endDate);
    sqlDS = new DataSet();
    sqlDA = new SqlDataAdapter(sqlCmd); //SqlAdapter acts as a bridge between the DataSet and SQL Server for retrieving the data
    connection.Open();
    sqlDA.SelectCommand = sqlCmd; //SqlAdapter uses the SelectCommand property to get the SQL statement used to retrieve the records from the table
    sqlDA.Fill(sqlDS, "I_Loans"); //SqlAdapter uses the "Fill" method so that the DataSet will match the data in the SQL table
    sqlDT = sqlDS.Tables["I_Loans"];
    //Code section to get record count
    sqlCmdCnt = connection.CreateCommand();
    sqlCmdCnt.CommandText = "SELECT COUNT(AcctNbr) AS myCnt FROM I_Loans WHERE ContractDate BETWEEN @startDate AND @endDate";
    sqlCmdCnt.Parameters.AddWithValue("@startDate", startDate);
    sqlCmdCnt.Parameters.AddWithValue("@endDate", endDate);
    int recCnt = (int)sqlCmdCnt.ExecuteScalar();
    txtRecCnt.Text = recCnt.ToString();
    btnExport.Enabled = true;
    //End of code section for record count
    connection.Close();
    dataGridView1.DataSource = sqlDS.Tables["I_Loans"];
    dataGridView1.ReadOnly = true;
    //Reset both dateTimePickers to todays date
    Start_dateTimePicker.Value = DateTime.Today;
    End_dateTimePicker.Value = DateTime.Today;
    //END BUTTON LOAD CLICK EVENT
    //BEGIN BUTTON EXPORT CLICK EVENT
    private void btnExport_Click(object sender, EventArgs e)
    SaveFileDialog saveFD = new SaveFileDialog();
    { //ClosedXML code to export datagrid result set to Excel
    string dirInfo = Path.GetPathRoot(@"\\FS-03250\users\dyoung\LoanOrig_FDIC_Codes");
    if (Directory.Exists(dirInfo))
    var wb = new XLWorkbook();
    var ws = wb.Worksheets.Add(sqlDT);
    ws.Tables.First().ShowAutoFilter = false;
    //SaveFileDialog saveFD = new SaveFileDialog(); //I moved this variable to the top of the btnExport code block so that the variable will be available thru the entire scope of that code block
    saveFD.Title = "Save As";
    saveFD.Filter = "Excel File (*.xlsx)| *.xlsx";
    saveFD.FileName = "LoanOrig_FDIC_Codes_" + DateTime.Now.ToString("yyyy-MM-dd");
    if (saveFD.ShowDialog() == System.Windows.Forms.DialogResult.OK)
    Stream stream = saveFD.OpenFile();
    wb.SaveAs(stream);
    stream.Close();
    else if (saveFD.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
    MessageBox.Show("Save file operation has been canceled", "Save As Canceled", MessageBoxButtons.OK, MessageBoxIcon.Stop);
    return;
    //End of ClosedXML code
    MessageBox.Show("File has been exported to " + saveFD.FileName, "File Exported", MessageBoxButtons.OK, MessageBoxIcon.Information);
    //MessageBox.Show("File has been exported to U:\\LoanOrig_FDIC_Codes", "File Exported", MessageBoxButtons.OK, MessageBoxIcon.Information);
    else
    MessageBox.Show("Drive " + saveFD.FileName + " " + "not found, not accessible, or you may have invalid permissions");
    //MessageBox.Show("Drive " + "U:\\Visual Studio Projects\\LoanOrig_FDIC_Codes" + " " + "not found, not accessible, or you may have invalid permissions");
    return;
    //END THE SAVE AS PROCESS
    //END BUTTON EXPORT CLICK EVENT
    private void Form1_Load(object sender, EventArgs e)
    //Set dates to be today's date when the form is openend
    Start_dateTimePicker.Value = DateTime.Today;
    End_dateTimePicker.Value = DateTime.Today;
    private void Form1_Load_1(object sender, EventArgs e)
    // TODO: This line of code loads data into the 'dataSet1.I_Loans' table. You can move, or remove it, as needed.
    this.i_LoansTableAdapter.Fill(this.dataSet1.I_Loans);
    private void iLoansBindingSource_CurrentChanged(object sender, EventArgs e)
    private void btnExit_Click(object sender, EventArgs e)
    this.Close();
    David Young

    In SQL you have a login which allows access to the server but you must also have permissions to access each database that you will use (including Master). So I would verify that your user also has the necessary permissions on the database itself and
    not just the SQL instance. The error you're getting is from SQL saying that the user doesn't have permissions.  If it works for 1 DB but not the other on the same SQL instance then it is likely a missing permission on the DB itself.
    I should note that you have a hard coded conn string in your code but the error is for a different user.  I'm assuming that you simply posted it there for convenience and that you changed the values to obscure the data.  If you are actually getting
    the info from your config file then verify the connection string is correct. Also be sure to not use Integrated Security since it appears that you are using SQL authentication.

Maybe you are looking for