/// <summary> /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>. /// The state of the <see cref="MyCatConnection"/> object remains unchanged after execution /// of this method. /// </summary> /// <param name="connection"><see cref="MyCatConnection"/> object to use</param> /// <param name="commandText">Command to execute</param> /// <param name="commandParameters">Parameters to use for the command</param> /// <returns><see cref="DataSet"/> containing the resultset</returns> public static DataSet ExecuteDataset(MyCatConnection connection, string commandText, params MyCatParameter[] commandParameters) { //create a command and prepare it for execution MyCatCommand cmd = new MyCatCommand(); cmd.Connection = connection; cmd.CommandText = commandText; cmd.CommandType = CommandType.Text; if (commandParameters != null) { foreach (MyCatParameter p in commandParameters) { cmd.Parameters.Add(p); } } //create the DataAdapter & DataSet MyCatDataAdapter da = new MyCatDataAdapter(cmd); DataSet ds = new DataSet(); //fill the DataSet using default values for DataTable names, etc. da.Fill(ds); // detach the MyCatParameters from the command object, so they can be used again. cmd.Parameters.Clear(); //return the dataset return(ds); }
public MyCatDataAdapter(MyCatDataAdapter from) { this.DeleteCommand = from.DeleteCommand; this.InsertCommand = from.InsertCommand; this.SelectCommand = from.SelectCommand; this.UpdateCommand = from.UpdateCommand; this.UpdateBatchSize = from.UpdateBatchSize; this.AcceptChangesDuringFill = from.AcceptChangesDuringFill; this.AcceptChangesDuringUpdate = from.AcceptChangesDuringUpdate; }
/// <summary> /// Updates the given table with data from the given <see cref="DataSet"/> /// </summary> /// <param name="connectionString">Settings to use for the update</param> /// <param name="commandText">Command text to use for the update</param> /// <param name="ds"><see cref="DataSet"/> containing the new data to use in the update</param> /// <param name="tablename">Tablename in the dataset to update</param> public static void UpdateDataSet(string connectionString, string commandText, DataSet ds, string tablename) { MyCatConnection cn = new MyCatConnection(connectionString); cn.Open(); MyCatDataAdapter da = new MyCatDataAdapter(commandText, cn); MyCatCommandBuilder cb = new MyCatCommandBuilder(da); cb.ToString(); da.Update(ds, tablename); cn.Close(); }
protected override void SetRowUpdatingHandler(DbDataAdapter adapter) { MyCatDataAdapter myAdapter = (adapter as MyCatDataAdapter); if (adapter != base.DataAdapter) { myAdapter.RowUpdating += new MyCatRowUpdatingEventHandler(RowUpdating); } else { myAdapter.RowUpdating -= new MyCatRowUpdatingEventHandler(RowUpdating); } }
/// <include file='docs/MyCatCommandBuilder.xml' path='docs/Ctor2/*'/> public MyCatCommandBuilder(MyCatDataAdapter adapter) : this() { DataAdapter = adapter; }