I wrote a web application and tested it on the development pc and everything is working well. Then I created a Virtual Directory on my Test pc and transfered the developed site using the copy project in Visual Studio 2005. In my test pc I have .Net Framework 2.0 with SQL Express installed.
When I tried to run the site I get the following error message.
Cannot open database "C:\Inetpub\wwwroot\Reports\App_Data\aspnetdb.mdf" requested by the login. The login failed.
Login failed for user 'W2678\ASPNET'
I checked permissions and everything is ok. I strongly believe this error happens because I do not have access writes to the database. But when I open the SQL Server Management Studio, I cannot see my database there. I am totally new with this SQL server express edition that comes with Visual Studio 2005. I do not know how to add the ASPNET account to the database , because my application attaches the file at run time.
Could some one tell me how to do this? Any help is greaty appriciated.
To grant Asp.net permissions in your database, you create the server permissions in the security section under management in Management Studio and you create the database permissions in the new security section in the database section of Management Studio. You may need the Advanced Express which comes with Management Studio. Post again if you still have question. Hope this helps.
http://msdn.microsoft.com/vstudio/express/sql/download/
You need to download the BOL(books online) and read up on permssions and check the thread below for the correct permissions because if you don't you cannot run your application. Hope this helps.
http://www.microsoft.com/downloads/details.aspx?FamilyID=BE6A2C5D-00DF-4220-B133-29C1E0B6585F&displaylang=en
http://msdn2.microsoft.com/en-us/library/ms189612.aspx
http://forums.asp.net/thread/1492092.aspx
Thanks for your response. This may not be a good question. In my web.config file I am attaching the database at run time. So my problem is when I open the SQL Management Studio in my Test or Development PC, I don't see my application database. Because of this I really cannot include the the account name in database login. My web.config file contents are
<?
xmlversion="1.0"?><!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<
configurationxmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"><
appSettings><
addkey="CrystalImageCleaner-AutoStart"value="true" /><
addkey="CrystalImageCleaner-Sleep"value="60000" /><
addkey="CrystalImageCleaner-Age"value="120000" /></
appSettings><
connectionStrings><
addname="ASPNETDBConnectionString"connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True"providerName="System.Data.SqlClient" /></
connectionStrings><
system.web><!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
Visual Basic options:
Set strict="true" to disallow all data type conversions
where data loss can occur.
Set explicit="true" to force declaration of all variables.
--><
roleManagerenabled="true" /><
compilationdebug="true"strict="false"explicit="true"><assemblies><addassembly="CrystalDecisions.CrystalReports.Engine, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/><addassembly="CrystalDecisions.ReportSource, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/><addassembly="CrystalDecisions.Shared, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/><addassembly="CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/><addassembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/><addassembly="CrystalDecisions.Enterprise.Framework, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/><addassembly="CrystalDecisions.Enterprise.InfoStore, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/></assemblies></compilation><
pages><
namespaces><
clear/><
addnamespace="System"/><
addnamespace="System.Collections"/><
addnamespace="System.Collections.Specialized"/><
addnamespace="System.Configuration"/><
addnamespace="System.Text"/><
addnamespace="System.Text.RegularExpressions"/><
addnamespace="System.Web"/><
addnamespace="System.Web.Caching"/><
addnamespace="System.Web.SessionState"/><
addnamespace="System.Web.Security"/><
addnamespace="System.Web.Profile"/><
addnamespace="System.Web.UI"/><
addnamespace="System.Web.UI.WebControls"/><
addnamespace="System.Web.UI.WebControls.WebParts"/><
addnamespace="System.Web.UI.HtmlControls"/></
namespaces></
pages><!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
--><
authenticationmode="Forms" /><!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
--><
httpHandlers><addverb="GET"path="CrystalImageHandler.aspx"type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/></httpHandlers></system.web><
system.net><
mailSettings><
smtpfrom="coolvaas@.yahoo.com"><
networkhost="10.5.10.22"password=""userName="" /></
smtp></
mailSettings></
system.net></
configuration>As you can see I use AttachDbFilename in the connectionstring. So I don't know how to set the database with the required user name.
Please help. I am going to browse the links that you sent me. Thanks a lot.
|||(In my web.config file I am attaching the database at run time.)
That is what you do with Access not SQL Server so you have to choose if you want to use SQL Server, if yes take the time to read up and create the permissions you need or your application will not run. Hope this helps.
No comments:
Post a Comment