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

This code is giving me this error

using System;

using System.Configuration;

using System.Data;

using System.Data.SqlClient;

using System.Text;

 

 

namespace WebApplication1

{

/// <summary>

/// Summary description for WebForm1.

/// </summary>

public class WebForm1 : System.Web.UI.Page

{

private void Page_Load(object sender, System.EventArgs e)

{

SqlConnection con;

string sql;

SqlDataAdapter adExisting;

//con = new SqlConnection("Data Source=slon12d11012";User ID=nnichol1;);

//con = new SqlConnection("Initial Catalog=DACari;Data Source=slon12d11012;User ID=nnichol1;Password=xxxxx");

//con = new SqlConnection("Data Source=slon12d11012;Initial Catalog=DACari;Integrated Security=SSPI;");

//con = new SqlConnection("Server=slon12d11012;Database=DACari;Trusted_Connection=yes;");

con = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DACari;Data Source=slon12d11012;Packet Size=4096;Workstation ID=WLON110355965;");

sql = "select 'RCRF' as DacType, R.Id, R.AmendmentInstructions as Comments, 'Comment' as TypeOfComment, D.ExternalID as RiskId,D.AmendedByUserId as UserId, D.AmendedDateTime";

sql+="from dbo.ITRR_RCRFDetailComments R, RCRFDetail D";

sql+="where R.Id *= D.Id";

sql+="and R.AmendmentInstructions *=D.AmendmentInstructions";

sql+="union";

sql+="select 'RCRF' as DacType, R.Id, R.ApproverComments as Comments,'RejectedComment' as TypeOfComment,D.ExternalID as RiskId, D.AmendedByUserId as UserId, D.AmendedDateTime";

sql+="from ITRR_RCRFApproverComments R, RCRFDetail D";

sql+="where R.Id *= D.Id";

sql+="and R.ApproverComments *=D.ApproverComments";

sql+="union";

sql+="select 'DAC' as DacType, R.Id, R.Comments, 'Comment' as TypeOfComment,D.RiskId, D.AmendedByUserId as UserId, D.AmendedDateTime from ITRR_DacDetailComments R, DacDetail D";

sql+="where R.Id *= D.Id";

sql+="and R.Comments *=D.Comments";

sql+="union";

sql+="select 'DAC' as DacType, R.Id, R.RejectedComments as Comments,'RejectedComment' as TypeOfComment,D.RiskId, D.AmendedByUserId as UserId, D.AmendedDateTime";

sql+="from ITRR_DacDetailRejectedComments R, DacDetail D";

sql+="where R.Id *= D.Id";

sql+="and R.RejectedComments *=D.RejectedComments";

sql+="union";

sql+="select 'CAP' as DacType, R.CapId, R.Comments, 'Comment' as TypeOfComment, D.CurrentRiskId,D.AmendedByUserId as UserId, D.AmendedDateTime from dbo.ITRR_CAPDetailComments R, CapDetail D";

sql+="where R.CapId *= D.CapId";

sql+="and R.Comments *=D.Comments";

sql+="union";

sql+="select 'CAP' as DacType, R.CapId, R.RejectedComments as Comments,'RejectedComment' as TypeOfComment,D.CurrentRiskId, D.AmendedByUserId as UserId, D.AmendedDateTime";

sql+="from ITRR_CapDetailRejectedComments R, CapDetail D";

sql+="where R.CapId *= D.CapId";

sql+="and R.RejectedComments *=D.RejectedComments";

sql+="union";

sql+="select 'MODAC' as DacType, R.Id, R.MiddleOfficeComments as Comments, 'MiddleOfficeComment' as TypeOfComment, D.RiskId,D.AmendedByUserId as UserId, D.AmendedDateTime";

sql+="from ITRR_MODacDetailComments R, MODacDetail D";

sql+="where R.Id *= D.Id";

sql+="and R.MiddleOfficeComments *=D.MiddleOfficeComments";

sql+="union";

sql+="select 'MODAC' as DacType, R.Id, R.RequestorComments as Comments,'RequestorComment' as TypeOfComment,D.RiskId, D.AmendedByUserId as UserId, D.AmendedDateTime";

sql+="from ITRR_RequestorComments R, MODacDetail D";

sql+="where R.Id *= D.Id";

sql+="and R.RequestorComments *= D.RequestorComments";

adExisting = new SqlDataAdapter(sql,con);

con.Open();

DataSet ds = new DataSet();

try

{

adExisting.Fill(ds,"Existing");

}

catch

{

throw;

}

finally

{

con.Close();

}

/**

System.Data.SqlClient.SqlConnection conn =

new System.Data.SqlClient.SqlConnection ();

// TODO: Modify the connection string and include any

// additional required properties for your database.

conn.ConnectionString =

"integrated security=SSPI;data source=slon12d11012;" +

"persist security info=False;initial catalog=DACari";

try

{

conn.Open();

// Insert code to process data.

}

catch (Exception ex)

{

Response.Write("Failed to connect to data source"+ex.ToString());

}

finally

{

conn.Close();

}

**/

}

#region Web Form Designer generated code

override protected void OnInit(EventArgs e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeComponent();

base.OnInit(e);

}

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

}

}

 

Server Error in '/WebApplication1' Application.

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 75: 
Line 76: 			adExisting = new SqlCommand(sql,con);
Line 77: 			con.Open();
Line 78: 			DataSet ds = new DataSet();
Line 79: 			try

Source File: c:\inetpub\wwwroot\webapplication1\webform1.aspx.cs    Line: 77

Stack Trace:

[SqlException: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.]
   System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +474
   System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
   System.Data.SqlClient.SqlConnection.Open() +384
   WebApplication1.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\webapplication1\webform1.aspx.cs:77
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Page.ProcessRequestMain() +731


Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573

0
ace333
8/26/2005 12:55:07 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

1 Replies
927 Views

Similar Articles

[PageSpeed] 1

Not sure if you've heard of it before, but there's this site called "Google." You type stuff in and it brings up web pages that are relavent to your query. When you type in the title of the post, you get countless replies. what's nice about that is you don't have to waste everyone's time with such a common problem.

http://www.google.com/search?q=Login+failed+for+user+%27%28null%29%27%2E+Reason%3A+Not+associated+with+a+trusted+SQL+Server+connection

 

0
Alex
8/26/2005 1:38:29 PM
Reply:

Similar Artilces:

[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
Hello All, I'm Getting the following error when calling a dll from my vb.net application. [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection. The dll was written in vb6 and accesses a sql db using the following connection string. Public Const GLOBAL_DNS As String = "DSN=TransSrvFinal;UID=sa;PWD=admin;" This DLL works fine when called from other Windows Apps. However I'm now trying to call this dll from with in an asp.net application. I'm using vb.net as the codebehind. I'm a...

2008 IIS7 connection to SQL Server 2000 on Web Server 2000: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
I am setting up a windows 2008 IIS7 web server, and trying to connect to a windows 2000 sql server 2000 database. I have an IIS6 Windows 2000 web server activately connected just fine. I have anonymous and windows authentication enabled. And in my web.config I have identity impersonate="true" My sql server 2000 typically uses the IISUSER anonymous user set up in IIS6 on my original windows 2000 web server. But this new IIS7 is giving me grief. I can't seem to setup the IUSR or IISUSER or anything in it. I can't even use sql server credentials in my connection string altho...

Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection
I dont believe that no one can help me in this damn error,Please, I'm gonne lose my job offer If I didnt fix this. I have spent 7 days searching with no use !! I use ASP.NET 2.0 with C# to develop an intranet site, it was working perfectly when i was on Visual Studio, when i tried to publish the site it gave me that error. Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection. the web application on IIS server, windows 2003 - the database on a different server windows 2003, sql server 2000. Regaeding that we have proxy server, one fi...

Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection
Dear All,I am trying to establish a connection to my SQL Server which is on the Remote machine. My ASP.Net application is on the local machine. Below is my connection string: <appSettings><add key="NorthConn" value="server=ABC;integrated security=sspi;database=Northwind"/></appSettings>The North wind Database has the following user accounts:1) ABC\ASPNET2)ABC\IUSR_ABCboth of these accounts have permissions granted to them.My SQL Server has both Windows and SQL Server authentication checked. I checked the properties of my  web project in IIS  and it has both Anony...

Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection
Hi i installed msde with follwoing attributes for a project DotnetNUke..C:\sql2ksp3\MSDE\>Setup.exe SAPWD="password "INSTANCENAME="DNNV3" SECURITYMODE=SQLin my web.config file here is what i am using==><appSettings>    <add key="SiteSqlServer" value="Server=(local);Database=DNNV3;uid=;pwd=password;" />   but i am getting below error...can anyone PLEASE help me on this.thanks a lotInstalling DotNetNukeUpgrade Error: ERROR: Could not connect to database specified in connectionString for SqlDataProvider   ---------------------------------------------...

Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection #3
Hi I have am developing on xp machine with iis 5.1 and trying to connect to a seperate windows 2003 machine with mssql 2000 installed.I would like to use a trusted connection and I added an asp account on the sql server with permissions to the database and also edited the security tab on IIS to have this account. I unchecked allow IIS to control this password.  When I look in the event viewer on my local machine I get an error:Process information:     Process ID: 2388     Process name: aspnet_wp.exe     Account name: MACHINENAME\ASPNET &...

Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection. #2
Basic setup IIS 6 with ASP.Net 2.0, Integrated Windows Authentication turned on (anonymous turned off) SQL Server 2000 with Windows Only Authentication on (SQL Server authentication turned off) web.config file contains the following relevant entries:<identity impersonate="true" /><authentication mode=Windows" /> connection string:Data Source=[server name]; Integrated Security=SSPI; Initial Catalog=[database name]; When I run my query on my development server, it runs perfectly. When I run it on the production server (which is just an exact xcopy of the development web site...

Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection #2
I realize people have had this problem before. Probably on this very board. But I am up against a wall and none of the solutions I have found online work at all. I have a asp.net 1.x application that sits on an IIS server and talks to an SQL 2000 database on a separate server. It was working fine until about a week ago when all of the sudden I started recieving the following error: "Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection" In IIS manager the application is set up in a virtual directory, denies anonymous users, and uses only Integrat...

Web resources about - Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection. - asp.net.sql-datasource

Trump urged to apologise to Muslim woman ejected from rally
Ohio Govern­or John Kasich, said the crowd's respon­se at Trump's rally in Rock Hill, South Caroli­na was inappr­opriat­e

No one won Powerball, jackpot now $1.3 billion
So you didn't pick 16, 19, 32, 34, 57 and the Powerball 13? You're in luck: No one else did, either. Those were the winning numbers in Saturday ...

NFL Playoff Schedule: Pittsburgh Steelers Vs. Denver Broncos; Kansas City Chiefs Vs. New England Patriots ...
NFL playoff schedule updates have come following the AFC wild card games. The 2016 NFL playoff schedule now includes the Pittsburgh Steelers ...

US B-52 bomber flies over S. Korea in solidarity after N. Korean nuclear claim
CNN US B-52 bomber flies over S. Korea in solidarity after N. Korean nuclear claim CNN Pyongyang, North Korea (CNN) Days after North Korea ...

Germany: Authorities Must Probe Cologne Assault Links
Hindustan Times Germany: Authorities Must Probe Cologne Assault Links New York Times BERLIN — Germany's justice minister says authorities ...

Police Say 5 Men Raped Woman Inside New York City Park
Police say 5 men raped woman inside New York City park while she walked with her father

In Oregon standoff, local sheriff embraces the spectacle
Los Angeles Times In Oregon standoff, local sheriff embraces the spectacle Los Angeles Times When Harney County Sheriff David Ward met with ...

Surprise: Obama actually does get things from State of the Union
Sacramento Bee Surprise: Obama actually does get things from State of the Union Sacramento Bee As he prepares for his final State of the Union ...

Bernie Sanders Would ‘Destroy’ Trump — The Socialist Senator Has Right-Wing Appeal
Bernie Sanders ‘destroys’ Donald Trump by a whopping 13 points in a new poll, as reported by The Huffington Post. This places the socialist ...

Bengals lose discipline, poise late in chippy wild-card loss to Steelers
ESPN Bengals lose discipline, poise late in chippy wild-card loss to Steelers ESPN CINCINNATI A quote from Cincinnati Bengals founder and ...

Resources last updated: 1/10/2016 2:41:44 PM