App_Data SQLExpress databases

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.

Andy
LVL 3
Andy GreenAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gyanendra SinghArchitectCommented:
>>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;
 
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Andy GreenAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.