public void DataAdapterUpdateReturnValue2() { var cmd = TheConnection.CreateCommand(); var da = new NpgsqlDataAdapter("select * from tabled", TheConnection); var cb = new NpgsqlCommandBuilder(da); var ds = new DataSet(); da.Fill(ds); //## Insert a new row with id = 1 ds.Tables[0].Rows.Add(new Object[] { 0.4, 0.5 }); da.Update(ds); //## change id from 1 to 2 cmd.CommandText = "update tabled set field_float4 = 0.8 where id = (select max(field_serial) from tabled)"; cmd.ExecuteNonQuery(); //## change value to newvalue ds.Tables[0].Rows[0][1] = 0.7; //## update should fail, and make a DBConcurrencyException var count = da.Update(ds); //## count is 1, even if the isn't updated in the database Assert.AreEqual(0, count); }
public void ChangeDatabase() { TheConnection.ChangeDatabase("template1"); var command = new NpgsqlCommand("select current_database()", TheConnection); var result = (String)command.ExecuteScalar(); Assert.AreEqual("template1", result); }
public void NestedTransaction() { var t = TheConnection.BeginTransaction(); if (t == null) { return; } }
public void CleansupOkWithDisposeCalls() { NpgsqlCommand command = new NpgsqlCommand("select * from tablea", TheConnection); using (NpgsqlDataReader dr = command.ExecuteReader()) { dr.Read(); dr.Close(); using (NpgsqlCommand upd = TheConnection.CreateCommand()) { upd.CommandText = "select * from tablea"; upd.Prepare(); } } }
public void GetSchemaParameterMarkerFormats() { var dt = TheConnection.GetSchema("DataSourceInformation"); var parameterMarkerFormat = (string)dt.Rows[0]["ParameterMarkerFormat"]; using (var connection = new NpgsqlConnection(TheConnectionString)) { connection.Open(); using (var command = connection.CreateCommand()) { const String parameterName = "p_field_int4"; command.CommandText = "SELECT * FROM tablea WHERE field_int4=" + String.Format(parameterMarkerFormat, parameterName); command.Parameters.Add(new NpgsqlParameter(parameterName, 4)); using (var reader = command.ExecuteReader()) { Assert.IsTrue(reader.Read()); // This is OK, when no exceptions are occurred. } } } }
public void SequencialTransaction() { TheTransaction.Rollback(); TheTransaction = TheConnection.BeginTransaction(); }
public void GetSchemaForeignKeys() { var dt = TheConnection.GetSchema("ForeignKeys"); Assert.IsNotNull(dt); }