473,589 Members | 2,651 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Running an entire SQL Script from C#

Hi

I have written a small transformation routine that converts my XML file into
a bunch of Insert statements in another file. The file will be in the
following format but much longer:

INSERT INTO lockbox_refid (lockbox_refid)
VALUES ('lasfgasd ');

INSERT INTO lockbox_refid (lockbox_refid)
VALUES ('asgasg');

INSERT INTO lockbox_refid (lockbox_refid)
VALUES ('asgasg');

INSERT INTO lockbox_refid (lockbox_refid)
VALUES ('afgsasg');

How can I possibly run this entire script from inside of my script???
Assuming I can already make my connection to the SQL Server Database.
Nov 29 '05 #1
7 1459
Append them all together into a single string and use them as your
CommandText property with CommandType set to Text (on the xxxCommand object.
"farsad nasseri" <fa***********@ discussions.mic rosoft.com> wrote in message
news:3E******** *************** ***********@mic rosoft.com...
Hi

I have written a small transformation routine that converts my XML file
into
a bunch of Insert statements in another file. The file will be in the
following format but much longer:

INSERT INTO lockbox_refid (lockbox_refid)
VALUES ('lasfgasd ');

INSERT INTO lockbox_refid (lockbox_refid)
VALUES ('asgasg');

INSERT INTO lockbox_refid (lockbox_refid)
VALUES ('asgasg');

INSERT INTO lockbox_refid (lockbox_refid)
VALUES ('afgsasg');

How can I possibly run this entire script from inside of my script???
Assuming I can already make my connection to the SQL Server Database.

Nov 29 '05 #2

I'm sorry if this is a simple question.. but how do I append them all into
on string?
and is that the only way? is there no way of committing or executing a
script (*.sql)?
"Martin Robins" wrote:
Append them all together into a single string and use them as your
CommandText property with CommandType set to Text (on the xxxCommand object.
"farsad nasseri" <fa***********@ discussions.mic rosoft.com> wrote in message
news:3E******** *************** ***********@mic rosoft.com...
Hi

I have written a small transformation routine that converts my XML file
into
a bunch of Insert statements in another file. The file will be in the
following format but much longer:

INSERT INTO lockbox_refid (lockbox_refid)
VALUES ('lasfgasd ');

INSERT INTO lockbox_refid (lockbox_refid)
VALUES ('asgasg');

INSERT INTO lockbox_refid (lockbox_refid)
VALUES ('asgasg');

INSERT INTO lockbox_refid (lockbox_refid)
VALUES ('afgsasg');

How can I possibly run this entire script from inside of my script???
Assuming I can already make my connection to the SQL Server Database.


Nov 30 '05 #3
Yes you could use a StreamReader to read the sql from the file and then
set it as the commandText of the Command object.

Simon

farsad nasseri wrote:
I'm sorry if this is a simple question.. but how do I append them all into
on string?
and is that the only way? is there no way of committing or executing a
script (*.sql)?
"Martin Robins" wrote:

Append them all together into a single string and use them as your
CommandText property with CommandType set to Text (on the xxxCommand object.
"farsad nasseri" <fa***********@ discussions.mic rosoft.com> wrote in message
news:3E****** *************** *************@m icrosoft.com...
Hi

I have written a small transformation routine that converts my XML file
into
a bunch of Insert statements in another file. The file will be in the
following format but much longer:

INSERT INTO lockbox_refid (lockbox_refid)
VALUES ('lasfgasd ');

INSERT INTO lockbox_refid (lockbox_refid)
VALUES ('asgasg');

INSERT INTO lockbox_refid (lockbox_refid)
VALUES ('asgasg');

INSERT INTO lockbox_refid (lockbox_refid)
VALUES ('afgsasg');

How can I possibly run this entire script from inside of my script???
Assuming I can already make my connection to the SQL Server Database.


Nov 30 '05 #4
Hi,
You do not need to run it as a single script, at least the snip you gave,
you could just simply execute it one by one, of course the performance will
be lower than if you concatenate all the script in a single string and pass
it to the server.

Now if you have a REAL big script ( like 10K inserts ) having it as a
single command is not practical.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"farsad nasseri" <fa***********@ discussions.mic rosoft.com> wrote in message
news:3E******** *************** ***********@mic rosoft.com...
Hi

I have written a small transformation routine that converts my XML file
into
a bunch of Insert statements in another file. The file will be in the
following format but much longer:

INSERT INTO lockbox_refid (lockbox_refid)
VALUES ('lasfgasd ');

INSERT INTO lockbox_refid (lockbox_refid)
VALUES ('asgasg');

INSERT INTO lockbox_refid (lockbox_refid)
VALUES ('asgasg');

INSERT INTO lockbox_refid (lockbox_refid)
VALUES ('afgsasg');

How can I possibly run this entire script from inside of my script???
Assuming I can already make my connection to the SQL Server Database.

Nov 30 '05 #5
Listen that is really uncalled for take a chill pill man.

----------------------------------
http://community.ihostasp.net
ASP.NET Developer Community
Nov 30 '05 #6
> Listen that is really uncalled for take a chill pill man.

I agree. Whoever the heck it is you're talking to, whatever the heck you're
talking about, he or she should take a chill pill. Seriously. Dude.

--

Kevin Spencer
Microsoft MVP
..Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition

"ship261" <st*****@m-s-n-dot-net.no-spam.invalid> wrote in message
news:l8******** ************@gi ganews.com...
Listen that is really uncalled for take a chill pill man.

----------------------------------
http://community.ihostasp.net
ASP.NET Developer Community

Nov 30 '05 #7
Yup I have to agree .. no idea what your talking about .. hehe

Reply to wrong thread me thinks ;)

ship261 wrote:
Listen that is really uncalled for take a chill pill man.

----------------------------------
http://community.ihostasp.net
ASP.NET Developer Community

Dec 1 '05 #8

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

Similar topics

8
3311
by: Sticks | last post by:
ok... im not quite sure how to describe my problem. i have a php script that runs through my entire php site and writes the resulting output to html files. this is necessary as the nature of the hosting available to me for this particular page prohibits me from using php/mysql as i would like. my script works simply by using output buffers and an include the relevant section of code is as follows: ob_start();
1
1738
by: Andrew Chalk | last post by:
I am developing a CGI app, When the user loads my page I want to populate an HTML 'select' box (drop down menu) with items from a database. What is the best way to get my Python procedure that does this called when the page is loaded? Many thanks
5
3047
by: code_wrong | last post by:
Hi Firefox does not support the IE specific 'event' identifier and just quits running the script. ..... even though the identifier only turns up in code marked for IE only ... Does this seem reasonable? The script is here: http://www.lunds.us/private/coolclock.htm
12
2493
by: Troy | last post by:
My ISP provides me with 2 servers: one for normal web hosting (non-PHP) and a CGI server (with PHP). I create my website using fusion 7 and upload this in its entirity to the web hosting server. If I want to run CGI scripts, I can do so with an external link to a page on the CGI server. The problem however is that I have to maintain two sites and all associated links. Ideally, I'd like everything to be in one place, but I'm not allowed...
0
3697
by: Titof | last post by:
Hello, i want to create an active webpage that displays the status of users quotas on a volume of a server. I installed IIS on this server and installed Win2k server Resource Kit because the Perl script "DiskQuotas.pl" exactly doing what i want. I created a function (see below) that running the script in a dos-command mode... BUT nothing happens :(( please help me
2
15057
by: Benjamin Rutt | last post by:
I often execute a long-running python script which is a "driver" for my application; it may run for several hours on a large input. Under CPython, is it safe for me to modify the Python script and run it under some smaller inputs for test purposes, while the long-running script is still running? It seems safe to do so, but I want to be sure. I know, for example, that #!/bin/sh on my system is not safe in this regard. I suppose this...
13
5991
by: wattersmt | last post by:
Hello, I am trying to write a python cgi that calls a script over ssh, the problem is the script takes a very long time to execute so Apache makes the CGI time out and I never see any output. The script is set to print a progress report to stdout every 3 seconds but I never see any output until the child process is killed. Here's what I have in my python script:
24
2827
by: Mark | last post by:
Hi, I'm new to python and looking for a better idiom to use for the manner I have been organising my python scripts. I've googled all over the place about this but found absolutely nothing. I'm a linux/unix command line guy quite experienced in shell scripts etc. I have a heap of command line utility scripts which I run directly. What is the best way to create python command line scripts but exploit the (loadonly) speed-up benefit of...
22
3807
by: V S Rawat | last post by:
(bringing the discussion here for php.general) I am on xpsp3, wampserver 2.0, having apache 2.2.8, php 5.2.6, MySQL 5.0.51b. http://localhost/ is E:\wamp\www\ I have put the first php script to hello.php file: <html> <head> <title>PHP Test</title>
0
7931
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8360
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
7990
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
8224
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
3849
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
3889
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2374
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
1
1461
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1198
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.