/// <summary> /// Run EA SQL Query with Exception handling /// <para/>return null if error, it also displays the error message in MessageBox /// <para/>return "" if nothing found /// <para/>return xml string if ok /// </summary> /// <returns>string</returns> public bool SqlExecuteWithException(string sql) { // delete an existing error file SqlError.DeleteEaSqlError(); try { // run the query (select * .. from sql = FormatSql(sql); // store final/last query which is executed SqlError.WriteHoToolsLastSql(sql); Repository.Execute(sql); if (!SqlError.ExistsEaSqlErrorFile()) { return(true); } else { MessageBox.Show(SqlError.ReadEaSqlError(), @"Error SQL (CTRL+C to copy it!!)"); return(false); } } catch (Exception ex) { MessageBox.Show($@"SQL:{Environment.NewLine}{sql}{Environment.NewLine}{ex.Message}", @"Error SQL"); return(false); } }
/// <summary> /// EA Execute SQL: /// - formatSQL /// - runSQL /// - return SQL string /// </summary> /// <returns>false=error</returns> public bool SqlExecuteNative(string sqlExecute) { sqlExecute = FormatSql(sqlExecute); // store final/last query which is executed SqlError.WriteHoToolsLastSql(sqlExecute); return(ExecuteSql(sqlExecute)); // no error, only no result rows }
/// <summary> /// EA SQL Query native with: /// - formatSQL /// - runSQL /// - return SQL string /// </summary> /// <param name="sqlQuery"></param> /// <returns>string</returns> public string SqlQueryNative(string sqlQuery) { sqlQuery = FormatSql(sqlQuery); // store final/last query which is executed SqlError.WriteHoToolsLastSql(sqlQuery); return(Repository.SQLQuery(sqlQuery)); // no error, only no result rows }