public void TestWithClosedConnection() { Connection.Close(); FbCommandBuilder builder = new FbCommandBuilder(adapter); Console.WriteLine(); Console.WriteLine("CommandBuilder - RefreshSchema Method Test - Commands for original SQL statement: "); Console.WriteLine(builder.GetInsertCommand().CommandText); Console.WriteLine(builder.GetUpdateCommand().CommandText); Console.WriteLine(builder.GetDeleteCommand().CommandText); adapter.SelectCommand.CommandText = "select * from TEST where BIGINT_FIELD = ?"; builder.RefreshSchema(); Console.WriteLine(); Console.WriteLine("CommandBuilder - RefreshSchema Method Test - Commands for new SQL statement: "); Console.WriteLine(builder.GetInsertCommand().CommandText); Console.WriteLine(builder.GetUpdateCommand().CommandText); Console.WriteLine(builder.GetDeleteCommand().CommandText); builder.Dispose(); }
/// <summary> /// Saves a dataset's datatable to the database using the values /// specified when db provider was created /// </summary> /// <param name="tableName"></param> /// <param name="dataTable"></param> public int SaveDataTableSetRowState(string tableName, DataTable dataTable) { CheckDisposedState(); int recordsAffected = 0; //Create a data adapter to read Firebird schema for the table. this.NewDataAdapterWithSelect(tableName); this.DataAdapater.FillLoadOption = LoadOption.OverwriteChanges; FbCommandBuilder cmdBuilder = new FbCommandBuilder(this.DataAdapater); DataTable table = new DataTable(); this.DataAdapater.Fill(table); cmdBuilder.RefreshSchema(); table.TableName = dataTable.TableName; foreach (DataRow row in dataTable.Rows) { if (row.RowState == DataRowState.Unchanged) row.SetAdded(); table.ImportRow(row); } try { recordsAffected = this.DataAdapater.Update(table); } catch { throw new Exception(); } return recordsAffected; }