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
Loading
Scott LyslePosted May 7, 2007, 3:46 AM
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