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?
 
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
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
jindaleeAuthor Commented:
I am trying to add a brand new database not attach an existing one.
0
 
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
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.