Пример #1
0
        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);
        }
Пример #2
0
 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);
     }
 }
Пример #3
0
 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);
     }
 }
Пример #4
0
        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);
            }
        }