i wrote a software which would work perfectly fine on vb.net with connection string:

SQLConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename='" & a & "';Initial Catalog='" & f & "';Integrated Security=True;User Instance=True"

but if i try and run it on a pc with sql server 2005 installed it fails to run
what changes do i need to do to make it run

Change this part SQLEXPRESS

thanks that worked but now arises another problem .After i have closed the application the database is still attached to the local server .i want to detach the mdf file from the server upon exit of the application.i used the DROP DATABASE command and that removes the database from the local server and the disk as well.i just want to remove it from the server.

I am not sure what you mean.

Just delete it from SQL Browser. why do you need to do it in the .net

I am assuming this is a One time thing. Just go into Sql Browser and delete it from there.

in the application the user can choose the mdf database he wishes to work with after he is done editing it .the application should detach the database and close.Its not a one time thing ,needs to be done via coding

i found a solution to it:
sys.sp_detach_db MyDatabase

but it tells me that cannot close as the database is in use

Make sure you have no connections open, and Dispose all SQLCommand, SqlDataReaders, SqlConnections, etc basically everything that called on the connection.

Be a part of the DaniWeb community

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