ace333 Posted August 26, 2005 Posted August 26, 2005 Getting the follow error from the following code...been trying to fix it for days 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 Quote
mike55 Posted August 26, 2005 Posted August 26, 2005 The usual cause of your problem is that users have the authentication set to Windows only. Try the following: Open SQL Server Enterprise manager. Expand the Console Root Expand the Microsoft SQL Servers Expand the SQL ServerGroup Right click on (Local)(Windows NT) Select Properties Select the Security Tab Set Authentication mod to SQL Server and Windows Click Ok Mike55 Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
JTDPublix Posted August 29, 2005 Posted August 29, 2005 The usual cause of your problem is that users have the authentication set to Windows only. Try the following: Open SQL Server Enterprise manager. Expand the Console Root Expand the Microsoft SQL Servers Expand the SQL ServerGroup Right click on (Local)(Windows NT) Select Properties Select the Security Tab Set Authentication mod to SQL Server and Windows Click Ok Mike55 You can use Impersonation to get around this as well. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.