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?
 
Gyanendra SinghConnect With a Mentor ArchitectCommented:
>>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
 
Andy GreenAuthor Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.