我正在尝试运行查询/作业,需要等到作业/查询完成后才能继续执行VB.NET应用程序中的下一行代码。我该怎么做?
con.Open()
Dim cmd As SqlCommand = New SqlCommand()
cmd.Connection = con
cmd.CommandText = "USE msdb; EXEC dbo.sp_start_job N'FWP1 Incremental Daily'"
cmd.CommandType = CommandType.Text
cmd.ExecuteNonQuery()
con.Close()
(WAIT UNTIL FINISHES) - How do I Code this???
\\Continue Code...........
答案 0 :(得分:0)
Application.UseWaitCursor = True
con.Open()
Dim cmd As SqlCommand = New SqlCommand()
cmd.Connection = con
cmd.CommandText = "USE msdb; EXEC dbo.sp_start_job N'FWP1 Incremental Daily'"
cmd.CommandType = CommandType.Text
cmd.ExecuteNonQuery()
con.Close()
Application.UseWaitCursor = False
MsgBox("Finished!")
希望这会有所帮助。