Пример #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="commandText"></param>
        /// <returns></returns>
        public static DataSet ExecuteDataSet(string connectionString, string commandText)
        {
            DataSet ds;

            using (var connection = new MonetDbConnection(connectionString))
            {
                connection.Open();

                using (var command = new MonetDbCommand(connection)
                {
                    CommandText = commandText
                })
                {
                    using (var reader = command.ExecuteReader())
                    {
                        ds = reader.ToDateSet();
                    }
                }

                connection.Close();
            }

            return ds;
        }
Пример #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="commandText"></param> 
        /// <returns></returns>
        public static IDataReader ExecuteReader(string connectionString, string commandText)
        {
            var connection = new MonetDbConnection(connectionString);

            connection.Open();

            var command = new MonetDbCommand(connection)
            {
                CommandText = commandText
            };

            return command.ExecuteReader();
        }
Пример #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="commandText"></param>
        /// <returns></returns>
        public static object ExecuteScalar(string connectionString, string commandText)
        {
            object result;

            using (var connection = new MonetDbConnection(connectionString))
            {
                connection.Open();

                using (var command = new MonetDbCommand(connection)
                {
                    CommandText = commandText
                })
                {
                    result = command.ExecuteScalar();
                }

                connection.Close();
            }

            return result;
        }
Пример #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="commandText"></param>
        /// <returns></returns>
        public static int ExecuteNonQuery(string connectionString, string commandText)
        {
            int result;

            using (var connection = new MonetDbConnection(connectionString))
            {
                connection.Open();

                using (var command = new MonetDbCommand(connection)
                {
                    CommandText = commandText
                })
                {
                    result = command.ExecuteNonQuery();
                }

                connection.Close();
            }

            return result;
        }