Hi,
I'm trying to populate a tooltip with a list of users connected to a database when hovering over an row in a ListView.
I'm using sysprocesses to show a list of databases and the connections, how do I tie this together?
select loginame, hostname, blocked, db_name(dbid) from master..sysprocesses where db_name(dbid
I've attached a mock-up image of what I'm trying to achieve, is this possible?
Thanks.
Private Sub LVDatabases_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LVDatabases.ItemMouseHover
ToolTip1.SetToolTip(CurrentDatabaseUsers(SQLServerName, Instance, LVDatabases.HoverSelection(0).Text))
End Sub
Function CurrentDatabaseUsers(ByVal Server As String, ByVal Instance As String, ByVal Database As String)
Dim mySqlConnection As New SqlConnection("server=" + Server + "\" + Instance + ";uid=sa;pwd=pwd;database=" + Database)
Dim mySqlCommand As SqlCommand = mySqlConnection.CreateCommand()
mySqlCommand.CommandText = "select loginame, hostname, blocked, db_name(dbid) from master..sysprocesses where db_name(dbid) = '" & Database & "';"
mySqlConnection.Open()
Dim mySqlDataReader As String = CType(mySqlCommand.ExecuteScalar(), String)
mySqlConnection.Close()
Return mySqlDataReader
End Function