/// <Summary> /// obtain the names of all database instances with the specified IP address. /// </Summary> /// <Param name = "ip"> specifies the IP address. </Param> /// <Param name = "username"> username used to log on to the database. </Param> /// <Param name = "password"> password used to log on to the database. </Param> /// <returns> Returns a list of data instance names. </Returns> private arraylist getalldatabase (string IP, string username, string password) {arraylist dbnamelist = new arraylist (); sqlconnection connection = new sqlconnection (string. format ("Data Source = {0}; initial catalog = Master; user id = {1}; Pwd = {2}", IP, username, password )); datatable dbnametable = new datatable (); sqldataadapter adapter = new sqldataadapter ("Select name from master .. sysdatabases ", connection); lock (adapter) {adapter. fill (dbnametable);} foreach (datarow row in dbnametable. rows) {dbnamelist. add (row ["name"]);} return dbnamelist ;}