Executing a SQL Script

  • Thread starter Thread starter Bruce Hodge
  • Start date Start date
B

Bruce Hodge

Hi All,

We've got some complex configuration scripts that we need to run against a
S2K database, they configure our application. For a number of reasons we
want to run them from within .Net. At the moment we Open the file from C#
read in the text to a string variable and then pass it to SQL for
processing. A typical file would be

Declare @AccountID

Select @AccountID = AccountID
From TAccounts
Where [Name] = 'Test Account'

Exec add_config_data @AccountID = @AccountID, @Code='TT',
@Description='TestCode'
Exec add_config_data @AccountID = @AccountID, @Code='TT2',
@Description='TestCode2'

The problem we have is how to run this script using ADO.Net. For other
scripts such as Table Update files we've been able to split the string into
executable chunks then exec them using a Command object, but that won't work
for above. Thoughts/Help appreciated.

Regards


Bruce H
 
Back
Top