473,394 Members | 1,845 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,394 software developers and data experts.

update database through SQL script

I am doing customization for Microsoft Pos. I am working on
installation package now. I added some new tables and stored
procuedures and generated SQL Script for that. During the installation
process, after user entered the server name and database name, how to
open the script file (*.sql) and run that to update database? So they
don't have to open Query Analizer to run it. The idea is to get
everything done during the installation process. Anyone got an idea?

Thanks in advance.

Leanne

Nov 9 '06 #1
5 2089
Leanne,

You can run every script using the SQLCommand.executenonquery, therefore as
well Create and Alter statements.

http://msdn2.microsoft.com/en-us/lib...enonquery.aspx

I hope this helps,

Cor
"Leanne" <le******@connectretail.com.auschreef in bericht
news:11**********************@f16g2000cwb.googlegr oups.com...
>I am doing customization for Microsoft Pos. I am working on
installation package now. I added some new tables and stored
procuedures and generated SQL Script for that. During the installation
process, after user entered the server name and database name, how to
open the script file (*.sql) and run that to update database? So they
don't have to open Query Analizer to run it. The idea is to get
everything done during the installation process. Anyone got an idea?

Thanks in advance.

Leanne

Nov 9 '06 #2
Cor,
Thank you for your reply. My problem is, the generated SQL script
contains a lot " if exist...then drop...Go..." etc, so when I use

ls=My.Computer.FileSystem.ReadAllText(Dialog1.File Name)
sqlCommand.CommandText = ls
sqlCommand.ExecuteNonQuery()
I got many syntex error. (such as "Go" should be the last). I set the
command type to "text". I don't know what method I should use to read
string from the file and how should I tell sqlCommand that this is SQL
Script and not normal SQL Statement.

Thanks again
Leanne

Cor Ligthert [MVP] wrote:
Leanne,

You can run every script using the SQLCommand.executenonquery, therefore as
well Create and Alter statements.

http://msdn2.microsoft.com/en-us/lib...enonquery.aspx

I hope this helps,

Cor
"Leanne" <le******@connectretail.com.auschreef in bericht
news:11**********************@f16g2000cwb.googlegr oups.com...
I am doing customization for Microsoft Pos. I am working on
installation package now. I added some new tables and stored
procuedures and generated SQL Script for that. During the installation
process, after user entered the server name and database name, how to
open the script file (*.sql) and run that to update database? So they
don't have to open Query Analizer to run it. The idea is to get
everything done during the installation process. Anyone got an idea?

Thanks in advance.

Leanne
Nov 9 '06 #3
Leanne,

Did you look at the code in the Query analyzer from the SQL management tool,
if you start with a new one, than that starts with statements to let it
execute to be imported in the program libraries of SQL server.

Cor

"Leanne" <le******@connectretail.com.auschreef in bericht
news:11*********************@h48g2000cwc.googlegro ups.com...
Cor,
Thank you for your reply. My problem is, the generated SQL script
contains a lot " if exist...then drop...Go..." etc, so when I use

ls=My.Computer.FileSystem.ReadAllText(Dialog1.File Name)
sqlCommand.CommandText = ls
sqlCommand.ExecuteNonQuery()
I got many syntex error. (such as "Go" should be the last). I set the
command type to "text". I don't know what method I should use to read
string from the file and how should I tell sqlCommand that this is SQL
Script and not normal SQL Statement.

Thanks again
Leanne

Cor Ligthert [MVP] wrote:
>Leanne,

You can run every script using the SQLCommand.executenonquery, therefore
as
well Create and Alter statements.

http://msdn2.microsoft.com/en-us/lib...enonquery.aspx

I hope this helps,

Cor
"Leanne" <le******@connectretail.com.auschreef in bericht
news:11**********************@f16g2000cwb.googleg roups.com...
>I am doing customization for Microsoft Pos. I am working on
installation package now. I added some new tables and stored
procuedures and generated SQL Script for that. During the installation
process, after user entered the server name and database name, how to
open the script file (*.sql) and run that to update database? So they
don't have to open Query Analizer to run it. The idea is to get
everything done during the installation process. Anyone got an idea?

Thanks in advance.

Leanne

Nov 9 '06 #4
Cor,

If I start Query analyzer, then open the sql file, I can run that
without any problem.
Now what I want is to open the sql file from VB, and then execute that
throuth sqlCommand. Can you tell me how to do that? Some code sample
maybe?

Thanks
Leanne

Cor Ligthert [MVP] wrote:
Leanne,

Did you look at the code in the Query analyzer from the SQL management tool,
if you start with a new one, than that starts with statements to let it
execute to be imported in the program libraries of SQL server.

Cor

"Leanne" <le******@connectretail.com.auschreef in bericht
news:11*********************@h48g2000cwc.googlegro ups.com...
Cor,
Thank you for your reply. My problem is, the generated SQL script
contains a lot " if exist...then drop...Go..." etc, so when I use

ls=My.Computer.FileSystem.ReadAllText(Dialog1.File Name)
sqlCommand.CommandText = ls
sqlCommand.ExecuteNonQuery()
I got many syntex error. (such as "Go" should be the last). I set the
command type to "text". I don't know what method I should use to read
string from the file and how should I tell sqlCommand that this is SQL
Script and not normal SQL Statement.

Thanks again
Leanne

Cor Ligthert [MVP] wrote:
Leanne,

You can run every script using the SQLCommand.executenonquery, therefore
as
well Create and Alter statements.

http://msdn2.microsoft.com/en-us/lib...enonquery.aspx

I hope this helps,

Cor
"Leanne" <le******@connectretail.com.auschreef in bericht
news:11**********************@f16g2000cwb.googlegr oups.com...
I am doing customization for Microsoft Pos. I am working on
installation package now. I added some new tables and stored
procuedures and generated SQL Script for that. During the installation
process, after user entered the server name and database name, how to
open the script file (*.sql) and run that to update database? So they
don't have to open Query Analizer to run it. The idea is to get
everything done during the installation process. Anyone got an idea?

Thanks in advance.

Leanne
Nov 9 '06 #5
Not tested,

cmd.CommandText = _
"CREATE PROCEDURE dbo.whatever AS & vbCrLf & _
SELECT * FROM MyTable"
cmd.ExecuteNonQuery()

If it is already in your database than CREATE is ALTER

I hope this helps,

Cor

"Leanne" <le******@connectretail.com.auschreef in bericht
news:11**********************@i42g2000cwa.googlegr oups.com...
Cor,

If I start Query analyzer, then open the sql file, I can run that
without any problem.
Now what I want is to open the sql file from VB, and then execute that
throuth sqlCommand. Can you tell me how to do that? Some code sample
maybe?

Thanks
Leanne

Cor Ligthert [MVP] wrote:
>Leanne,

Did you look at the code in the Query analyzer from the SQL management
tool,
if you start with a new one, than that starts with statements to let it
execute to be imported in the program libraries of SQL server.

Cor

"Leanne" <le******@connectretail.com.auschreef in bericht
news:11*********************@h48g2000cwc.googlegr oups.com...
Cor,
Thank you for your reply. My problem is, the generated SQL script
contains a lot " if exist...then drop...Go..." etc, so when I use

ls=My.Computer.FileSystem.ReadAllText(Dialog1.File Name)
sqlCommand.CommandText = ls
sqlCommand.ExecuteNonQuery()
I got many syntex error. (such as "Go" should be the last). I set the
command type to "text". I don't know what method I should use to read
string from the file and how should I tell sqlCommand that this is SQL
Script and not normal SQL Statement.

Thanks again
Leanne

Cor Ligthert [MVP] wrote:
Leanne,

You can run every script using the SQLCommand.executenonquery,
therefore
as
well Create and Alter statements.

http://msdn2.microsoft.com/en-us/lib...enonquery.aspx

I hope this helps,

Cor
"Leanne" <le******@connectretail.com.auschreef in bericht
news:11**********************@f16g2000cwb.googleg roups.com...
I am doing customization for Microsoft Pos. I am working on
installation package now. I added some new tables and stored
procuedures and generated SQL Script for that. During the
installation
process, after user entered the server name and database name, how
to
open the script file (*.sql) and run that to update database? So
they
don't have to open Query Analizer to run it. The idea is to get
everything done during the installation process. Anyone got an idea?

Thanks in advance.

Leanne


Nov 10 '06 #6

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

Similar topics

2
by: Mark | last post by:
A beginner in this area, I have been able to read a record from a MySQL database and populate an HTML form (wow!). Now, my goal is to allow the user to edit the contents of the form and then...
10
by: Jim | last post by:
Hi, Let me explain how I'd generally do things. For a page where the user edits data, I'd generally call it something like editfred.php (for example), the page which updates the data would be...
13
by: Lyners | last post by:
I have a web page writen in ASP.NET that contains some javascript so that when a user presses a button, or edits a certain field in a datagrid, another cell in the datagrid is filled with a value....
4
by: Jonathan Upright | last post by:
Greetings to anyone who can help: I'm using WebMatrix to make ASP.NET pages, and I chose the "Editable DataGrid" at the project selector screen. As you may know, it defaults to the Microsoft...
16
by: Ian Davies | last post by:
Hello Needing help with a suitable solution. I have extracted records into a table under three columns 'category', 'comment' and share (the category column also holds the index no of the record...
0
by: Jim in Arizona | last post by:
I'm experimenting by following instructions at this address: http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/data/datalist.aspx on how to use the DataList. I was trying out the...
6
by: rukkie | last post by:
Hi, I have a dynamic HTML page with 4 columns of data, retrieved with PHP from a MySQL database. At the end of every row I have an UPDATE submit button, which activates a php update script to...
5
by: keeps21 | last post by:
A little problem I've run into is the following. I have a script that allows a user to edit a story. I have an HTML form for title and main_text which gets it's values by pulling the selected...
3
by: DavidPr | last post by:
I've wrestled with this code all day and I just can't figure out what the problem is. I have this same code on the add_job.php page and the edit_job.php page and neither one is enter in the correct...
7
by: Jarosław Kozik | last post by:
how to create script - update database development code using MSSQL 2000 Enterprise Manager i'm trying in this way all tasks -genetate sql script .... ( in this way I can generate only CREATE...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.