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

Running Scripts

I have a problem... I need to do a SQL script runner.
Somenthing like the query analizer, but hidding the code.

I try with the sqlCommand, but doesn't work. The scripts
have: "go"es, "commit"s, etc. And I need to present the
command result.

Somebody can give a recomendation about this, I try doing
this:

private System.Data.SqlClient.SqlConnection Connection;
private System.Data.SqlClient.SqlCommand
Scriptor;
System.Windows.Forms.TextBox scriptt;
Connection = new System.Data.SqlClient.SqlConnection();
this.Scriptor = new
System.Data.SqlClient.SqlCommand();
Connection.ConnectionString = "data
source=DBSERVER;initial catalog=TEST;integrated
security=SSPI;persist s" +
"ecurity
info=False;packet size=4096";
scriptt = new System.Windows.Forms.TextBox();
Scriptor.Connection = this.Connection;

byte[] buffer;
System.IO.FileStream fscript =
new System.IO.FileStream
(textBox1.Text,System.IO.FileMode.Open);
System.Text.ASCIIEncoding trans =
new System.Text.ASCIIEncoding();
int n;
buffer = new byte[bufferSize];
Scriptor.CommandText="";
scriptt.Clear();
string temp;
n = fscript.Read
(buffer,0,bufferSize);
while (n != 0)
{
temp = trans.GetString
(buffer)
Scriptor.CommandText =
Scriptor.CommandText+temp;
buffer = new byte
[bufferSize];
n = fscript.Read
(buffer,0,bufferSize);
}
fscript.Close();

Connection.Open();
Scriptor.Prepare();
scriptt.Text =
Scriptor.CommandText;
scriptt.AppendText("Esto
salió "+Scriptor.ExecuteNonQuery());
Connection.Close();
Nov 15 '05 #1
0 1704

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

Similar topics

1
by: Rolfe | last post by:
Hi, I struggled, and got mod_python running on Apache/Win2k. Follow these instructions verbatim and you shouldn't have any trouble. These instructions are based on...
4
by: Peter Otten | last post by:
Is there a way to limit both width and height of a canvas text item? My current workaround seems clumsy: import Tkinter as tk root = tk.Tk() canvas = tk.Canvas(root, width=400, height=200,...
1
by: Patrick | last post by:
Hi, The company's database has multiple schema. If I want to modify a stored procedure, which is saved as a script (something like abc.sql), I opened that script in Query Analyser, made the...
3
by: Sravani | last post by:
Hi, I am setting up a new server for an already running website. The problem is the person before me ran ASP scripts on .html extension pages (The old machine is a windows 2000 server with IIS...
4
by: Nick Sinclair | last post by:
Hi all, I'm new to C. I have successfully written a small C program that acts as a "wrapper" around cgi scripts. These scripts perform admin tasks such as backing up etc. Obviously, The need...
1
by: edovale | last post by:
Hi there, I am trying to create a db on db2 and when running the scripts, which have been successfully ran before, I get the following error: DB21034E The command was processed as an SQL...
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...
6
by: Ishpeck | last post by:
I'm using Python to automate testing software for my company. I wanted the computers in my testing lab to automatically fetch the latest version of the python scripts from a CVS repository and...
24
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...
22
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.