Click to See Complete Forum and Search --> : SQL DB Deployment


Promotional Engine
November 9th, 2008, 09:07 PM
Hi all,
I've developed an application that's using SQL Server for DB, now I want to create a setup and give it to users.
For the DB part, I have a simple '.mdf' file that is created with SQL Server and connecting to it like this:

sql_conn = new SqlConnection(@"AttachDBFilename=c:\test.mdf;Integrated Security=true");

then it's a simple connection; but I don't know how to use my DB in the user's computer, I should only copy the .mdf file in the user's computer? what's the exact steps to deploy a SQL DB related application?
I've searched the Internet and some eBooks + MSDN but didn't find anything about that.
I'm working with C# 2.0 WinApp in VS2005 and it's for XP or Vista.

Please answer soon, since I want that in a week.
Thanks in advance.

TheCPUWizard
November 9th, 2008, 09:14 PM
Assuming there was no associated log file (.ldf), then copying the .mdf to the target and "attaching" to it is usually sufficient.

The alternative is to make a backup of the mdf file,and then "restore" it into the new server.

Some minor tradeoffs between the approaches, but both are common....

dee-u
November 10th, 2008, 02:11 AM
... I should only copy the .mdf file in the user's computer? ...

Aside from TheCPUWizard's suggestion, of course you need to install Sql Server in the target machine also assuming it is not yet installed...

Promotional Engine
November 10th, 2008, 01:51 PM
Thanks guys,

TheCPUWizard, can you explain the steps and statements in C# 2.0 to attach or back&restore a DB?

dee-u, the user should have SQL Server installed?! :eek: It's practical? I don't think it's the way that current apps are going! Please tell me what should be installed on the target machine and how to install that with an installer like .NET Setup. :cool:

Thanks. :)

TheCPUWizard
November 10th, 2008, 02:05 PM
1) The steps are NOT (typically) done fromwithin the application.

2) YES SQLServer needs to be installed on the machine. The MSI should be launched from within your own installer.

dee-u
November 10th, 2008, 11:52 PM
...It's practical?...

It is a requirement... :)

dee-u
November 10th, 2008, 11:58 PM
May I add that if it is going to be in a multi-user environment then you should just install in one machine and access the database from there...