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); }
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. } }
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. } }