Saturday, February 25, 2012

"Login failed for user" error

hi ppl,
I'm having trouble connecting to my database using ASP.NET
I have been getting the error below whenever i try open the connection using connection.open using vb.net

I have this error in when using plain text editor as and even using
the visual studio.nets data tools (sqlconnection,sqldataadapter tool.)
The strange thing is that i can easily preview the data in any table in northwind db using the connections i've created in the solution explorer using visual studio.net.

This is the connection string created by visual studio.net (i also tried to use this connectionstring manually in code)
"initial catalog=Northwind;integrated security=SSPI;persist security info=False;workstation id=COMPI;packet size=4096"

Here is the error (same error for plain text and vs.net):

Login failed for user 'COMPI\ASPNET'
...
Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'COMPI\ASPNET'.
...
[SqlException: Login failed for user 'COMPI\ASPNET'.]
System.Data.SqlClient.ConnectionPool.GetConnection (Boolean& isInTransaction)
System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString options, Boolean& isInTransaction)
System.Data.SqlClient.SqlConnection.Open()
BegCh12.WebForm1.Page_Load(Object sender, EventArgs e) in C:\BegASPNet\BegCh12\WebForm1.aspx.vb:153
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()...

can someone help pls
Im using sql server 7 sp3, windows xp pro.I may have miss read this so let me restate your problem.

You have an application thaat can view and access data in the NorthWind DB but not the DB your app is written for. If that is true then it sounds like your userid "ASPNET" needs to be granted access to the db in question as well as execute or Select/Delete/Update permissions of all needed objects.|||How do i do what ur saying, is it from SQL server or using Windows XP.
I have just installed sql server and havent done any changes to permission or account (not sure how)?|||Use Enterprise Manager

Open your server, expand Security and then click on Users. right click on your UserID and select properties. Under the Database Access tab click on the Permit check box next to your database. Under the Permit in Database Role, you will want to select public, and probably db_datareader/datawrite OR you can open things up a bit and select db_owner, but I wouldn't use it for very long.

Books Online covers this very well.

No comments:

Post a Comment