Beispiel #1
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);
     }
 }
Beispiel #2
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);
     }
 }
Beispiel #3
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);
            }
        }