Exception when accessing mdf file when using IIS and aspnet_wp.exe


T

Tony Johansson

Hello!

The database is a mdf file located in the web site
If I use the built-in development web server in Visual Studio it works just
fine.
If I instead use IIS and the asp engine aspnet_wp.exe I get a exception see
Exception message below.
As you can see in the source below I use SqlDataSource
Can anybode give me a hint how to solve the problem to be able to run
the web site from IIS ?

Here is the code behind file
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{}
}

Here is the source.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<!--Page Header -->
<h3 style="text-align: center">This Page is readOnly and will display
all Digital cameras and camCorders for sale </h3> <br />

<!-- Label DigitalCameras for sale -->
<asp:Label ID="Label5" runat="server" Text="DigitalCameras for sale"
Font-Bold="True" Font-Size="Large" />

<!-- Repeater control 1 -->
<asp:Repeater ID="Repeater1" runat="server"
DataSourceID="SqlDataSource1">
<HeaderTemplate>
<table border="1px" style="border: 1px solid #000000; width: 600px;
background-color: #0000FF;
font-size: medium; font-weight: bold; color: #FFFF00;"
cellspacing="4">
<tr>
<td style="width: 90px">ProductName</td>
<td style="width: 70px">Maker</td>
<td style="width: 35px">Pixel</td>
<td style="width: 50px">Price</td>
<td style="width: 50px">Quantity</td>
<td style="width: 50px">Select</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table border="1px" style="border: 1px solid #000000; width: 600px;
color: #0000FF; background-color: #FFFF00;">
<tr>
<td style="width: 80px">
<asp:Label ID="lblProductName" runat="server" Text='<%#
Eval("ProductName") %>'></asp:Label>
</td>
<td style="width: 70px">
<asp:Label ID="lblMaker" runat="server" Text='<%#
Eval("Maker") %>'></asp:Label>
</td>
<td style="width: 30px">
<asp:Label ID="lblMegaPixel" runat="server" Text='<%#
Eval("MegaPixel") %>'></asp:Label>
</td>
<td style="width: 50px">
<asp:Label ID="lblPrice" runat="server" Text='<%#
Eval("Price") %>'></asp:Label>
</td>
<td style="width: 50px">
<asp:Label ID="lblQuantity" runat="server" Text='<%#
Eval("Quantity") %>'></asp:Label>
</td>
<td style="width: 50px">
<asp:Button ID="btnSelect" runat="server" Width="40"
Text='<%# Eval("ProductID") %>' />
</td>
</tr>
</table>
</ItemTemplate>
<AlternatingItemTemplate>
<table border="1px" style="border: 1px solid #000000; width: 600px;
color: #0000FF; background-color: #00FFFF;">
<tr>
<td style="width: 80px">
<asp:Label ID="lblProductName" runat="server" Text='<%#
Eval("ProductName") %>'></asp:Label>
</td>
<td style="width: 70px">
<asp:Label ID="lblMaker" runat="server" Text='<%#
Eval("Maker") %>'></asp:Label>
</td>
<td style="width: 30px">
<asp:Label ID="lblMegaPixel" runat="server" Text='<%#
Eval("MegaPixel") %>'></asp:Label>
</td>
<td style="width: 50px">
<asp:Label ID="lblPrice" runat="server" Text='<%#
Eval("Price") %>'></asp:Label>
</td>
<td style="width: 50px">
<asp:Label ID="lblQuantity" runat="server" Text='<%#
Eval("Quantity") %>'></asp:Label>
</td>
<td style="width: 50px">
<asp:Button ID="btnSelect" runat="server" Width="40"
Text='<%# Eval("ProductID") %>' />
</td>
</tr>
</table>
</AlternatingItemTemplate>
</asp:Repeater>

<!--Button -->
<asp:Button ID="btnDigitalCameraManagement" runat="server"
Text="Add/Delete/Update"
onclick="btnDigitalCameraManagement_Click" /><br />

<!-- SqlDataSource1 -->
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:CameraConnectionString
%>"

SelectCommand="SELECT [ProductID], [ProductName], [Maker],
[MegaPixel], [Price], [Quantity] FROM [DigitalCamera]">
</asp:SqlDataSource><br /><br />

<!-- Label CamCorders for sale -->
<asp:Label ID="Label1" runat="server" Text="CamCorders for sale"
Font-Bold="True" Font-Size="Large" />

<!-- Repeater control 2 -->
<asp:Repeater ID="Repeater2" runat="server"
DataSourceID="SqlDataSource2">
<HeaderTemplate>
<table border="1px" style="border: 1px solid #000000; width: 500px;
background-color: #0000FF;
font-size: medium; font-weight: bold; color: #FFFF00;"
cellspacing="4">
<tr>
<td style="width: 90px">ProductName</td>
<td style="width: 70px">Maker</td>
<td style="width: 35px">Pixel</td>
<td style="width: 50px">Price</td>
<td style="width: 50px">Quantity</td>
<td style="width: 50px">Select</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table border="1px" style="border: 1px solid #000000; width: 500px;
color: #0000FF; background-color: #FFFF00;">
<tr>
<td style="width: 80px">
<asp:Label ID="lblProductName" runat="server" Text='<%#
Eval("ProductName") %>'></asp:Label>
</td>
<td style="width: 70px">
<asp:Label ID="lblMaker" runat="server" Text='<%#
Eval("Maker") %>'></asp:Label>
</td>
<td style="width: 30px">
<asp:Label ID="lblMegaPixel" runat="server" Text='<%#
Eval("MegaPixel") %>'></asp:Label>
</td>
<td style="width: 50px">
<asp:Label ID="lblPrice" runat="server" Text='<%#
Eval("Price") %>'></asp:Label>
</td>
<td style="width: 50px">
<asp:Label ID="lblQuantity" runat="server" Text='<%#
Eval("Quantity") %>'></asp:Label>
</td>
<td style="width: 50px">
<asp:Button ID="btnSelect" runat="server" Width="40"
Text='<%# Eval("ProductID") %>' />
</td>
</tr>
</table>
</ItemTemplate>
<AlternatingItemTemplate>
<table border="1px" style="border: 1px solid #000000; width: 500px;
color: #0000FF; background-color: #00FFFF;">
<tr>
<td style="width: 80px">
<asp:Label ID="lblProductName" runat="server" Text='<%#
Eval("ProductName") %>'></asp:Label>
</td>
<td style="width: 70px">
<asp:Label ID="lblMaker" runat="server" Text='<%#
Eval("Maker") %>'></asp:Label>
</td>
<td style="width: 30px">
<asp:Label ID="lblMegaPixel" runat="server" Text='<%#
Eval("MegaPixel") %>'></asp:Label>
</td>
<td style="width: 50px">
<asp:Label ID="lblPrice" runat="server" Text='<%#
Eval("Price") %>'></asp:Label>
</td>
<td style="width: 50px">
<asp:Label ID="lblQuantity" runat="server" Text='<%#
Eval("Quantity") %>'></asp:Label>
</td>
<td style="width: 50px">
<asp:Button ID="btnSelect" runat="server" Width="40"
Text='<%# Eval("ProductID") %>' />
</td>
</tr>
</table>
</AlternatingItemTemplate>
</asp:Repeater>

<!--Button -->
<asp:Button ID="btnCamCorderManagement" runat="server"
Text="Add/Delete/Update" onclick="btnCamCorderManagement_Click"
/><br />

<!-- SqlDataSource2 -->
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:CameraConnectionString
%>"

SelectCommand="SELECT [ProductID], [ProductName], [Maker],
[MegaPixel], [Price], [Quantity] FROM [CamCorder]">
</asp:SqlDataSource> <br /><br />


</div>
</form>
</body>
</html>


Exception message
=============
Failed to generate a user instance of SQL Server due to a failure in
starting the process for the user instance. The connection will be closed.

Undantagsinformation: System.Data.SqlClient.SqlException: Failed to generate
a user instance of SQL Server due to a failure in starting the process for
the user instance. The connection will be closed.

Stackspårning:
[SqlException (0x80131904): Failed to generate a user instance of SQL Server
due to a failure in starting the process for the user instance. The
connection will be closed.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection) +4846887
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj) +194
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand
cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet
bulkCopyHandler, TdsParserStateObject stateObj) +2392
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean
enlistOK) +35
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo
serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64
timerExpire, SqlConnection owningObject) +144
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String
host, String newPassword, Boolean redirectedUserInstance, SqlConnection
owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +342
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection
owningObject, SqlConnectionString connectionOptions, String newPassword,
Boolean redirectedUserInstance) +221
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
identity, SqlConnectionString connectionOptions, Object providerInfo, String
newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
+189
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection
owningConnection) +4861315
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection
owningConnection, DbConnectionPool pool, DbConnectionOptions options) +31
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
owningObject) +433
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
owningObject) +66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection
owningObject) +499
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
owningConnection) +65
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) +117
System.Data.SqlClient.SqlConnection.Open() +122
System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection,
ConnectionState& originalState) +31
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +112
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord,
Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior
behavior) +287
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
+92
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments
arguments) +1297
System.Web.UI.WebControls.Repeater.GetData() +35
System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean
useDataSource) +220
System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) +51
System.Web.UI.WebControls.Repeater.DataBind() +75
System.Web.UI.WebControls.Repeater.EnsureDataBound() +55
System.Web.UI.WebControls.Repeater.OnPreRender(EventArgs e) +15
System.Web.UI.Control.PreRenderRecursiveInternal() +80
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
 
Ad

Advertisements

T

Tony Johansson

Yes the connection string is in the web.config and it looks like this.
<connectionStrings>
<add name="CameraConnectionString" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Camera.mdf;Integrated
Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>

I use VS 2008
As I mentioned it works just fine if I use the built-in development
webserver that exist in Visual Studio.
I can even run the Visual Studio and use the IIS but that give the same
error.
I can debug but it nothing to debug because my Page_Load method is empty.

//Tony
 
T

Tony Johansson

I found a solution to my problem in this way. I use IIS 5.1 because I use
Windows XP
1. In IIS manager I selected ASP.NET
2. I selected change configuration
3. I selected the fifth tabs called Tillämpningsprogram in swedish.
4.In local personidentification I set user name to Tony and the associated
password
5 Now it works to use IIS

//Tony
 
T

Tony Johansson

The problem was the access to the database.
I don't use any kind of login to the website
The problem that I mentioned about was to get access to the database.
It seems to me that aspnet_wp.exe don't have access to the mdf database file
that I have in my web site
but when I set my username Tont and the associated password it work fine.

//Tony
 
Ad

Advertisements

T

Tony Johansson

Anyone can now access the web site because I don't use any kind of login to
the web site.

//Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top