CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2006
    Location
    Iran - Shiraz
    Posts
    8

    Question SQL DB Deployment

    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.
    NetTimeSaver - My software that stores your connecting infos with any windows connection type.

    Learn C++ Programming(Farsi) - C++ آموزش برنامه نویسی با

  2. #2
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: SQL DB Deployment

    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....
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  3. #3
    Join Date
    Jan 2006
    Location
    Pearl of the orient
    Posts
    304

    Re: SQL DB Deployment

    Quote Originally Posted by Promotional Engine View Post
    ... 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...

  4. #4
    Join Date
    Jul 2006
    Location
    Iran - Shiraz
    Posts
    8

    Re: SQL DB Deployment

    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?! 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.

    Thanks.
    NetTimeSaver - My software that stores your connecting infos with any windows connection type.

    Learn C++ Programming(Farsi) - C++ آموزش برنامه نویسی با

  5. #5
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: SQL DB Deployment

    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.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  6. #6
    Join Date
    Jan 2006
    Location
    Pearl of the orient
    Posts
    304

    Re: SQL DB Deployment

    Quote Originally Posted by Promotional Engine View Post
    ...It's practical?...
    It is a requirement...

  7. #7
    Join Date
    Jan 2006
    Location
    Pearl of the orient
    Posts
    304

    Re: SQL DB Deployment

    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...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured