sql - Data Reader formatting output -


I am using the following function to create a list of users connected to the selected database. How do I change it for more than one similar result? for example:? - rather than listing "MyComputer bit (3)" "sa - MyComputer" three times

  function ConnectedUsers (ByVal SelectedDatabase String, ByVal SelectedInstance dim dim myCommand SqlCommand as as string) Dr. SqlDataReader dim try new SqlConnection (ConnectionString) myConn.Open (as mystring as string = String.Empty dim myConn) myCommand = new SqlCommand as ( "loginame, select the host name from sysprocesses where db_name (DBID) = '' & amp; SelectedDatabase & amp; ",", myConn) Dr = myCommand.ExecuteReader () while dr.Read () mystring + = GetFullName (Dr (0) KToString () trim ()) & Amp. - "&" (1). Artificial () and; vbCrLf End while DrkClose () MyConnkClose () Catch e exception MessageBox.Show (e.Message) Try End Return mystring as end function  

Thank you.

SQL commands must be

  select loginame, count ( *) As NBR, sysprocesses with hostname where db_name (DBID) = '' & amp; SelectedDatabase & amp; "Something like:" group by loginame, " 

and you should change the performance (NBR in this example) to show the count:

  Mystring + = GetFullName (DR (0) .ToString () trim ().) & Amp; "(" & Amp; Dr (1) .Trim () & amp; ") -" & amp; Dr. (2) .Trim () and vbCrLf  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -