public void query(String query) { try { openConnection(); SqlCommand queryCommand = new SqlCommand(query, getConnectionString()); SqlDataReader queryCommandReader = queryCommand.ExecuteReader(); closeConnection(); } catch (SqlException ex) { closeConnection(); SqlExceptionManager.handlerException(ex); } }
public void executeQueryWithParameters(String query, Dictionary <String, Object> dictionary) { try { openConnection(); SqlCommand command = new SqlCommand(query, getConnectionString()); foreach (String key in dictionary.Keys) { command.Parameters.AddWithValue(key, dictionary[key]); } command.ExecuteNonQuery(); closeConnection(); } catch (SqlException ex) { closeConnection(); SqlExceptionManager.handlerException(ex); } }
public DataTable select_query(String query) { try { openConnection(); SqlCommand queryCommand = new SqlCommand(query, getConnectionString()); SqlDataReader queryCommandReader = queryCommand.ExecuteReader(); DataTable dataTable = new DataTable(); dataTable.Load(queryCommandReader); closeConnection(); return(dataTable); } catch (SqlException ex) { SqlExceptionManager.handlerException(ex); return(null); } }