vb.net kil掉SQL数据库进程不生效
Dim strConnection As String = "data source=WIN-8J5UO9K1ULN; initial catalog=master;integrated security=SSPI"Dim sqlConnection1 As New SqlConnection(strConnection)
Dim dataAdapter As New SqlDataAdapter
Dim dst As New DataSet
Dim dt As New DataTable
sqlConnection1.Open() '打开数据库
Dim sql As String = "select spid from sysprocesses where dbid=db_id('财务管理数据库') "
Dim cmd As SqlCommand = New SqlCommand(sql, sqlConnection1)
dataAdapter.SelectCommand = cmd
dataAdapter.Fill(dst, "sysprocesses")
dt = dst.Tables("sysprocesses")
sqlConnection1.Close() '关闭数据库
DataGridView1.AutoGenerateColumns = True '自动创建列
DataGridView1.DataSource = dt
Try
cn = New SqlConnection("data source=WIN-8J5UO9K1ULN; initial catalog=master;integrated security=SSPI")
cn.Open()
If DataGridView1.RowCount > 1 Then
For b = 0 To DataGridView1.RowCount - 1
a = DataGridView1.Rows(b).Cells(0).Value.ToString()
cm = New SqlCommand("kilL '" + a + "'", cn)
MsgBox(a)
MsgBox(DataGridView1.RowCount)
Next
cm.ExecuteNonQuery()
cn.Close()
End If
Catch ex As Exception
End Try
Try
cn = New SqlConnection("data source=WIN-8J5UO9K1ULN; initial catalog=master;integrated security=SSPI")
cn.Open()
cm = New SqlCommand("DROP DATABASE 财务管理数据库", cn)
cm.ExecuteNonQuery()
cn.Close()
Catch ex As Exception
End Try
'Try
' cn = New SqlConnection("data source=WIN-8J5UO9K1ULN; initial catalog=master;integrated security=SSPI")
' cn.Open()
' cm = New SqlCommand("restore database 财务管理数据库 from disk='E:\锱铢财务管理数据库备份文件' with replace ", cn)
' cm.ExecuteNonQuery()
' cn.Close()
'Catch ex As Exception
'End Try
KILL进程部分无效???????????????????????????????????????? vb.net KILL进程 SQL数据库 数据备份恢复 求教各位大神
快来帮帮忙啊 楼主要是改变一下提问的技巧,估计会有大侠出手的.....
补充:VB , 网络编程