Hello colleagues, Could someone take a look at this error message and my cs file to open connection and suggest what the problem might be. I have not been able to figure this out. error message: Server Error in '/jan' Application. ________________________________________ Login failed for user 'ga'. 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 'ga'. Source Error: Line 17: protected void Button1_Click(object sender, EventArgs e) Line 18: { Line 19: con.Open(); Line 20: SqlCommand cmd= new SqlCommand("insert into CComments values('"+TextBox1.Text+ "', '"+TextBox2.Text+ "','"+TextBox3.Text+ "', '"+TextBox4.Text+ "', '"+TextBox5.Text+ Line 21: "','"+ DropDownList1.Text + "' '"+TextBox6.Text+ "')",con); Source File: f:\websites\jan\Feedback.aspx.cs Line: 19 Stack Trace: [SqlException (0x80131904): Login failed for user 'ga'.] System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5103182 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +260 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2294 System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +35 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject, Boolean withFailover) +250 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +932 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +195 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +316 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) +33 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +524 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +479 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +108 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126 System.Data.SqlClient.SqlConnection.Open() +125 Feedback.Button1_Click(Object sender, EventArgs e) in f:\websites\jan\Feedback.aspx.cs:19 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112 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) +5563 ________________________________________ Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.276 Then here's my open connection cs file: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; public partial class Feedback : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } SqlConnection con = new SqlConnection("Data Source=OTEGA\\SQLEXPRESS;Initial Catalog=miracle;User ID=ga;Password=***********"); SqlCommand cmd; protected void Button1_Click(object sender, EventArgs e) { con.Open(); SqlCommand cmd= new SqlCommand("insert into CComments values('"+TextBox1.Text+ "', '"+TextBox2.Text+ "','"+TextBox3.Text+ "', '"+TextBox4.Text+ "', '"+TextBox5.Text+ "','"+ DropDownList1.Text + "' '"+TextBox6.Text+ "')",con); cmd.ExecuteNonQuery(); } } Can someone understand why the error message is highlighting 'con.open()' ? Many thanks in advance.
The above, is the connection string to your local sql express database. You need to replace this connection string with the connection string to your Winhost database. To obtain the connection string to your Winhost database: * Login to your Winhost Control Panel at https://cp.Winhost.com * In the navigation menu under Winhost logo click on "Sites" tab * In "Your Sites" section click "Manage" link next to a site you'd like to manage * In the "Site Tools" section click on "MS SQL Manager" button * Click on "Manage" link next to the database you'd like to obtain the connection string for The connection string will be displayed at the button
opening my database connection contd I am sorry I wasn't explicit enough in my post. I did not mention the fact that the above error occurred in my local computer. I need to solve this one first before proceeding to the point you are showing me. Kindly direct your attention to my local computer where I am using visual studios and sql express for now and sort me out here then I would be ready to deploy my forms pages to Winhost servers. I really need to get my forms and login pages right for uploading to my site on your servers. Many thanks in advance.
This is what you should be focused on: Make sure the user exists in your SQL Server Express instance and that the user is mapped to one of your database logins.