Add mdf file to VB.Net project

I am using Visual Studio.Net 2008 Std edition with SQL Server 2008 Express. If I try to add a local database (db.mdf) to the project it returns an error (see attached image).

Running the query in the code snippet in MSSMS, I get a result telling me that I have MS SQl Express Edition with Advanced Services running. (10.0.1600.22, RTM, Express Edition with Advanced Services). The test query  comes straight from Microsoft's KB article http://support.microsoft.com/kb/321185/ where it is under the section "How to determine which version of SQL Server 2008 is running".

It therefore appears that I should be able to add the local database. I'd appreciate it if someone could tell me why I am getting the error shown.


SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')

Open in new window

SQL.gif
LVL 1
jindaleeAsked:
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.

Alfred A.Commented:
Hi,

10.0.1600.22, RTM, Express Edition with Advanced Services is SQL Server 2008 (SQL Server 10.0).  SQL Server 2005 is SQL Server 9.0.  The mdf was created with SQL Server Express 2005 I guess based on the error.
0
Alfred A.Commented:
Oh, I forgot to add in my previous post, VS2008 might be having problem accessing the mdf because it was created/configured in SQL Server Express 2005.
0
jindaleeAuthor Commented:
I am trying to add a brand new database not attach an existing one.
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

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
Alfred A.Commented:
By the way, are you using Server Explorer -> Data Connections to connect to the database?
0
Alfred A.Commented:
Oh, correction in my last post, what I meant was if you have tried using Server Explorer -> Data Connections to connect to the database.  This might be an alternative approach.
0
Alfred A.Commented:
-------> I am trying to add a brand new database not attach an existing one.

Just a suggestion, why don't you just do this in SQL Server Management Studio 2008 Express?  and then just access your database through ADO.NET conn string for example.
0
jindaleeAuthor Commented:
I can create a database through the Server Explorer and access it through ADO.Net conn string. It works fine.

I xcan also go into MSSMS, create the fdatabase in there and then attach it via the server explorer.

However, my client has said he wants a local database since he is not running over a network. I've tried to explain that the database can still be installed locally but just can't convicne him. I get the impression that he has been talking to an "expert" who has done a bit of SQL.
0
Alfred A.Commented:
I sympathized with your plight.  I experienced before what you are currently experiencing.  Some people, unfortunately, thinks that if they know one, they know all.  

Have you tried to demonstrate that a local SQL Express database can be installed locally?  As a consultant, I sometimes have debates with client and ended up challenging them for a demonstration to see for themselves.

Just my two cents of it. :-)

0
jindaleeAuthor Commented:
I'll go for the challenge by doing a test install on a standalone machine in his office. Thanks for the tip. I'll let you know how it goes.
0
jindaleeAuthor Commented:
I meant to add that I checked those links and found 1 partial solution that stopped the original error message but popped up another.
DBError.gif
0
jindaleeAuthor Commented:
I've been bouncing through the links on the forums.asp page and landed at this one: http://aspdotnetfaq.com/Faq/fix-error-Failed-to-generate-a-user-instance-of-SQL-Server-due-to-a-failure-in-starting-the-process-for-the-user-instance.aspx. It suggested deleting the path to the SQLEXPRESS instance in AppData. I tried. It worked. I also checked that it didn't prevent other apps I am developing from working. All are fine.

I'll give my client that local database which will save me tearing our more hair (which I can ill afford).

Many thanks for all of your help.
0
Alfred A.Commented:
Hi jindalee,

You accepted the wrong post.  Ha ha ha. :-)

Anyway, glad to help.  Goodluck with your projects!  :-)



0
jindaleeAuthor Commented:
So I did! At least I got my solution and the right person got the points. :)
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.