예제 #1
0
 public MySqlDataAdapter(MySqlDataAdapter 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;
     
 }
예제 #2
0
 /// <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)
 {
   MySqlConnection cn = new MySqlConnection(connectionString);
   cn.Open();
   MySqlDataAdapter da = new MySqlDataAdapter(commandText, cn);
   MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
   cb.ToString();
   da.Update(ds, tablename);
   cn.Close();
 }
예제 #3
0
 /// <include file='docs/MySqlCommandBuilder.xml' path='docs/Ctor2/*'/>
 public MySqlCommandBuilder(MySqlDataAdapter adapter)
   : this()
 {
     DataAdapter = adapter;
 }
예제 #4
0
    /// <summary>
    /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.  
    /// The state of the <see cref="MySqlConnection"/> object remains unchanged after execution
    /// of this method.
    /// </summary>
    /// <param name="connection"><see cref="MySqlConnection"/> 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(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters)
    {
      //create a command and prepare it for execution
      MySqlCommand cmd = new MySqlCommand();
      cmd.Connection = connection;
      cmd.CommandText = commandText;
      cmd.CommandType = CommandType.Text;

      if (commandParameters != null)
        foreach (MySqlParameter p in commandParameters)
          cmd.Parameters.Add(p);

      //create the DataAdapter & DataSet
      MySqlDataAdapter da = new MySqlDataAdapter(cmd);
      DataSet ds = new DataSet();

      //fill the DataSet using default values for DataTable names, etc.
      da.Fill(ds);

      // detach the MySqlParameters from the command object, so they can be used again.			
      cmd.Parameters.Clear();

      //return the dataset
      return ds;
    }