By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,213 Members | 1,105 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,213 IT Pros & Developers. It's quick & easy.

Problem connecting to SQLServer Express from ASP.NET

P: 32
Hello All,

I have an application using ASP.NET. The database is SQLServer Express 2005. There is a table called ApartmentInfo in the database. All i am trying to do, is to "select * from ApartmentInfo" into a repeater control on an asp.net page.
This is the connection code i am using -

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dbconn, sql, dbcomm, dbread
dbconn = New System.Data.SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;database=ApartmentBooking;Trus ted_Connection=yes")
dbconn.Open()
sql = "SELECT * FROM ApartmentInfo"
dbcomm = New System.Data.SqlClient.SqlCommand(sql, dbconn)
dbread = dbcomm.ExecuteReader()
aptlist.DataSource = dbread
aptlist.DataBind()
dbread.Close()
dbconn.Close()
End Sub

When I click on the "View in Browser" option. I get the following error, I have pasted it below : here RNIYER is my computer name. I dont know how the ASPNET word is getting added to the user.

Thanks and Regards
Nanda

Server Error in '/aptbkg' Application.
--------------------------------------------------------------------------------

ERROR [28000] [Microsoft][SQL Native Client][SQL Server]Login failed for user 'RNIYER\ASPNET'. ERROR [42000] [Microsoft][SQL Native Client][SQL Server]Cannot open database "ApartmentBooking" requested by the login. The login failed. ERROR [28000] [Microsoft][SQL Native Client][SQL Server]Login failed for user 'RNIYER\ASPNET'. ERROR [42000] [Microsoft][SQL Native Client][SQL Server]Cannot open database "ApartmentBooking" requested by the login. The login failed.
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.Odbc.OdbcException: ERROR [28000] [Microsoft][SQL Native Client][SQL Server]Login failed for user 'RNIYER\ASPNET'. ERROR [42000] [Microsoft][SQL Native Client][SQL Server]Cannot open database "ApartmentBooking" requested by the login. The login failed. ERROR [28000] [Microsoft][SQL Native Client][SQL Server]Login failed for user 'RNIYER\ASPNET'. ERROR [42000] [Microsoft][SQL Native Client][SQL Server]Cannot open database "ApartmentBooking" requested by the login. The login failed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[OdbcException: ERROR [28000] [Microsoft][SQL Native Client][SQL Server]Login failed for user 'RNIYER\ASPNET'.
ERROR [42000] [Microsoft][SQL Native Client][SQL Server]Cannot open database "ApartmentBooking" requested by the login. The login failed.
ERROR [28000] [Microsoft][SQL Native Client][SQL Server]Login failed for user 'RNIYER\ASPNET'.
ERROR [42000] [Microsoft][SQL Native Client][SQL Server]Cannot open database "ApartmentBooking" requested by the login. The login failed.]
AptBkg.ApartmentInfo_maint.ApartmentInfoDataProvid er.FillItem(ApartmentInfoItem item, Boolean& IsInsertMode) +3259
AptBkg.ApartmentInfo_maint.ApartmentInfo_maintPage .ApartmentInfoShow() +195
AptBkg.ApartmentInfo_maint.ApartmentInfo_maintPage .OnLoad(EventArgs e) +69
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2407; ASP.NET Version:1.1.4322.2407
Sep 17 '07 #1
Share this Question
Share on Google+
2 Replies


Plater
Expert 5K+
P: 7,872
So follow what the error message says.
Create a login entry in your SQL server for the ASPNET user and you should have less trouble.


They put those descriptions in errors for a reason you know....
Sep 17 '07 #2

P: 32
hi,

thx for ur help. it worked. i had not set the correct permissions for the new login

regards
Nanda
Sep 17 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.