Monday, March 12, 2012

login error

when i display the contents of a MS Access database, it displays fine. but when i use SQL/MSDE database, the contents can by displayed well when i run the aspx locally using webmatrix's local server. but when i access the same aspx file online, i get the following error message:

************* ERROR MESSAGE *************
Server Error in '/' Application.
------------------------

Login failed for user 'PC-MARVINE\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 'PC-MARVINE\ASPNET'.

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.
************* ERROR MESSAGE *************

the following is the code:


<%@. Page Language="VB" %>
<%@. Register TagPrefix="wmx" Namespace="Microsoft.Matrix.Framework.Web.UI" Assembly="Microsoft.Matrix.Framework, Version=0.6.0.0, Culture=neutral, PublicKeyToken=6f763c9966660626" %>
<script runat="server"
' Insert page code here
'

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
<wmx:SqlDataSourceControl id="SqlDataSourceControl1" runat="server" SelectCommand="SELECT * FROM [Employees]" ConnectionString="server='(local)'; trusted_connection=true; database='Northwind'" UpdateCommand="" DeleteCommand=""></wmx:SqlDataSourceControl>
<wmx:MxDataGrid id="MxDataGrid2" runat="server" DataSourceControlID="SqlDataSourceControl1" BorderColor="#CCCCCC" AllowSorting="True" DataMember="Employees" AllowPaging="True" BackColor="White" CellPadding="3" DataKeyField="EmployeeID" BorderWidth="1px" BorderStyle="None">
<PagerStyle horizontalalign="Center" forecolor="#000066" backcolor="White" mode="NumericPages"></PagerStyle>
<FooterStyle forecolor="#000066" backcolor="White"></FooterStyle>
<SelectedItemStyle font-bold="True" forecolor="White" backcolor="#669999"></SelectedItemStyle>
<ItemStyle forecolor="#000066"></ItemStyle>
<HeaderStyle font-bold="True" forecolor="White" backcolor="#006699"></HeaderStyle>
</wmx:MxDataGrid>
</p>
<!-- Insert content here -->
</form>
</body>
</html

do i need to insert some code to do this properly? obviously running the aspx file to display the SQL/MSDE database contents locally works perfectly. i have a webserver setup at home. but when another computer tries to access that file online, i get the error message shown above.

regards,
marvineMy instinct say that the user id under which ASP.NET is running (PC-MARVINE\ASPNET) doesn't have access rights to the SQL Server database. There are a couple of solutions to this problem, the correct one depending on the type of environment you're running and the level of security (read that as risk) that you'd like to have. One of the simplest solutions is to give the ASPNET user access to the SQL Server database. Another is to change the user under which ASP.NET is running to someone that has access to the database. A third is to turn impersonation on for the web site, which means that the person accessing the page will need to have access to the database. There are other options, but I'm sure you get the point.

HTH

No comments:

Post a Comment