Showing posts with label app_data. Show all posts
Showing posts with label app_data. Show all posts

Tuesday, March 20, 2012

Cannot open database C:\Inetpub\wwwroot\Reports\App_Data\aspnetdb.mdf

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/

|||I did install the Advance express but no luck so far. Just to let you know that I used the SQL version that comes with VS 2005 to create the database. I am not sure how to deploy these applications. Are there any tutorials for these type of application (Using VS2005 SQL edition)?|||

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.

Monday, March 19, 2012

Cannot Open / Create SQL Express Databases (.mdf files) in Visual Studio 2005 Professional

Hi, I am trying to open or create a sqlexpress database within Visual Studio 2005 Professional in the App_Data folder. If I attempt either method, I get the following dialog box:

Required Components Missing

Connections to SQL Server files (*.mdf) require SQL Server Express 2005 to function properly. Please verify the installation of the component or download from the URL: http://go.microsoft.com/fwlink/?LinkID=49251

The link above just takes you to the download page for Sql Server Express 2005.

I have both SQL Server 2005 Developer and SQL Server 2005 Expression instances running. The existing database will work properly in my web application, however I cannot access it through Visual Studio.

As background, I did have a problem connecting to the database via the web application, receiving a "Failed to generate a User Instance of SQL Server" error. But I was able to fix that by renaming my SQLEXPRESS folder in C:\Documents and Settings\user\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data. When the web page ran, it created another SQLEXPRESS folder.

However, I cannot figure out why I am having the other issue.

Thanks in advance

Patrick


Hi,

This error means that you are not pointing to the correct instance.

Right click the mdf database > Modify Connection > Advanced > Data Source string.

Check this string and see if it points to the correct instance

HTH,
Suprotim Agarwal

--
http://www.dotnetcurry.com
--

Sunday, February 12, 2012

cannot find database.mdf under app_Data using sql

Why can I not connect to the database created under app_data folder with sql express and view the tables. I am trying to understand the structure of how it works, I have gone through the My personal web site starter kit's files to try and understand how it writes to the database.Why is the databse not visible in SQL express and why are the databases attached database files and not directly in SQL2005.

I'm not sure I understand what you are asking. My version of the Personal Web Site starter kit came with the mdf in with all the other files. In VWD, I chose Add ASP.NET folder, and created an App_Data folder. I moved the Personal.mdf file into it and double clicked, and voila - it opened in Database Explorer.

If I wanted to examine such a database through Sql Server Management Studio (Express), I would attach the file myself to make it available to SSMSE.

|||

In VWD 2005 express, if you select database explorer you will see the connection to aspnetdb.mdf, which is created by personal starter kit. If you try and expand it to view the tables or store procedures it does not allow you to. Why? If I create a database manually in sql server express, and then create a connection via database explorer I can see all the tables created.

Error(This is the error I get when trying to view aspnetdb.mdf in database explorer

An error has occurred while establishing a connection to the server. When connecting to sql server 2005, this failure may be caused by the fact that under the default settings SQL server does not allow remote connections(Provider:SQL Network interface, error 26 errorlocating server/instance specified.

I also cannot create a .mdf file by adding " add new item SQL database"

Error

(Connection to SQL server files(*.mdf) requires SQL server express 2005 to function properly. Please verify the installation of the component or download from URL http://go.microsoft.com/fwlink/?linkid=49251.

SQL Express was installed at the same time when I installed VWD express 2005. So it is installed. I have aslo installed the SQL server managment studio

What I am ultimately trying to achieve is creating a authentication create user, but I do not want to use the Web administration tool for the reason I want the user to enter his information required and then auto generate a password but using his email address as his username, and then sending it to him via email for activation. I would prefer to customise the my ouwn database as to using aspnetdb.mdf


|||

Problem solved. If you install SQL 2000, and then uninstall and instal sql express 2005 it leaves some or other entries behind, thus it will not allow you to edit or view attached mdf database files it will tell you the instance name or server could not be found. I could not find the exact entry in ht registry so I reinstalled my os and applications and now it works fine.