473,654 Members | 3,107 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Run SQL scripts from VB.NET

Hi Everyone!

I work in a company that has developed several VB.Net Web
applications. Currently we use SourceGear's Vault for source control
and versioning for the application files. One area that have been
left
behind a little bit is the version control on database level. Our
typical installation of an application is like this:
1. Get latest application file build from FinalBuilder.
2. Install the build output.
3. Run SQL scripts:
3.1 Manually run BuildScripts from \\application folder\BuildScr ipts\
that creates database, storeproc, tables etc.
3.2 Manually run ChangeScripts from \\application folder
\ChangesScripts
\, this is multiple scripts and any changes on the database level is
added in a new script with a number in the script indicating
versionnr
(ChangeScr_001. sql - ChangeScr_087.s ql) Currently 087.sql is the
latest.
What we are trying to do right now is to get rid of the manual steps
in 3.1 and 3.2 by building these into the application startup. As
mentioned in the topic i need to run the BuildScripts (if database is
not installed) and then the ChangeScripts the first time the
application is started. I'm told to do this from the
Application_Sta rt
method in Global.asax.
What's the easiest way for me to execute all the BuildScripts and
ChangeScripts ? Is it possible to read all scripts into a
streamreader
and then send the stream to command.Excecut eNonQuery.
One other thing is that I want this to be in a transaction, so that
if
it fails it will be rolled back.
Any tips or codesnippets are greatly appreciated! :)
Regards
Mcad

Sep 29 '07 #1
3 2542
On Sep 29, 3:07 pm, gamesfor...@hot mail.com wrote:
Hi Everyone!

I work in a company that has developed several VB.Net Web
applications. Currently we use SourceGear's Vault for source control
and versioning for the application files. One area that have been
left
behind a little bit is the version control on database level. Our
typical installation of an application is like this:

1. Get latest application file build from FinalBuilder.
2. Install the build output.
3. Run SQL scripts:
3.1 Manually run BuildScripts from \\application folder\BuildScr ipts\
that creates database, storeproc, tables etc.
3.2 Manually run ChangeScripts from \\application folder
\ChangesScripts
\, this is multiple scripts and any changes on the database level is
added in a new script with a number in the script indicating
versionnr
(ChangeScr_001. sql - ChangeScr_087.s ql) Currently 087.sql is the
latest.

What we are trying to do right now is to get rid of the manual steps
in 3.1 and 3.2 by building these into the application startup. As
mentioned in the topic i need to run the BuildScripts (if database is
not installed) and then the ChangeScripts the first time the
application is started. I'm told to do this from the
Application_Sta rt
method in Global.asax.

What's the easiest way for me to execute all the BuildScripts and
ChangeScripts ? Is it possible to read all scripts into a
streamreader
and then send the stream to command.Excecut eNonQuery.
One other thing is that I want this to be in a transaction, so that
if
it fails it will be rolled back.

Any tips or codesnippets are greatly appreciated! :)

Regards
Mcad
http://www.mattberther.com/?p=619
http://forums.microsoft.com/MSDN/Sho...19811&SiteID=1

Sep 29 '07 #2
You can open a text file with SQL statements and run them. You can also set
up an installer that you can automate that runs the build and change
scripts. Another option is setting up the create and change scripts as
stored procedures and running using the database name, etc. The last one
will not work if this is an install you are not controlling.

Another thing you might look into, if this is an Enterprise build, is use a
tool like Cruise Control .NET (continuous integration). With CC .NET, your
project is built every time you check in source code. It gives you the
ability, using nAnt, to set up build tasks that run automatically. And, it
can be configured against vault. This is, of course, for your developer test
area and not to automatically be run against production, but you can use the
same tasks that you have used on your development machine.

If you have Team Foundation Server, you also have the option of using the
Build Server. If not, MSBuild can be used to automate a great variety of
tasks and build an application.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************** *************** *************** ****
| Think outside the box!
|
*************** *************** *************** ****
<ga*********@ho tmail.comwrote in message
news:11******** **************@ g4g2000hsf.goog legroups.com...
Hi Everyone!

I work in a company that has developed several VB.Net Web
applications. Currently we use SourceGear's Vault for source control
and versioning for the application files. One area that have been
left
behind a little bit is the version control on database level. Our
typical installation of an application is like this:
1. Get latest application file build from FinalBuilder.
2. Install the build output.
3. Run SQL scripts:
3.1 Manually run BuildScripts from \\application folder\BuildScr ipts\
that creates database, storeproc, tables etc.
3.2 Manually run ChangeScripts from \\application folder
\ChangesScripts
\, this is multiple scripts and any changes on the database level is
added in a new script with a number in the script indicating
versionnr
(ChangeScr_001. sql - ChangeScr_087.s ql) Currently 087.sql is the
latest.
What we are trying to do right now is to get rid of the manual steps
in 3.1 and 3.2 by building these into the application startup. As
mentioned in the topic i need to run the BuildScripts (if database is
not installed) and then the ChangeScripts the first time the
application is started. I'm told to do this from the
Application_Sta rt
method in Global.asax.
What's the easiest way for me to execute all the BuildScripts and
ChangeScripts ? Is it possible to read all scripts into a
streamreader
and then send the stream to command.Excecut eNonQuery.
One other thing is that I want this to be in a transaction, so that
if
it fails it will be rolled back.
Any tips or codesnippets are greatly appreciated! :)
Regards
Mcad

Sep 30 '07 #3
Check out http://www.red-gate.com/

I have used their products a number of times and have no reservations
recommending them.

On Sat, 29 Sep 2007 06:07:27 -0700, ga*********@hot mail.com wrote:
>Hi Everyone!

I work in a company that has developed several VB.Net Web
applications . Currently we use SourceGear's Vault for source control
and versioning for the application files. One area that have been
left
behind a little bit is the version control on database level. Our
typical installation of an application is like this:
1. Get latest application file build from FinalBuilder.
2. Install the build output.
3. Run SQL scripts:
3.1 Manually run BuildScripts from \\application folder\BuildScr ipts\
that creates database, storeproc, tables etc.
3.2 Manually run ChangeScripts from \\application folder
\ChangesScript s
\, this is multiple scripts and any changes on the database level is
added in a new script with a number in the script indicating
versionnr
(ChangeScr_001 .sql - ChangeScr_087.s ql) Currently 087.sql is the
latest.
What we are trying to do right now is to get rid of the manual steps
in 3.1 and 3.2 by building these into the application startup. As
mentioned in the topic i need to run the BuildScripts (if database is
not installed) and then the ChangeScripts the first time the
application is started. I'm told to do this from the
Application_St art
method in Global.asax.
What's the easiest way for me to execute all the BuildScripts and
ChangeScript s ? Is it possible to read all scripts into a
streamreader
and then send the stream to command.Excecut eNonQuery.
One other thing is that I want this to be in a transaction, so that
if
it fails it will be rolled back.
Any tips or codesnippets are greatly appreciated! :)
Regards
Mcad
Oct 1 '07 #4

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

Similar topics

3
3154
by: Michele Simionato | last post by:
Is there a simple way to get the path to the Python Tools/scripts directory? Currently I have defined by hand an environment variable such as PYTHONSCRIPTS=/home/myhome/packages/Python-2.3.3/Tools/scripts so I can alias the more useful scripts in my .bashrc (for instance alias dutree=$PYTHONSCRIPTS/dutree.py), but this approach is PITA, I have to change the variable each time I change machine and at each new Python version. Is there...
9
3649
by: Jeff Wagner | last post by:
I have a project of converting numerous DOS cmd shell scripts to Python. Is there a tutorial to getting started? Thanks, Jeff
2
12737
by: RJ | last post by:
We currently send product releases to our customers, and often have to include scripts that need to be ran on the Oracle databases (also do it for SqlServer customers, but we use a different set of scripts for that). Some of the Sql scripts can be quite long, and so we break them out to their own script files and call them all from one main ..sql file, using sqlplus to execute it all. The admin would run the file like:
6
14548
by: Alex Vilner | last post by:
Hello! We have a set of individual .SQL scripts which we would like to execute against a MS SQL Server 2000. Is there any way to have ISQL utility (or any other means) to execute all of them without having to establish a separate database connection for each script: isql -Ux -Py -Ss -i script1.sql isql -Ux -Py -Ss -i script2.sql isql -Ux -Py -Ss -i script3.sql
7
4287
by: ergobob | last post by:
Hello, I have two small PHP scripts running on a test page at: http://www.usernomics.com/ergonomic-products-accessories5.html Both scripts work perfectly when there is one script on a page. However, if I place two on the page (one above the other), the second script will not render. I get no PHP error messages - the script will just not render. I think the PHP Scripts are OK as they were automatically generated by RSS
8
3740
by: Mike Nau | last post by:
We currently have all of our schema and testdata laid out in a large set of sql scripts. It currently takes about 15 minutes to run the scripts on a Dual 1.7ghz box with 1gb of ram. Does anyone know of a way to speed this up? Since our database is currently changing all the time, we are constantly having to re-create our database from these scripts.
2
4861
by: Dave Hughes | last post by:
Just noticed something rather annoying after upgrading my test box (a Linux server running DB2 UDB v8 for LUW) to fixpak 11 (for reference it was previously on fixpak 7). In the past I've relied heavily on the ability to start multiple long-running SQL scripts in the background and have them all run in parallel. Unfortunately, it seems that somewhere between fixpak 7 and fixpak 11 something has been fixed / broken which prevents more...
1
1543
by: ponsibabu | last post by:
We have several scripts for sale. We are selling them at reasonable prices and willing to work around your budget. For more information please contact totascriptz@yahoo.com with "Scripts" as the subject line. We have all types of scripts. We are very flexible with pricing and try to work around your budget. Some of our scripts are mentioned below. For more information please contact totascriptz@yahoo.com with "Scripts" as the...
8
2375
by: Alan Isaac | last post by:
Suppose I have a directory `scripts`. I'd like the scripts to have access to a package that is not "installed", i.e., it is not on sys.path. On this list, various people have described a variety of tricks they use, but nobody has proposed a pretty way to allow this. I am therefore assuming there is not one. (?) How about allowing a `scripts.pth` file in such a `scripts` directory, to work like a path configuration file?
3
1415
by: shapper | last post by:
Hello, I am working on a web site where I have a master page. Most web site pages use this master page as base. Some scripts are used in all pages ... other just in a few pages. Should I load all scripts in master page ... I think they are cached right? Or should I load the common scripts to all pages in my master page and
0
8290
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
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...
1
8482
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
7306
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...
0
5622
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
4149
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...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2714
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
2
1593
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.