Installing database while setup

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shanthsp2002
    New Member
    • Apr 2006
    • 28

    Installing database while setup

    can anybody help me in this
  • CaptainD
    New Member
    • Mar 2006
    • 135

    #2
    We'll need a little more information then that. What type of database, where is it going etc.

    Comment

    • shanthsp2002
      New Member
      • Apr 2006
      • 28

      #3
      i have to install it while installing product

      while installing product iuser can select database installation by checking chekbox then i have to install database on his system, database meanse in sql server.

      Comment

      • CaptainD
        New Member
        • Mar 2006
        • 135

        #4
        Sorry, still not enough information, what product, did you create it, if so, in what language.

        With what we have so far.

        As far as creating the database, with MS Sql Server (and I assume others) you can create a script that will create the database. Create the script, design your program (If you wrote it) to connect to the server and run the script.

        Comment

        • Niheel
          Recognized Expert Moderator Top Contributor
          • Jul 2005
          • 2432

          #5
          Hmm, maybe i need to setup a post guidelines.
          niheel @ bytes

          Comment

          • Banfa
            Recognized Expert Expert
            • Feb 2006
            • 9067

            #6
            Originally posted by KUB365
            Hmm, maybe i need to setup a post guidelines.
            Definately, I have been thinking the same thing for several weeks. I might even chip in and write some myself :D

            Comment

            • shanthsp2002
              New Member
              • Apr 2006
              • 28

              #7
              Well we have doveloped a product in c#

              we have doveloped a product in c# and it has diffrent applications ie.

              according to the clients role we have to install database . for ur clear idea
              i have created a custom diloguebox in setup&deploymen t project it looks some what like

              () cashier
              () central server option button
              () manager

              [] install database checkbox

              if user selects manager then only the installdatabase checkbox will be enabled and if he checks it we have to install local database. so i need some way to install or attach database to his local sql server using c#.net


              I hope u understand this, n expecting a goo help from u ...
              thanku
              Last edited by shanthsp2002; Apr 10 '06, 10:09 AM.

              Comment

              • CaptainD
                New Member
                • Mar 2006
                • 135

                #8
                Use SQL server (I'm assuming MS SQL Server) to create the scripts to build each of the databases. Then, based off the selection, connect to the database and run the script for that database.

                Comment

                • shanthsp2002
                  New Member
                  • Apr 2006
                  • 28

                  #9
                  oky can u give me example plzz

                  i need some examples

                  if possible some links to this kind of examples



                  thanku

                  Comment

                  • CaptainD
                    New Member
                    • Mar 2006
                    • 135

                    #10
                    I did some research and ran a test through VB6 (I'm learning C#)

                    I used the Shell feature and ran osql with the command line arguments and it worked. You'll need to write the code for C# to do the same. When I get time later I'll see what I can do in C#.

                    Here is some info on both programs.

                    If you're installing on SQL Sever 2005 then you'll use a program call SqlCmd.exe otherwise oSql.exe

                    OSql help from MSDN



                    SqlCmd help from MSDN

                    Comment

                    • CaptainD
                      New Member
                      • Mar 2006
                      • 135

                      #11
                      If you need all the command line arguments go to the command prompt and run osql /? or sqlcmd /?

                      That will give you a listing of all the command line arguments for each

                      Comment

                      • shanthsp2002
                        New Member
                        • Apr 2006
                        • 28

                        #12
                        Really its very helpfull

                        thanku for the help

                        Comment

                        • CaptainD
                          New Member
                          • Mar 2006
                          • 135

                          #13
                          Figured it out

                          Took some research but I got it to work in C#. My biggest catch was C# requires two "\\" for the drive spec where I entered one "\"
                          ("C:\\" instead of "C:\") The following code will run a SQL Script. In my case I wrote a script to query a database and put the data in a text file. your SQL script will create the database. (Through Enterprise manager, right click over the database, all task, Generate sql script and set the properties under Options)

                          Code:
                                  private void button1_Click(object sender, EventArgs e)
                                
                                  {
                                      try
                                      {
                                     Process RunSQLScript = new Process();
                                     RunSQLScript.StartInfo.FileName = "sqlcmd";
                                     RunSQLScript.StartInfo.Arguments = "-E -S clovis-003 -i c:\\test.sql -o c:\\testData.txt";
                                     RunSQLScript.Start();
                                      }
                                     catch(Exception f)
                                      {
                                          Console.WriteLine("An error occurred: '{0}'", f);
                                      }
                              
                                  }
                          hope that helps

                          Comment

                          • shanthsp2002
                            New Member
                            • Apr 2006
                            • 28

                            #14
                            Hi

                            I got another question, while installing i have to give the source path of the .mdf and .ldf files so that i can copy these in to Sql Servers Data folder and from there i can attach them to server but, how to specify the source path of these files. if i give source path of custom action property then it is a debug folder of the installer so when i build it all the files in that folder are being re-generated. so how do i do that. Is there any way to refer to the parent folder of this installer folder ie if the installer folder is

                            h:\myproduct\in staller\debug then i want to store my files in

                            h:\myproduct\in staller so how to do this


                            thanku
                            Regards
                            prashanth

                            Comment

                            • CaptainD
                              New Member
                              • Mar 2006
                              • 135

                              #15
                              I dont know the answer to that one. you might want to start a new thread and see if someone else can answer it for you. I've never created a custom action. I did look it up on MSDN but I did not see anything pointing me in that direction.

                              Comment

                              Working...