hi
im hoping someone can give me a point on how to execute an sql script from within vb.net
im hoping its something simple like just directing the file to the connection but havnt found anything to back this up.
do i need to read the sql script into a string and then deal to it?
any help appreciated
confused daniel
Executing an sql script in vb.net
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Scott LysleRank #49 · 31K reputationPosted May 6, 2007, 11:46 PM EDT
Imports
Microsoft.SqlServerImports Microsoft.SqlServer.Management.Smo
Imports System.IO
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim sr As StreamReader = New StreamReader("C:\Scripts\somescript.sql")
Dim somescript As String = sr.ReadToEnd
Dim SMOServer As Management.Smo.Server = New Management.Smo.Server
Dim db As Database = SMOServer.Databases("somedatabase")
db.ExecuteNonQuery(somescript)
End Sub
End
Class