473,612 Members | 2,331 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to setup database in VS Setup project?

I have a .sql script that holds the configuration of a local sql express
database needed for my C# .net forms app. I would like the script to run.
Right now, I have a install_db.cmd file that basically just runs the sql
script from the command line. I made a console app that runs the
install_db.cmd

I added that console app to the application folder and then ran that as a
custom action. The command windows pops up real quick, but then goes away and
the database never actually gets created.

Any ideas how to do this better or make it actually work?
Dec 14 '07 #1
1 5013
"Brandon" <Br*****@discus sions.microsoft .comwrote in message
news:17******** *************** ***********@mic rosoft.com...
>I have a .sql script that holds the configuration of a local sql express
database needed for my C# .net forms app. I would like the script to run.
Right now, I have a install_db.cmd file that basically just runs the sql
script from the command line. I made a console app that runs the
install_db.cmd

I added that console app to the application folder and then ran that as a
custom action. The command windows pops up real quick, but then goes away
and
the database never actually gets created.

Any ideas how to do this better or make it actually work?
You can use something like this:

using (SqlConnection connection = new
SqlConnection(c onnectionString ))

{

using (SqlCommand command = new SqlCommand())

{

command.Connect ion = connection;

command.Command Text = File.ReadAllTex t("file.sql") ;

connection.Open ();

command.Execute NonQuery();

}

}

The difference is that you need to execute one batch at a time. You can't
execute the whole thing at once. I have used a regular expression and the
..Split method to split the file on the "GO" commands, then execute each
batch one at a time.
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer
Dec 14 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1028
by: santhosh_176 | last post by:
:I Created a Pocket PC application for iPAQ 5450. Every thing went fine even installer creation. I could run the setup and install it into the actual device and worked fine. The application enables syncronization with remote database using merge replication. I found contradictory results while installing the application. I will mention here all the steps that I done while creating and installing setups. Result: Case 1: worked fine. ...
3
2623
by: Sunny | last post by:
Hi I have a Database Application that i am trying to create a SETUP for. The application uses three custom Ms access Databases. Those database i added in the correct folder in the SETUP Project of my application However, perhaps due to the size of the Databases (appx 500 mb), or some other reason when i try to build my SETUP project, it fails, right in the start giving an ERROR, not enough DISK SPACE to complete this operation. I even...
0
1152
by: Sunny | last post by:
Hi I have made a Database Application for which i am trying to create a SETUP Project. The application uses three custom Ms access Databases. Those database i added in the correct folder in the SETUP Project of my application However, perhaps due to the size of the Databases (appx 500 mb), or some other reason when i try to build my SETUP project, it fails, right in the start giving an ERROR, not enough DISK SPACE to complete this...
0
1092
by: Oz | last post by:
Hi We in our company build asp.net and MS SQL Server apps for deployment on clients' machines. We have created an Installer class (DBInstaller) which runs several scripts to build a database, populate it will data, etc. I would like to be able to create a setup file, which, if the application is NOT installed on the client computer, installs from scratch. This already works in the MSI file we create. However, if the application DOES...
3
1750
by: John | last post by:
Hi I have an app to deal with two companies A & B within a group of companies depending on which database is selected. Is it possible for setup to ask the user at install time which company they want to install the app for and then pass the relevant database path as parameter in the desktop shortcut? Thanks Regards
4
2580
by: Saber | last post by:
In VS 2005 I made a setup project for my application. The application uses a mdb file and needs Microsoft Jet OLE DB Provider to run on another PCs. In Prerequisites section of Setup Property Pages there are some checkboxes including Microsoft Data Access Component 2.8. But in microsoft site they say: This release does not include Microsoft Jet, the Microsoft Jet OLE DB Provider or ODBC driver, the Desktop Database ODBC Drivers, or the...
4
3398
by: Paul | last post by:
Hi, I am developing a c# windows .NET application. The application is going to run on a standalone PC and use an access database. I have figured out that I will need to create a project and add it to the custom actions of the my setup project to create the database. How do I create the database and then add a table using C#? Also, should I use an odbc data adapter, which I usually use with Access and if so how do I register the new...
3
3041
by: Maha | last post by:
Hi all, It is my first time with windows forms applications using Visual Studio .net 2005, and I have a question; My project is a database driven one which will be distributed on a CD. I know that Ishould include 'Microsoft Sql Server 2005 Express' with the setup project as a prerequisit, but what about my database
2
2741
kaushalparik
by: kaushalparik | last post by:
hi all, i am working with Desktop application, and trying to create a setup project. i finalized my application and now creating the setup for that application. what i need to do is, with in setup dialog boxes, i have to add my custom form which will ask for DB Details like DBServer name, User Name, Password, name of Database and SQL Server Selection etc., So, Besides my main application, i also added a Class Library Project with an...
0
949
by: winbala | last post by:
I am currently working in VB.NET project which is a desktop application with Access as database. I had made a setup project of my application. I ran the same in another machine which had Win 2000 professional as OS and no .NET Framework installed. When I was running the setup I got an error saying : .Net Framework 1.1 not installed . Please install and then run your setup program. I did the same then there was another error Mdac 2.7...
0
8617
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8568
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8254
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7044
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6082
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5537
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4047
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2555
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1416
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.