By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,574 Members | 1,968 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,574 IT Pros & Developers. It's quick & easy.

Installing database while setup

P: 28
can anybody help me in this
Apr 5 '06 #1
Share this Question
Share on Google+
20 Replies

P: 135
We'll need a little more information then that. What type of database, where is it going etc.
Apr 5 '06 #2

P: 28
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.
Apr 6 '06 #3

P: 135
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.
Apr 7 '06 #4

Expert Mod 100+
P: 2,327
Hmm, maybe i need to setup a post guidelines.
Apr 7 '06 #5

Expert Mod 5K+
P: 8,916
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
Apr 7 '06 #6

P: 28
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&deployment 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

I hope u understand this, n expecting a goo help from u ...
Apr 10 '06 #7

P: 135
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.
Apr 10 '06 #8

P: 28
i need some examples

if possible some links to this kind of examples

Apr 11 '06 #9

P: 135
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;325003#kb1

SqlCmd help from MSDN
Apr 11 '06 #10

P: 135
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
Apr 11 '06 #11

P: 28
thanku for the help
Apr 12 '06 #12

P: 135
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)

Expand|Select|Wrap|Line Numbers
  1.         private void button1_Click(object sender, EventArgs e)
  3.         {
  4.             try
  5.             {
  6.            Process RunSQLScript = new Process();
  7.            RunSQLScript.StartInfo.FileName = "sqlcmd";
  8.            RunSQLScript.StartInfo.Arguments = "-E -S clovis-003 -i c:\\test.sql -o c:\\testData.txt";
  9.            RunSQLScript.Start();
  10.             }
  11.            catch(Exception f)
  12.             {
  13.                 Console.WriteLine("An error occurred: '{0}'", f);
  14.             }
  16.         }
hope that helps
Apr 12 '06 #13

P: 28
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\installer\debug then i want to store my files in

h:\myproduct\installer so how to do this

Apr 13 '06 #14

P: 135
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.
Apr 13 '06 #15

P: 28
To find the source path of my database files just i have used a small trick
here first i srored the path to my database files in a string variable it contains all path except the drive name because we can't say in clint sys what is drive name of cd drive so i get this drive from source path

Expand|Select|Wrap|Line Numbers
  1.  private string GetConfigFilePath(string fpath) 
  2. {
  3.     string filePath = "";
  4.     string dd = "";
  5.     string Resources=@"\application\databasefolder\";    
  6.     dd=sourcePath.Substring(0, 3);
  7.     string strConfigLoc = dd + Resources
  8.     string strTemp = System.IO.Path.GetDirectoryName(strConfigLoc).ToString();
  10.     filePath = strTemp+@"\";
  11.     EventLog.WriteEntry("filepath", filePath , EventLogEntryType.SuccessAudit);
  12.     return filePath;
  14. }
Apr 15 '06 #16

P: 135
I like your solution. I was trying to find the equivilant to VB6's "App.Path" but was unable to locate it. What namespace is "SourcePath" under?
Apr 15 '06 #17

P: 28
SourcePath is not from namespace. do one thing , in custom action editor



go to properties of that UrCustomAction.dll is what ever ur custom action file
in that

CustomActionData property is there

enter following in to that property

/SourceFolder="[SourceDir]\" /DestinationFolder="[TARGETDIR]\"

here [SourceDir] is source folder of ur custom action dll

njoy n all the best
Apr 18 '06 #18

P: 28
How to find werther the SqlExpress is installed on current machine or not

i need this to install Sqlexpress on selection of client but i have to check first werther its alredy installed in sys
Apr 18 '06 #19

P: 28
if u want just go through this link

All the best friends

Apr 18 '06 #20

P: 28
Hi friends , i am developing a setup and deployment project for our application here i have to include two other applications with our product installer, and they must be installed only when use selects them. can any body have any idea abt this

just how to create nested installer. clear idea

thank u
Apr 21 '06 #21

Post your reply

Sign in to post your reply or Sign up for a free account.