private void ExecuteQuery() { if (CurrentDatabase != null && currentDatabase != String.Empty) { QueryResultStatusColor = "Blue"; QueryResultStatus = "Executing Query..!"; BusyStatus = Visibility.Visible; QueryResultStatusToolTip = QueryResultStatus; String connectionString = "Data Source=" + ServerName + ";Initial Catalog=" + CurrentDatabase; if (CreateConnectionString(connectionString)) { DataSet dbDataSet = new DataSet(); try { using (SqlConnection conn = new SqlConnection(ConnectionString)) { conn.Open(); using (SqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = QueryString.Trim(); cmd.CommandType = CommandType.Text; using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(dbDataSet); } } } if (!HoldLastResult || QueryAndResult == null) { QueryAndResult = new ObservableCollection <QueryResult>(); } QueryResult qr = new QueryResult(); qr.Server = ServerName; qr.Database = CurrentDatabase; qr.IsSQLAuthenticated = IsSqlAuthentication; if (IsSqlAuthentication) { qr.Password = Password; qr.Username = UserName; } qr.Query = QueryString.Trim(); qr.Result = dbDataSet.Tables[0].DefaultView; QueryAndResult.Add(qr); } catch (Exception ex) { FormatExceptionMessage(ex); return; } QueryResultStatusColor = "Green"; QueryResultStatus = "Query Executed Successfully..!"; BusyStatus = Visibility.Collapsed; QueryResultStatusToolTip = QueryResultStatus; } } }
private void ExecuteDelete(QueryResult parameter) { QueryAndResult.Remove(parameter); }