Alright , I have connected to the actual database and I also made a backup.
The backup generates a .bak file. The mdf and ldf files were already created
when I created the database. Back up created only one .bak file. What do I do
now?
Also can you please tell me about any free installer package where I could
include these files. Or does one come with the VS 2005? If yes, where can I
find it. Any tutorial on how to proceed with this?
Thanks a lot.
> You don't have to create a local database in this case. In the connection
> string you should only specify the name of the server where the database is
[quoted text clipped - 61 lines]
> > > Sql Server Express, I ran across articles out there on Google showing the
> > > how to.
Ok, that's good. You can now attach the database bak file to your
installation package. To make an installation package use the build in setup
& deployment install wizard that steps through all the settings. When
prompted to select what additional files to bundle up with the package,
select your SQL database backup file.
If size is an issue, you can also create a script file of your database. Use
SQL Server Management Studio to log in and right click on the database you
want to deploy. Select "Script Database As"->"Create To"->"File" and then
save the file. This file contains the code to recreate your database and
takes less space than the previous method. Add the file to your install
wizard by using the same steps as above.
Ok, now that you have an installation package you can now install your
program + database file to the host computer. Obviously the client will need
SQL Server 2005 installed on their end for this to work. With the database
bak or script file on the client computer you need to log into SQL Server
Management Studio on the client and either use the bak file to restore the
database from the backup or run the script file to produce a new database.
Both options are manual. When done, update you application's config file to
point to the new database server - you only need to change the "Data Source"
string in the connection string. That's it.
To make this automatic, I think you need to make a custom dll that launches
during installation and runs the script to create the database. This might
run into security problems though and you would also need to know the name of
the database server to install to and at the end change the application
config file.
Adrian.

Signature
[Please mark my answer if it was helpful to you]
> Alright , I have connected to the actual database and I also made a backup.
> The backup generates a .bak file. The mdf and ldf files were already created
[quoted text clipped - 72 lines]
> > > > Sql Server Express, I ran across articles out there on Google showing the
> > > > how to.
Punit Kaur - 18 Jul 2007 21:24 GMT
Hi,
Thank you for the detailed steps. From your answer I infer that the client
will need to manually do things which is not my intention. I remember doing
it in an easier way where I did not even need to do anything manually except
for installing the .msi package that had the database .mdf files along with
all the other components like .net 2 framework besides the actual
application. Also since the connection string was relative and I am using
"localhost" instead of my machinename, I had no problems installing and
running the application. I remember I had used the "Publish" wizard in VS.NET
2005.
However, since now I am having connection string problems when I am using
|DataDirectory| in the connection string to access .mdf file... I thought
that the solution you were giving would not require the client to do anything
once I attached .mdf files.
Is there any way besides the custom dLL solution where we can do it without
having to restore the database or do anything manually on the clients
computer?
Thanks
> Ok, that's good. You can now attach the database bak file to your
> installation package. To make an installation package use the build in setup
[quoted text clipped - 103 lines]
> > > > > Sql Server Express, I ran across articles out there on Google showing the
> > > > > how to.
ainsleyp@gmail.com - 30 Jul 2007 19:11 GMT
Use a connection string that looks like this:
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|
MyDatabase.mdf;User Instance=True;Integrated Security=True
This will attach using a user instance. That means you don't have to
do anything manual like attaching the database in SQL Server
Management Studio. You just include Sql Server 2005 Express in the
installation (it's even in the Prerequisites list in your Setup
project so you just have to check a box), and just include the
database files with the setup.
It makes it difficult to remotely connect into the database, but if
you don't need to do that then stick with user instances. They're
quite convenient.
Paul
On Jul 18, 1:24 pm, Punit Kaur <PunitK...@discussions.microsoft.com>
wrote:
> Hi,
>
[quoted text clipped - 17 lines]
>
> Thanks