locked
Login failed for user '(null)' RRS feed

  • Question

  • User1856559870 posted

    Hi,

    I am using Visual Studio 2008, .NET version 3.5, and SQL Server 2000.

    I have a .aspx page that has a GridView, after following the first two http://www.asp.net/learn/data-videos/ .

    When I run the application in Visual Studio, my GridView displays the data from SQL Server 2000 just fine.

    However, when I put the website on our internal test web server (I initially ran the application on my local machine), I get the following error.


    Login failed for user '(null)'. 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 '(null)'. Reason: Not associated with a trusted SQL Server connection.

    Source Error:

    Line 763:            this.Adapter.SelectCommand = this.CommandCollection[0];
    Line 764: SegDS.SegListDataTable dataTable = new SegDS.SegListDataTable();
    Line 765: this.Adapter.Fill(dataTable);
    Line 766: return dataTable;
    Line 767: }

    Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\redesign\a4cad38e\3276aeaf\App_Code.tae391uw.0.cs    Line: 765


    I do not actually have a login for my application; it is a .NET website I am working on for public viewing. I do see the "Source File" in the error references a .NET 2.0.x folder, but when I started my project, I chose .NET version 3.5.

    My connection string is:
      <add name="segsConnectionString" connectionString="Data Source=(SERVERNAME);Initial Catalog=(TABLENAME);Integrated Security=True;Trusted_Connection=True"
       providerName="System.Data.SqlClient" />


    I've done a lot of googling and searching around the asp.net site, and I haven't found anything that has solved my error.  Any help is greatly appreciated!

    Wednesday, September 23, 2009 3:12 PM

All replies

  • User1992938117 posted

    If you are working in local server then try connection string as..

    <add name="segsConnectionString" connectionString="Data Source=127.0.0.1; Initial Catalog=(TABLENAME);Integrated Security=True;Trusted_Connection=True"
       providerName="System.Data.SqlClient" />

    or

    <add name="segsConnectionString" connectionString="Data Source=127.0.0.1;user id=sa; pwd=""; Initial Catalog=(TABLENAME);Integrated Security=True;Trusted_Connection=True"
       providerName="System.Data.SqlClient" />


    Hope this works.............

    Wednesday, September 23, 2009 3:33 PM
  • User1856559870 posted

    When trying both connection strings, my new error is this each time:

    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)

    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: 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)

    Source Error:

    Line 763:            this.Adapter.SelectCommand = this.CommandCollection[0];
    Line 764: SegDS.SegListDataTable dataTable = new SegDS.SegListDataTable();
    Line 765: this.Adapter.Fill(dataTable);
    Line 766: return dataTable;
    Line 767: }

    Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\redesign\a4cad38e\3276aeaf\App_Code.tae391uw.0.cs    Line: 765

    Wednesday, September 23, 2009 3:37 PM
  • User1992938117 posted

    You can try this to check your connection string with udl connection for database connectivity for this ..

    create a notepad file on desktop -> open it -> save as -> aa.udl (be sure save as type is all files) -> open it (aa.udl) -> goto first tab (provider) -> select Microsoft OLE DB Provider for sqlserver ->now (Connection tab)-> enter your server name and if userid and password and select your database from given list and test connection if it succeed -> press ok close it and open it with notepad you will find a connection string in 2nd line copy it and paste in your connection string you can remove Provider name of this string.

    Hope this work..................

    Wednesday, September 23, 2009 3:51 PM
  • User1856559870 posted

    When I follow those steps, this is the what I see in notepad:

    Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=segs;Data Source=(SERVERNAME)

    I put that in my connectionString in my web.config, but it said, "Keyword not supported: 'provider'." When I delete "Provider=SQLOLEDB.1;" from my connectionString, I end up with my original error, "Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection."

    I'm sorry this hasn't worked yet! I really appreciate the responses.

    Wednesday, September 23, 2009 4:10 PM
  • User1992938117 posted

    Hello,

    try to take help with this article and make a trusted user for sql server 2000 and then modify your connection string according this with help of udl

    http://www.banmanpro.com/support/sql2k.asp

    http://forums.asp.net/t/946809.aspx

    http://geekswithblogs.net/ranganh/archive/2005/05/25/40489.aspx

    http://aspnet101.com/aspnet101/tutorials.aspx?id=23


    Hope these links works for you..................

    Wednesday, September 23, 2009 4:56 PM
  • User-1200535045 posted

    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)

     

     Smile

    the error mentioned is that its application of aspnet sql fails to reach the server, probably the server name or ip are incorrect.

    if you have an express version try to enable tcp-ip ports, another option is that the firewall running and not have the correct exceptions for TCP and UDP ports.
    Wednesday, September 23, 2009 6:22 PM
  • User1856559870 posted

    It's the full SQL Server 2000 (rather than express), and the SQL is not on the same machine as any of the web servers (they are all separate machines).

    So it seems that the SQL Server needs a default user of some sort that the web server can display the GridView data? Can I do that using remote desktop to get to the SQL Server?

    Wednesday, September 23, 2009 6:38 PM
  • User1856559870 posted

    After also posting to other forums, it appears that I need to set the Application Pool identity as a Domain (active directory) user, and then add the domain user to IIS_WPG.

    I need to talk to our network engineer to figure out how to get that done. I have remote desktop access to the SQL Server, but I don't know that this is something I can do.

    Thursday, September 24, 2009 11:47 AM
  • User77042963 posted

     Are you sure your server is SQL Server 2000? (not SQL Server 2005)

    Thursday, September 24, 2009 4:08 PM
  • User1856559870 posted

    Absolutely sure the SQL Server is 2000.

    Thursday, September 24, 2009 4:26 PM
  • User2011918074 posted

    It's the full SQL Server 2000 (rather than express), and the SQL is not on the same machine as any of the web servers (they are all separate machines).

    So it seems that the SQL Server needs a default user of some sort that the web server can display the GridView data? Can I do that using remote desktop to get to the SQL Server?

    After also posting to other forums, it appears that I need to set the Application Pool identity as a Domain (active directory) user, and then add the domain user to IIS_WPG.

    Based on your description, the Web application and SQL Server are on separate machines, and the Web application connects to the SQL Server using Windows Authentication.

    Please refer to the following link, it’s the second part of one link in Rajneesh’s reply.

    You may receive the error "Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection" - Part II
    http://geekswithblogs.net/ranganh/archive/2005/05/25/40503.aspx

    Monday, September 28, 2009 1:57 AM
  • User1856559870 posted

    I am in touch with my network engineer. Hopefully we can get this resolved!

    Tuesday, September 29, 2009 11:52 AM
  • User-1460196090 posted

    I am in touch with my network engineer. Hopefully we can get this resolved!

    When I'm getting similar issue I do use UDL file to compose connection string and test it if it's working.

    So as one of the previous posters said create an udl file like

    test.udl -> open it...

    Then select your server (select Windows or Remote *with user/pass* connection to MS SQL Server 2000) then TEST THE CONNECTION. If it's successfull you will get something as you did get:

    Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=segs;Data Source=(SERVERNAME)

    After that remove the Provider:SQLOLEDB.1; part just get the Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=segs;Data Source=(SERVERNAME) in your web config.

    Also you can create connection string using SqlDataSource object.

    Cheers,
    Hajan


    P.S. Also check the Blog post: http://geekswithblogs.net/ranganh/archive/2005/05/25/40503.aspx which was also suggested by other members :)

    Tuesday, September 29, 2009 12:04 PM
  • User1856559870 posted

    From further reading, it appears the issue is because all the servers are on different machines.  We have two web servers and two SQL servers, and all four are different machines (some in different geographic locations).

    Viewing on my local machine works because the web.config file is set for my Windows login.  But the web servers cannot "see" the SQL servers.  (Sorry for lack of proper language... networks and servers are not my strong points.)

    It appears I need my network engineer to create an application pool?  And then something about giving it domain access, and then something about a that new domain user (application pool) being added to IIS_WPG?  I don't understand what those things are, but I have contacted my network engineer.

    p.s. I think this information is also in the blog link several people have posted.

    Tuesday, September 29, 2009 1:42 PM
  • User-2119480821 posted
    Couple of things creates this issue

    1. Check the port is opened for the DB server from your system.try to ping/telnet the server ip address with port number.
    eg. From ur system cmd prompt, write "telnet serverip portnumber" and enter key. If it shows err you dont have access to DB Server.open the port and try again.

    2. create an account for ASP.NET on server, using this act you will able to access. Above one of links explains this.

    3. Try passing your acct username/pwd in connection string

    Tuesday, September 29, 2009 2:05 PM
  • User1856559870 posted

    Couple of things creates this issue

    1. Check the port is opened for the DB server from your system.try to ping/telnet the server ip address with port number.
    eg. From ur system cmd prompt, write "telnet serverip portnumber" and enter key. If it shows err you dont have access to DB Server.open the port and try again.

    2. create an account for ASP.NET on server, using this act you will able to access. Above one of links explains this.

    3. Try passing your acct username/pwd in connection string

    1. I have remote desktop access to the SQL Server. By checking to see if a port is open, do you mean a port from the web servers to the SQL server?

    2. Yes, this is what I have sent to my network engineer.

    3. Is passing the account username and password in the connection string in the web.config file okay? Is that a security risk?


    Tuesday, September 29, 2009 2:25 PM