Exemplo n.º 1
0
        public override object ExecuteScalar(string cmd)
        {
            Debug.Assert(this.DbFlavor == DbFlavor.SqlCE);

            if (cmd == null || cmd.Trim().Length == 0)
            {
                return(null);
            }

            this.AppendLog(cmd);

            object result = null;

            try
            {
                Connect();
                using (DbCommand command = SqlCeFactory.CreateSqlCeCommand(cmd, this.sqlCEConnection))
                {
                    result = command.ExecuteScalar();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error executing SQL \"" + cmd + "\"\n" + ex.Message);
            }
            return(result);
        }
Exemplo n.º 2
0
        public override IDataReader ExecuteReader(string cmd)
        {
            Debug.Assert(this.DbFlavor == DbFlavor.SqlCE);

            this.AppendLog(cmd);

            try
            {
                Connect();
                using (DbCommand command = SqlCeFactory.CreateSqlCeCommand(cmd, this.sqlCEConnection))
                {
                    return(command.ExecuteReader());
                }
            }
            catch (Exception)
            {
                throw; // useful for setting breakpoints.
            }
        }
Exemplo n.º 3
0
        public override void ExecuteNonQuery(string cmd)
        {
            Debug.Assert(this.DbFlavor == DbFlavor.SqlCE);
            if (cmd == null || cmd.Trim().Length == 0)
            {
                return;
            }

            this.AppendLog(cmd);
            try
            {
                Connect();
                using (DbCommand command = SqlCeFactory.CreateSqlCeCommand(cmd, this.sqlCEConnection))
                {
                    command.ExecuteNonQuery();
                }
            }
            catch (Exception)
            {
                throw; // useful for setting breakpoints.
            }
        }