Subject: Problems with datagrid (plizzz help)
Posted By: Muzzy Post Date: 9/25/2006 2:22:14 PM
I have on my webform one datagrid element and i'd like to fill it from database... i'm writing needed code, but after compiling the page during runtime i get such error:

Server Error in '/web/data' Application.
--------------------------------------------------------------------------------

Login failed for user 'NETSDK\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.

Does anybody has any idea to help me in solving this problem?

Reply By: dparsons Reply Date: 9/25/2006 2:54:53 PM
It depends on where the error occured in your code; it could be a permission's issue with the database or with your application directory.  Post the stack trace, error message, etc.

--Stole this from a moderator

I will only tell you how to do it, not do it for you.  
Unless, of course, you want to hire me to do work for you.
Reply By: Muzzy Reply Date: 9/26/2006 2:16:55 PM
Source Error:

Line 24:             SqlConnection sqlConnection1 = new SqlConnection("server=(local);database=NorthwindCS;Integrated Security=SSPI");
Line 25:             SqlDataAdapter myCommand = new SqlDataAdapter("select * from Customers",sqlConnection1);
Line 26:             sqlConnection1.Open();
Line 27:             DataSet ds = new DataSet();
Line 28:             myCommand.Fill(ds,"Customers");

Error is on the Line 26... And here is stack trace:

Stack Trace:

[SqlException: Login failed for user 'NETSDK\ASPNET'.]
   System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +484
   System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
   System.Data.SqlClient.SqlConnection.Open() +384
   data.WebForm1.Page_Load(Object sender, EventArgs e) in f:\vs_examples\web\data\webform1.aspx.cs:26
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Page.ProcessRequestMain() +731

I hope somebody will help me...

Reply By: gbianchi Reply Date: 9/26/2006 2:29:59 PM
hi there..

looks like integrated security is no good to access that database...

are you sure you have permission??

HTH

Gonzalo
Reply By: dparsons Reply Date: 9/26/2006 2:32:10 PM
Do this:
In sql create a new user and give them right to the Northwind database
Change your connection string to this:

"user ID=[user];password=[password];data source=(local);persist security info=True;initial catalog=NorthwindCS"

where [user] and [password] are the ones you just created.

BTW, the error you got is related to the user not having permission to access the database.

--Stole this from a moderator

I will only tell you how to do it, not do it for you.  
Unless, of course, you want to hire me to do work for you.
Reply By: Muzzy Reply Date: 9/26/2006 3:11:55 PM
I have created a user and gave a right to NorthwindCS, but I still have a problem...

Server Error in '/web/data' Application.
--------------------------------------------------------------------------------

Login failed for user 'Muzzy'. Reason: Not associated with a trusted SQL Server connection.


Source Error:


Line 24:             SqlConnection sqlConnection1 = new SqlConnection("user ID=Muzzy;password=nizo1988;data source=(local);persist security info=True;initial catalog=NorthwindCS");
Line 25:             SqlDataAdapter myCommand = new SqlDataAdapter("select * from Customers",sqlConnection1);
Line 26:             sqlConnection1.Open();
Line 27:             DataSet ds = new DataSet();
Line 28:             myCommand.Fill(ds,"Customers");
 


Reply By: dparsons Reply Date: 9/26/2006 3:40:31 PM
Do this in enterprise manager:

Expand the tree-control until you can your server
Right click on the server name and "SQL Server Properties (Configure)" window will open
Select the Security tab
For "Authentication", select "SQL Server and Windows"
Click "OK" to close the window and then "Yes" to restart SQL Server

this should clear up your error.

--Stole this from a moderator

I will only tell you how to do it, not do it for you.  
Unless, of course, you want to hire me to do work for you.
Reply By: Muzzy Reply Date: 9/26/2006 3:47:45 PM
THANK YOU A LOT! It helped me!

Reply By: dparsons Reply Date: 9/26/2006 4:29:21 PM
Your very welcome, glad it worked for you.

--Stole this from a moderator

I will only tell you how to do it, not do it for you.  
Unless, of course, you want to hire me to do work for you.

Go to topic 50271

Return to index page 164
Return to index page 163
Return to index page 162
Return to index page 161
Return to index page 160
Return to index page 159
Return to index page 158
Return to index page 157
Return to index page 156
Return to index page 155