Wednesday, March 21, 2012

Location of SQL-datafile after installation of VB 2005 DB-application

Hello Experts,

I am relatively new to VB 2005 and SQL Express. I have a question concerning where I can find the SQL-database file (*.mdf) after I have installed (published) my VB 2005 database-application (the *.mdf file was created by Visual Studio Express?). It seems it is nowhere in the disk of the of pc it is installed on. So, what happens to *.mdf file after installation of the application, in what way I can connect to the *.mdf file after the application - the file is part of - is published?

In need of help,

MY

That depends on wheter you are using User instances (standalone mdf files with a SQL Server Express) or server attached files. User instances are normally put in the app_Data directory, whereas saved and marked for deploy and installation will be placed in the appropiate configured folder.

Jens K. Suessmeyer


http://www.sqlserver2005.de

|||Thank you for your reply,

I found finally the *.mdf files (along with the rest of the program files) installed as hidden folders under C:\Documents and Settings\User\Local Settings\...Data\. So, in this respect problem is solved. Obviously, I was using User Instances - at least in the end of my app's ConnectionString I was "User Instance=True". Does this mean that I am using user instances? - And if I mark "User Instance=False" will the installation program automatically attach the *.mdf data file then to SQL Express local server?

And if so, then I have another troublesome question. I am creating an VB DB-application whose DB-structure will change later (further tables will be added later). And my client will add data already data into database of preliminary version. Then I later will update / redeploy (with ClickOnce method) the application - so will the redeployment of the new version of application overwrite the data in SQL-database of older version? - i.e. does the new database file (with nothing or meaningless test data in it) replace the older database content (It would be serious damage to overwrite that data). The change of DB-structure is a another problem.

Could you, please, clarify for me what should I do,

Matti

|||

ClickOnce installation replaces all of the project files, including your database file. This is a short comming in how VS handles database files in 2005. You'll have to find an alternative way to deal with deployment within the ClickOnce framework.

Happily, you can watch the web cast I recorded discussing just such an alternative, links to both the 'cast and the source code demonstrated are available from this blog post.

Mike

|||

Mike,

thank you very much for your reply - and your SQL Server Express WebLog. That is all now and in coming days very important information for me that.

Well, I have started to consider not to include mdf-file in the deployment process at all but install (attach) it manually on a deployment pc via SQL Server Management Studio Express (which of course needs then to be installed on the deployment pc as well). In this way I will not certainly touch in the process of redeployment / update the inserted data in DB.

Also this makes the future changes of DB-structure easier for me; I can perform them through SSMS via SQL: simply add here new tables and relationships.

Thank you,

MY

No comments:

Post a Comment