Problems with database connections
-
I'm trying to connect to a sql database but it seems whenever i open the connection, an exception will be thrown. The same code for accessing the database worked very well in a windows application, and i have also tried some other types of connections including an oledb connection to an Access database file. None of them succeeded. The exception looks like this:
Server Error in '/interdev' Application.
Login failed for user 'ECHEVIL-LAPTOP\ASPNET'.
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 'ECHEVIL-LAPTOP\ASPNET'.
Source Error:
Line 15: // Create and fill a DataSet. Line 16: DataSet ds = new DataSet(); Line 17: myCommand.Fill(ds); Line 18: // Bind MyDataGrid to the DataSet. MyDataGrid is the ID for the Line 19: // DataGrid control in the HTML section.
Source File: D:\Develop\Servers\interdev\test.aspx Line: 17Stack Trace:
[SqlException: Login failed for user 'ECHEVIL-LAPTOP\ASPNET'.] System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) System.Data.SqlClient.SqlConnection.Open() System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) ASP.Test_aspx.Page_Load(Object Src, EventArgs E) in D:\Dev
-
I'm trying to connect to a sql database but it seems whenever i open the connection, an exception will be thrown. The same code for accessing the database worked very well in a windows application, and i have also tried some other types of connections including an oledb connection to an Access database file. None of them succeeded. The exception looks like this:
Server Error in '/interdev' Application.
Login failed for user 'ECHEVIL-LAPTOP\ASPNET'.
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 'ECHEVIL-LAPTOP\ASPNET'.
Source Error:
Line 15: // Create and fill a DataSet. Line 16: DataSet ds = new DataSet(); Line 17: myCommand.Fill(ds); Line 18: // Bind MyDataGrid to the DataSet. MyDataGrid is the ID for the Line 19: // DataGrid control in the HTML section.
Source File: D:\Develop\Servers\interdev\test.aspx Line: 17Stack Trace:
[SqlException: Login failed for user 'ECHEVIL-LAPTOP\ASPNET'.] System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) System.Data.SqlClient.SqlConnection.Open() System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) ASP.Test_aspx.Page_Load(Object Src, EventArgs E) in D:\Dev
Try adding the 'ECHEVIL-LAPTOP\ASPNET' user account to your database. In Enterprise Manager, open your Sql Server Groups --> open the security folder --> right-click Logins --> New Login --> Browse to your 'ECHEVIL-LAPTOP\ASPNET' and select it. Then on the Database Access tab, select your database which you want to access and check the public and db_datareader roles. HTH, Thea
-
I'm trying to connect to a sql database but it seems whenever i open the connection, an exception will be thrown. The same code for accessing the database worked very well in a windows application, and i have also tried some other types of connections including an oledb connection to an Access database file. None of them succeeded. The exception looks like this:
Server Error in '/interdev' Application.
Login failed for user 'ECHEVIL-LAPTOP\ASPNET'.
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 'ECHEVIL-LAPTOP\ASPNET'.
Source Error:
Line 15: // Create and fill a DataSet. Line 16: DataSet ds = new DataSet(); Line 17: myCommand.Fill(ds); Line 18: // Bind MyDataGrid to the DataSet. MyDataGrid is the ID for the Line 19: // DataGrid control in the HTML section.
Source File: D:\Develop\Servers\interdev\test.aspx Line: 17Stack Trace:
[SqlException: Login failed for user 'ECHEVIL-LAPTOP\ASPNET'.] System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) System.Data.SqlClient.SqlConnection.Open() System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) ASP.Test_aspx.Page_Load(Object Src, EventArgs E) in D:\Dev
Your problem has to do with authentication and permissions for access to your SQL server instance. Try the sa account without the password in you connection string by the way did you use wizards in creating your adapter or did you type in the connection string yourself?? zimcoder What Democracy?? Jesus Christ is King and if you do not like... well you can go to hell!
-
Your problem has to do with authentication and permissions for access to your SQL server instance. Try the sa account without the password in you connection string by the way did you use wizards in creating your adapter or did you type in the connection string yourself?? zimcoder What Democracy?? Jesus Christ is King and if you do not like... well you can go to hell!
I tried the wizard and i also wrote some connection strings myself. by the way i'm using MS Deskop Engine as the data source, and i only want to make it work on my machine. would it be quite different from a full version SQL server? 'cause the sa account does not work even in a windows application.