Re: How To Execute A Sql Script File From ADO.NET Using VB.NET

From: Lloyd Sheen (sqlguyremoveallofthis_at_tostopspamhotmail.com)
Date: 05/17/04


Date: Mon, 17 May 2004 16:26:17 GMT

You will have to break up the script into it's portions. Remember that GO
is not a T-SQL word. If you know that each GO is on its own line then you
can split the text. Then execute each set of commands within the batch. If
you are expecting no results then use the SQLCommand.ExecuteNonQuery, this
will return the row count.

Ensure that you wrap the execution to ensure that errors are caught. If you
have PRINT statements you will have to capture the InfoMessage event of the
open connection.

Lloyd Sheen

"SqlJunkies User" <User@-NOSPAM-SqlJunkies.com> wrote in message
news:e5C$hZCPEHA.2976@TK2MSFTNGP10.phx.gbl...
> I have a sql script file containing a number of batch commands to create a
new database with 50 tables. Is there anyway i can use ado.net to open this
file and execute the sql command in side in a batch format. Basically I
would like to execute the myscriptfile.sql from vb.net using ado.net
>
> ---
> Posted using Wimdows.net NntpNews Component -
>
> Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine
supports Post Alerts, Ratings, and Searching.



Relevant Pages

  • Re: head, recursively through file tree?
    ... What's the problem with running a shell or perl inline script ... | child-process to execute the user's commands. ... the shell forks a process for every command it runs unless ...
    (comp.unix.shell)
  • Re: making a script
    ... batch command: executed successfully. ... I have used gimp's batch processing only slightly, ... You are using the batch mode to execute a scheme script ...
    (comp.graphics.apps.gimp)
  • Re: Is It Scripting or Not
    ... I'm considering VB Script. ... Many tasks that can be done using batch scripts or directly from the command ... reasonably be carried out with a series of batch commands. ... run backup batch file for computer backups ...
    (microsoft.public.scripting.vbscript)
  • Re: Maby a litle OT but: apache+sh CGI script
    ... that the http user is added to sudoers and may execute only ... thouse commands that it realy needs for the script. ... it's safer then giving apache full root priv. ...
    (comp.os.linux.security)
  • Re: Maby a litle OT but: apache+sh CGI script
    ... that the http user is added to sudoers and may execute only ... thouse commands that it realy needs for the script. ... it's safer then giving apache full root priv. ...
    (comp.os.linux.security)