I'm doing an insert then a select with oracleclient in c#. The direct query to the database returns me this:
However, when I do the select from a windows forms app, it returns the following:
The query is not being made from sql because the tables have different names and in the case of sql it brings the data well:
As you can see, it doesn't bring me the rows that have the null date in the database, why does this happen? The code is this:
private async Task cargar(string c)
{
string sentencia = "";
DataTable dt=new DataTable();
switch (c)
{
case "SQL":
sentencia = "select * from pushes";
using (var con = new SqlConnection("Server=zzzz;Initial Catalog=zz;User Id=zzz;Password=zzzz;"))
{
await con.OpenAsync();
SqlDataAdapter adapt = new SqlDataAdapter(sentencia,con);
adapt.Fill(dt);
dataGridView1.DataSource = dt;
}
break;
case "ORACLE":
sentencia = "select * from departamentos";
List<departamentos> depas = new List<departamentos>();
List<object> objetos = new List<object>();
using (var con = new OracleConnection("Data Source=zzzzz/test;User Id=zzzz;Password=zz;"))
{
await con.OpenAsync();
OracleDataAdapter adapt = new OracleDataAdapter(sentencia,con);
adapt.Fill(dt);
}
dataGridView1.DataSource = dt;
break;
default:
break;
}
}
To do the insert I use this code:
case "ORACLE":
sentencia = "INSERT INTO departamentos (depto_id,nombre,localidad,fecha_creacion)" +
" VALUES" +
"(:depto,:nombre,:local,:fecha)";
using (var con = new OracleConnection("Data Source=localhost:1521/test;User Id=system;Password=sa;"))
{
await con.OpenAsync();
using (var comando = new OracleCommand(sentencia, con))
{
comando.Parameters.Add("depto", 2);
comando.Parameters.Add("nombre", "oracle");
comando.Parameters.Add("local", "oracle");
comando.Parameters.Add("fecha", DateTime.Now);
var reader = await comando.ExecuteReaderAsync();
}
}
await cargar(comboBox1.Text);
When you work with Oracle from an administration tool you need to confirm the operations because otherwise they are pending in a transaction
Use the SQL Worksheet in SQL Developer to Insert, Update and Delete Data
can you write the line
at the end of any insert, update, or delete operations you perform
Or you can use the button
that is displayed in the image