App_Data SQLExpress databases

Posted on 2008-11-05
Medium Priority
Last Modified: 2013-11-07
Hi Experts

I have a need to use the APP_Data folder to host my database to hold local test data. I have read several threads and got totally confused as thing wont work as I expect (or want)

What I want to do is use a current database without SQL Server installed. I read that you could detach the database mdf file and move it to the App_Data folder and away you go, but I get a connection error saying:

 'Login failed for user 'WebService'. The user is not associated with a trusted SQL Server connection.'

This is my connection string:

<add name="AppDatabase" connectionString="Data Source=.\SQLEXPRESS;AttachDbFileName=|DataDirectory|WS_Test.mdf;uid=WebService;pwd=ws;" />

Can I do what I want I'm trying to do.

If not what are my options.

And one more thing, if I create a database in the App_data folder I cannot set up user accounts for it, so what acount does it run under.

Question by:Andy Green
LVL 16

Accepted Solution

Gyanendra Singh earned 2000 total points
ID: 22884830
>>What I want to do is use a current database without SQL Server installed
you still need to have sql express running on the server

Here is where you can get conn strings...http://connectionstrings.com/?carrier=sqlserver2005
Take a look at the two titled "Attach a database file on connect to a local SQL Server Express instance" and "Attach a database file, located in the data directory, on connect to a local SQL Server Express instance".
Also take a look at scott's blog here http://weblogs.asp.net/owscott/archive/2005/08/26/Using-connection-strings-from-web.config-in-ASP.NET-v2.0.aspx.

so it would be Driver={SQL Native Client};Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;

Author Closing Comment

by:Andy Green
ID: 31513452

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question