首先透過 sp_lock 去查詢被 Lock 的資料有哪些,
因為他不會直接列出 Table 名稱, 所以可透過select object_id('TABLE_NAME') 或是 select object_name('OBJECT_ID') 去查出該 Lock 是屬於哪個 Table 的
直接下kill spid...spid為sp_lock查出的第一個欄位
kill xxx
星期五, 9月 04, 2009
星期五, 7月 24, 2009
判斷IP是哪個國家的位址
http://www.maxmind.com/app/geoip_country
http://ip-to-country.webhosting.info/downloads/ip-to-country.csv.zip
這兩個網站可以下載到ip對應的國家..
但是
資料要自己從CSV匯入到SQL內
ip="168.95.1.1"
arr=split(ip)
sum = arr(0) * 16777216 + arr(1) * 65536 + arr(2) * 256 + arr(3)
SELECT country, name FROM ip_country WHERE sum BETWEEN begin_num AND end_num
http://ip-to-country.webhosting.info/downloads/ip-to-country.csv.zip
這兩個網站可以下載到ip對應的國家..
但是
資料要自己從CSV匯入到SQL內
ip="168.95.1.1"
arr=split(ip)
sum = arr(0) * 16777216 + arr(1) * 65536 + arr(2) * 256 + arr(3)
SELECT country, name FROM ip_country WHERE sum BETWEEN begin_num AND end_num
星期二, 5月 12, 2009
Error: Common Language Runtime...Application has generated an exception that could not be handled
The Microsoft .NET Framework 1.1 Cache must be cleared.
1. Go to the Control Panel.
2. Double-click Administrative Tools.
3. Double-click Microsoft .NET Framework 1.1 Configuration.
4. From the left panel, click Assembly Cache.
5. From the right panel, click View List of Assemblies...
6. CRTL+A 刪除全部
7. 重新執行程式
1. Go to the Control Panel.
2. Double-click Administrative Tools.
3. Double-click Microsoft .NET Framework 1.1 Configuration.
4. From the left panel, click Assembly Cache.
5. From the right panel, click View List of Assemblies...
6. CRTL+A 刪除全部
7. 重新執行程式
星期二, 1月 13, 2009
SqlDependency的設定方式
Private Delegate Sub UICallBack()
Private changeCnt As Integer
Private Sub getdata()
Dim cn As New SqlClient.SqlConnection("Data Source=localhost;Initial Catalog=MIS;Persist Security Info=True;User ID=sa;password=")
cn.Open()
Dim strSQL As String = "select test from dbo.tblTest where test>=2"
Dim da As New SqlClient.SqlDataAdapter(strSQL, cn)
Dim sqld As New SqlClient.SqlDependency(da.SelectCommand)
SqlDependency.Start(cn.ConnectionString)
ds.Clear()
da.Fill(ds, "test")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "test"
DataGridView1.Refresh()
AddHandler sqld.OnChange, AddressOf Me.dataChanged
End Sub
Private Sub rebind()
getdata()
lblmsg.Text = ds.Tables("test").Rows.Count
End Sub
Private Sub dataChanged(ByVal sender As Object, ByVal e As SqlNotificationEventArgs)
changeCnt += 1
Me.Invoke(New UICallBack(AddressOf rebind))
End Sub
主要不能使用*來選取所有欄位...並且一定要有where 篩選條件..
不然dataChanged會形成無窮迴圈
Private changeCnt As Integer
Private Sub getdata()
Dim cn As New SqlClient.SqlConnection("Data Source=localhost;Initial Catalog=MIS;Persist Security Info=True;User ID=sa;password=")
cn.Open()
Dim strSQL As String = "select test from dbo.tblTest where test>=2"
Dim da As New SqlClient.SqlDataAdapter(strSQL, cn)
Dim sqld As New SqlClient.SqlDependency(da.SelectCommand)
SqlDependency.Start(cn.ConnectionString)
ds.Clear()
da.Fill(ds, "test")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "test"
DataGridView1.Refresh()
AddHandler sqld.OnChange, AddressOf Me.dataChanged
End Sub
Private Sub rebind()
getdata()
lblmsg.Text = ds.Tables("test").Rows.Count
End Sub
Private Sub dataChanged(ByVal sender As Object, ByVal e As SqlNotificationEventArgs)
changeCnt += 1
Me.Invoke(New UICallBack(AddressOf rebind))
End Sub
主要不能使用*來選取所有欄位...並且一定要有where 篩選條件..
不然dataChanged會形成無窮迴圈
訂閱:
文章 (Atom)