public int executeProcedureWithParametersReturnInt(String query, Dictionary <String, Object> dictionary, Dictionary <String, Object> returnParams) { int res = 0; try { openConnection(); SqlCommand command = new SqlCommand(query, getConnectionString()); foreach (String key in dictionary.Keys) { command.Parameters.AddWithValue(key, dictionary[key]); } foreach (String key in returnParams.Keys) { command.Parameters.Add(key, dictionary[key]).Direction = ParameterDirection.Output; } command.CommandType = CommandType.StoredProcedure; command.ExecuteNonQuery(); closeConnection(); } catch (SqlException ex) { closeConnection(); SqlExceptionManager.handlerException(ex); } return((int)res); }
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); } }