473,385 Members | 2,005 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,385 software developers and data experts.

run SQL script through SQLCommand

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.
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.
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. Anyone got an idea? Some code sample maybe?

Thanks
Leanne

Nov 9 '06 #1
0 1097

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

Similar topics

1
by: viktor9990 | last post by:
I have a page called CustomerSlides.aspx which contains an iframe(with the source Lookupage.aspx). The iframe page will look continuously in the database to see if a value has changed: if it is...
1
by: viktor9990 | last post by:
I have a page called CustomerSlides.aspx which contains an iframe(with the source Lookupage.aspx). The iframe page will look continuously in the database to see if a value has changed: if it is...
10
by: Henrik Dahl | last post by:
Hello! After I've finished using an instance of the SqlCommand class, should I then invoke Dispose() on the instance. I suppose so, as there is a Dispose method, but what does it actually...
3
by: Steve Richter | last post by:
I have the asp.net source of a web application. ( from a great asp.net book by Wrox ) ...
2
by: anoop | last post by:
Hello, I created a Public class in .aspx.vb code behind file, now I want to know can I call that functions in the class in the Scripts either client side or server side in .aspx page. also I want...
1
by: job | last post by:
how is it possible to serialize/de-serialize a SqlCommand?
5
by: Leanne | last post by:
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...
0
by: jaredciagar | last post by:
Hi Guys, Can You Help Me PLease, I'm Currently facing Problems in my system... I need some help... I'm using VB script,ASP.net,MS SQL Server2005 I want to select a specific data in...
7
by: Smurfas | last post by:
Hi, I write News Script: Write news skript, but how maket that - Whent I push "Read Full News" show full news? Some like that: http://blogs.msdn.com/ Sorry, for bad English My script ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
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
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...

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.