/// <summary> /// Capture the selected macro variables as a series /// of LET statements, to provide a simple template /// for setting these values within a program. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnCopyMacroAssignments(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); foreach (ListViewItem lvi in lvMacros.SelectedItems) { MacroVar mv = lvi.Tag as MacroVar; if (mv != null) { if (mv.Scope == "AUTOMATIC") { sb.AppendFormat("/* AUTOMATIC variable {0} */\n%let {0} = {1};\n", mv.Name, mv.CurrentValue); } else { sb.AppendFormat("%let {0} = {1}; \n", mv.Name, mv.CurrentValue); } } } try { Clipboard.SetData(System.Windows.Forms.DataFormats.Text, sb.ToString()); } catch { } }
/// <summary> /// Query to retrieve the macro values from the active server /// </summary> private void RetrieveMacroValues() { SasServer s = cmbServers.SelectedItem as SasServer; using (System.Data.OleDb.OleDbConnection dbConnection = s.GetOleDbConnection()) { //----- make provider connection dbConnection.Open(); //----- Read values from query command string sql = @"select * from sashelp.vmacro order by name"; OleDbCommand cmdDB = new OleDbCommand(sql, dbConnection); OleDbDataReader dataReader = cmdDB.ExecuteReader(CommandBehavior.CloseConnection); try { MacroVars = new List <MacroVar>(); while (dataReader.Read()) { MacroVar var = new MacroVar() { Name = dataReader["name"].ToString(), CurrentValue = dataReader["value"].ToString(), Scope = dataReader["scope"].ToString() }; MacroVars.Add(var); } } finally { dataReader.Close(); dbConnection.Close(); } } }
/// <summary> /// Query to retrieve the macro values from the active server /// </summary> private void RetrieveMacroValues() { SasServer s = cmbServers.SelectedItem as SasServer; using (System.Data.OleDb.OleDbConnection dbConnection = s.GetOleDbConnection()) { //----- make provider connection dbConnection.Open(); //----- Read values from query command string sql = @"select * from sashelp.vmacro order by name"; OleDbCommand cmdDB = new OleDbCommand(sql, dbConnection); OleDbDataReader dataReader = cmdDB.ExecuteReader(CommandBehavior.CloseConnection); try { MacroVars = new List<MacroVar>(); while (dataReader.Read()) { MacroVar var = new MacroVar() { Name = dataReader["name"].ToString(), CurrentValue = dataReader["value"].ToString(), Scope = dataReader["scope"].ToString() }; MacroVars.Add(var); } } finally { dataReader.Close(); dbConnection.Close(); } } }