public void CreateDatabase() { var connectionstringBuilder = new SqlProviderConnectionStringBuilder { DataSource = this.DataSource, UserID = this.UserID, Password = this.Password, IntegratedSecurity = this.IntegratedSecurity }; CreateDatabase(connectionstringBuilder.ConnectionString); }
public async Task <List <string> > ListDatabase(string server, string userID, string password, bool integratedSecurity) { var connectionstringBuilder = new SqlProviderConnectionStringBuilder { DataSource = server, UserID = userID, Password = password, IntegratedSecurity = integratedSecurity }; var dbList = new List <string>(); return(await Task.Run( () => { try { using (SqlConnection con = new SqlConnection(connectionstringBuilder.ConnectionString)) { con.Open(); using (SqlCommand cmd = new SqlCommand("SELECT * from sys.databases where database_id > 6", con)) { using (IDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { dbList.Add(dr[0].ToString()); } } } } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); } return dbList; })); }