OracleDataAdapter fill method - Refill problem

G

Guest

I am using a DataGrid with a dataset and the
OracleDataAdapter.Fill(dataset,"Tablename") method. All is fine: a table is
created and mapped to the dataset and data is shown in the datagrid.

When I clear the table, dispose it and remove it from the dataset, and then
reload the same table with the fill statement, the datagrid shows (NULL)
although the debug output shows that there is a table mapped to the dataset
with populated rows. Although when I try to remove it again by index from the
DataSet, I get a NullPointerException - but the Table is present!

What am I missing?

Test-Code is like this:

namespace TestDsLoadClear
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

/// <summary>
/// DeleteButton
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
dataSet1.Tables[0].Clear();
dataSet1.Tables[0].Dispose();
dataSet1.Tables.RemoveAt(0);

button2.Enabled = false;
button1.Enabled = true;
}

/// <summary>
/// LoadButton
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
oracleDataAdapter1.Fill(dataSet1, "NewTable");
button1.Enabled = false;
button2.Enabled = true;
}
}
}
 
W

W.G. Ryan - MVP

MSPZZZ:

Before going further, is the methodology you're using something that you are
dead set on? Namely, do you need to remove the datatable, dispose of it
etc? I think based on the code that you couild just use Clear() and then
refill which should alleviate the problem. But if you have to do the
dispose thing and all, let me know and we'll take it from there.
 
G

Guest

Hi,

thx for reply. Indeed the datagrid and dataset are part of a huge
application for displaying time series data. Each time series is represented
by a datatable and the customer should be able to load and remove the curves
(tables) individually. So if one chooses to remove the table it should
disappear from the datagrid with the possibillity to re-load the same or
another time series again from database.
Removing the table from the dataset (and grit) is what the RemoveAt(index)
does, but it seems that this is not enough?
Would be obliged if you can give me a hint to get this work.


W.G. Ryan - MVP said:
MSPZZZ:

Before going further, is the methodology you're using something that you are
dead set on? Namely, do you need to remove the datatable, dispose of it
etc? I think based on the code that you couild just use Clear() and then
refill which should alleviate the problem. But if you have to do the
dispose thing and all, let me know and we'll take it from there.
mspzzz said:
I am using a DataGrid with a dataset and the
OracleDataAdapter.Fill(dataset,"Tablename") method. All is fine: a table
is
created and mapped to the dataset and data is shown in the datagrid.

When I clear the table, dispose it and remove it from the dataset, and
then
reload the same table with the fill statement, the datagrid shows (NULL)
although the debug output shows that there is a table mapped to the
dataset
with populated rows. Although when I try to remove it again by index from
the
DataSet, I get a NullPointerException - but the Table is present!

What am I missing?

Test-Code is like this:

namespace TestDsLoadClear
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

/// <summary>
/// DeleteButton
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
dataSet1.Tables[0].Clear();
dataSet1.Tables[0].Dispose();
dataSet1.Tables.RemoveAt(0);

button2.Enabled = false;
button1.Enabled = true;
}

/// <summary>
/// LoadButton
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
oracleDataAdapter1.Fill(dataSet1, "NewTable");
button1.Enabled = false;
button2.Enabled = true;
}
}
}
 
G

Guest

Still waiting for a solution! Anyone can comment on this problem?

W.G. Ryan - MVP said:
MSPZZZ:

Before going further, is the methodology you're using something that you are
dead set on? Namely, do you need to remove the datatable, dispose of it
etc? I think based on the code that you couild just use Clear() and then
refill which should alleviate the problem. But if you have to do the
dispose thing and all, let me know and we'll take it from there.
mspzzz said:
I am using a DataGrid with a dataset and the
OracleDataAdapter.Fill(dataset,"Tablename") method. All is fine: a table
is
created and mapped to the dataset and data is shown in the datagrid.

When I clear the table, dispose it and remove it from the dataset, and
then
reload the same table with the fill statement, the datagrid shows (NULL)
although the debug output shows that there is a table mapped to the
dataset
with populated rows. Although when I try to remove it again by index from
the
DataSet, I get a NullPointerException - but the Table is present!

What am I missing?

Test-Code is like this:

namespace TestDsLoadClear
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

/// <summary>
/// DeleteButton
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
dataSet1.Tables[0].Clear();
dataSet1.Tables[0].Dispose();
dataSet1.Tables.RemoveAt(0);

button2.Enabled = false;
button1.Enabled = true;
}

/// <summary>
/// LoadButton
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
oracleDataAdapter1.Fill(dataSet1, "NewTable");
button1.Enabled = false;
button2.Enabled = true;
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top