I've been working with SQL2008 AdventureWorks; specifically database AdventureWorks, table Person.Contact.

I experimented with using a DataGrid control's DataSource property to add a new project data source to the DataGrid, although my code was written to access the database without using a DataGrid. My code was unable to do so because, naturally enough, the database was already in use by the DataGrid.

However, when I removed the DataGrid, to my surprise the AdventureWorks database was just plain gone. That's right, not corrupted, but gone from the disk without a trace. The other databases (AdventureWorksDW, AdventureWorksDW2008, AdventureWorksLT, AdventureWorksLT2008, ReportServer$SQLEXPRESS, ReportServer$SQLEXPRESSTempDB) were still there, but not the database named simply "AdventureWorks".

So I reinstalled AdventureWorks. Now here's the part where you all conclude I've lost my mind: AdventureWorks installed without any problem - but no database named simply "AdventureWorks". No "Person.Contact" table, even in any of the other databases. No sign of them, no explanation.

But you can look up the AdventureWorks schema online and see that they DO exist. So I'm NOT insane after all - honest, fellas, I’m not dangerous, it’s all right to talk to me.

So wha’d’ya think is going on here?

Recommended Answers

All 3 Replies

Bob,

I take it you are using the Data Source Wizard crap in VS2008.
Some people get along with it, but I have been bitten way too many times, and I simply refuse to use it. It has the potential to lose databases, and IMO it is more trouble than it is worth.

I see a lot of new students accessing MDF files through VS, and most of them end up with some issue at the end of the day. Some of them get tragic results.

Personally, I prefer to build my own DAL (Data Access Layer) class and let it deal with data the way I want to.... not the way that wizard does it. When comparing code between my DAL, and the horrendous, bloated, useless class that VS creates for you... you will see why most people avoid it.

Sorry for venting, but you are not the first person to get bit by VS's Database wizard class generator. If that is what you are using.

If the database is indeed still in the SQL Server, then blow away the class that VS built for you as the database designer stuff. Delete it from the project, and see if you can get back to the database using traditional SQL___ methods.

Good luck
// Jerry

JerryShaw :

I take it you are using the Data Source Wizard crap in VS2008.

Yes, the problem arose when I experimented (once) with the Data Source Configuration Wizard in Visual C# 2008 Express (accessed via the DataSource property in the Properties window in the Form1.cs [Design] window, when the DataGrid control was selected).

It has the potential to lose databases...

Where do you think they “go” when they are lost?

I see a lot of new students accessing MDF files through VS…

Every other time I always accessed databases through “traditional” SQL methods.

…most of them end up with some issue at the end of the day. Some of them get tragic results.

My problem is even more tragic than losing a database outright - I can’t even reinstall it. Surely nothing worse than that happens, does it?

Personally, I prefer to build my own DAL (Data Access Layer) class and let it deal with data the way I want to...

I’m a newbie - that sounds a little more involved than I want to get into while I’m learning.

If the database is indeed still in the SQL Server, then blow away the class that VS built for you as the database designer stuff. Delete it from the project, and see if you can get back to the database using traditional SQL___ methods.

No, it’s gone - I went back to earlier versions of my app (different projects that never used anything but traditional SQL methods) with the same result. And the database “AdventureWorks” is simply just not showing up in SQL Server 2008 Express.

Is it possible that database "AdventureWorks” IS there and SQL Server 2008 Express simply refuses to show it because it now "belongs to" another fictitious, non-logged-in user that was somehow conjured into being by the Data Source Configuration Wizard?

(I can't just look for the files in Windows Explorer. These databases are somehow hidden in other files that, although I know they reside in subfolders of C:\Program Files\Microsoft SQL Server\100\Tools\Samples, I've never been able to locate precisely.)

Bob,

Look in the directory:
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data
for the AdventureWorks_Data.mdf file.

If you do not already have the Sql Server Management Studio Express, then I recommend you download it from MSDN (its free).

If the file exists in that directory, then use SSMS to see if the database exists as a registered database. If not, then try attaching it using the options on the Database node.

I believe that you can also get the script from MSDN (or already on your hard-drive for re-creating that database).

Let me know how it goes.
BTW: a DAL is whatever you want to make of it. It is not something fancy or complicated. If you want to learn more about it, let me know.

// Jerry

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.