473,398 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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\BuildScripts\
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.sql) 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_Start
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.ExcecuteNonQuery.
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 2532
On Sep 29, 3:07 pm, gamesfor...@hotmail.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\BuildScripts\
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.sql) 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_Start
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.ExcecuteNonQuery.
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*********@hotmail.comwrote in message
news:11**********************@g4g2000hsf.googlegro ups.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\BuildScripts\
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.sql) 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_Start
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.ExcecuteNonQuery.
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*********@hotmail.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\BuildScripts\
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.sql) 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_Start
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.ExcecuteNonQuery.
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
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 ...
9
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
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...
6
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...
7
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....
8
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...
2
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...
1
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...
8
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...
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...
0
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...
0
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...

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.