Attaching *.mdf (MSDE)

BadgerByte

Well-known member
Joined
Aug 5, 2005
Messages
194
Location
Ipswich, UK
Programming Experience
5-10
Hey all,

Currently deploying MSDE and have written an installer class, I intend to use sp_attach_db within the installer class to attach a database previously detached from my development system. I have all the code for using sp_attach_db, but have hit a brick wall!!

Does anyone know how on earth I would know where the mdf files are from the installer class? I have to pass the path to the stored procedure. I tried GetCurrentDirectory in the hope that it would return either the application directory or the deployment CD path but it returns the system32 directory. Has anyone done this before? if so any help would be marvellous.

I may even perform a remarkably sophisticated dance for you in compensation!

To summarise:

I have an installer class

On the AfterInstall event I'm trying to run sp_attach_db

I have everything else set up (Detecting service, starting service, instance etc)

I don't know where to put the mdf file or how to find them from the installer class.
 
Not sure if this is what your looking for,

IO.Path.GetDirectoryName(Reflection.Assembly.GetExecutingAssembly.Location())

should return the path for your app.

Hope this helps.
 
Now I don't want to cause fear here Martin, but I'm afraid I may just have fallen in love with you!!

Heh, Works a treat, many thanks.

*performs a somewhat clumsy dance*
 
Msde

Hi

I want to creat a setup program for my vb.net application. But, not sure how can I install MSDE engine from setup package and attace a database using .mdf & .ldf included in the setup program.

Kinldy help me

Rgds/
 
Back
Top