PC Review


Reply
Thread Tools Rate Thread

DataTable refill problem

 
 
=?Utf-8?B?bXNwenp6?=
Guest
Posts: n/a
 
      20th Dec 2005
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? If anyone can verify this strange behaviour?

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;
}
}
}

 
Reply With Quote
 
 
 
 
Paul Clement
Guest
Posts: n/a
 
      20th Dec 2005
On Tue, 20 Dec 2005 02:27:04 -0800, mspzzz <(E-Mail Removed)> wrote:

¤ 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? If anyone can verify this strange behaviour?
¤
¤ 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;
¤ }
¤ }
¤ }

I don't believe the DataGrid will display any data until you set the DataSource property to the new
DataTable.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
=?Utf-8?B?bXNwenp6?=
Guest
Posts: n/a
 
      21st Dec 2005
The datasource property of the datagrid is set in the designer.

I expanded the form with a third button for switching the Datasource:


private void button3_Click(object sender, EventArgs e)
{
if (dataGrid1.DataSource == dataSet1)
{
dataGrid1.DataSource = dataSet1.Tables["NewTable"];

}
else
dataGrid1.DataSource = dataSet1;
}

If the datasource references directly to the datatable, data is shown. If it
references to the dataset, the tree is shown with "NewTable" but NewTable has
0 (1 row with NULL values) rows.

Why is this?? Plz help!!!


"Paul Clement" wrote:

> On Tue, 20 Dec 2005 02:27:04 -0800, mspzzz <(E-Mail Removed)> wrote:
>
> ¤ 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? If anyone can verify this strange behaviour?
> ¤
> ¤ 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;
> ¤ }
> ¤ }
> ¤ }
>
> I don't believe the DataGrid will display any data until you set the DataSource property to the new
> DataTable.
>
>
> Paul
> ~~~~
> Microsoft MVP (Visual Basic)
>

 
Reply With Quote
 
Paul Clement
Guest
Posts: n/a
 
      22nd Dec 2005
On Wed, 21 Dec 2005 04:39:02 -0800, mspzzz <(E-Mail Removed)> wrote:

¤ The datasource property of the datagrid is set in the designer.
¤
¤ I expanded the form with a third button for switching the Datasource:
¤
¤
¤ private void button3_Click(object sender, EventArgs e)
¤ {
¤ if (dataGrid1.DataSource == dataSet1)
¤ {
¤ dataGrid1.DataSource = dataSet1.Tables["NewTable"];
¤
¤ }
¤ else
¤ dataGrid1.DataSource = dataSet1;
¤ }
¤
¤ If the datasource references directly to the datatable, data is shown. If it
¤ references to the dataset, the tree is shown with "NewTable" but NewTable has
¤ 0 (1 row with NULL values) rows.
¤
¤ Why is this?? Plz help!!!
¤

Setting the DataSource property to a DataSet is actually setting it to all DataTables in the
DataSet. That is why you get a TreeView display. It's allowing you to select amongst all the
DataTables in your DataSet.

If you want to see data immediately then you need to set the DataSource to a specific DataTable.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
=?Utf-8?B?bXNwenp6?=
Guest
Posts: n/a
 
      22nd Dec 2005
Paul,

this is not the question. The problem is that if I click on the tree to
select the "newTable", "newTable" has 0 Rows (only after removing and
re-loading). If you bind to "newTable" directly, you see rows. Don't believe
it? Try it!!

"Paul Clement" wrote:

> On Wed, 21 Dec 2005 04:39:02 -0800, mspzzz <(E-Mail Removed)> wrote:
>
> ¤ The datasource property of the datagrid is set in the designer.
> ¤
> ¤ I expanded the form with a third button for switching the Datasource:
> ¤
> ¤
> ¤ private void button3_Click(object sender, EventArgs e)
> ¤ {
> ¤ if (dataGrid1.DataSource == dataSet1)
> ¤ {
> ¤ dataGrid1.DataSource = dataSet1.Tables["NewTable"];
> ¤
> ¤ }
> ¤ else
> ¤ dataGrid1.DataSource = dataSet1;
> ¤ }
> ¤
> ¤ If the datasource references directly to the datatable, data is shown. If it
> ¤ references to the dataset, the tree is shown with "NewTable" but NewTable has
> ¤ 0 (1 row with NULL values) rows.
> ¤
> ¤ Why is this?? Plz help!!!
> ¤
>
> Setting the DataSource property to a DataSet is actually setting it to all DataTables in the
> DataSet. That is why you get a TreeView display. It's allowing you to select amongst all the
> DataTables in your DataSet.
>
> If you want to see data immediately then you need to set the DataSource to a specific DataTable.
>
>
> Paul
> ~~~~
> Microsoft MVP (Visual Basic)
>

 
Reply With Quote
 
Paul Clement
Guest
Posts: n/a
 
      23rd Dec 2005
On Thu, 22 Dec 2005 09:03:01 -0800, mspzzz <(E-Mail Removed)> wrote:

¤ Paul,
¤
¤ this is not the question. The problem is that if I click on the tree to
¤ select the "newTable", "newTable" has 0 Rows (only after removing and
¤ re-loading). If you bind to "newTable" directly, you see rows. Don't believe
¤ it? Try it!!
¤

I can't reproduce this problem. I am seeing the data I expect.

Did you check the underlying DataTable in the DataSet to make certain that is contains the data you
are expecting?

Which version of Visual Studio are you using?


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
=?Utf-8?B?bXNwenp6?=
Guest
Posts: n/a
 
      23rd Dec 2005
I am using VS2005 and C#, but I had the same problem in VS2003. Did you use
the OracleDataAdaptor? And did you Clear and Dispose? Maybe I should test the
same with SQL or OLEDB.


Before I do this:
dataSet1.Tables[0].Clear();
dataSet1.Tables[0].Dispose();
dataSet1.Tables.RemoveAt(0);
dataGrid1.DataSource = dataSet1;
oracleDataAdapter1.Fill(dataSet1, "newTable");

I see data when DataSource is set to dataSet1 or "newTable". Of course I
debugged the sample but even after executing the 5 lines above debug is:
dataSet1.Tables+Non-Public members+List+[0]+Rows+Count=95
and
dataSet1.Tables+Non-Public members+List+[0]+Rows+TableName="newTable"

but no Rows are shown when datasource is set to dataset1.

Very strange.




"Paul Clement" wrote:

> On Thu, 22 Dec 2005 09:03:01 -0800, mspzzz <(E-Mail Removed)> wrote:
>
> I can't reproduce this problem. I am seeing the data I expect.
>
> Did you check the underlying DataTable in the DataSet to make certain that is contains the data you
> are expecting?
>
> Which version of Visual Studio are you using?
>
>
> Paul
> ~~~~
> Microsoft MVP (Visual Basic)
>

 
Reply With Quote
 
Paul Clement
Guest
Posts: n/a
 
      23rd Dec 2005
On Fri, 23 Dec 2005 08:17:02 -0800, mspzzz <(E-Mail Removed)> wrote:

¤ I am using VS2005 and C#, but I had the same problem in VS2003. Did you use
¤ the OracleDataAdaptor? And did you Clear and Dispose? Maybe I should test the
¤ same with SQL or OLEDB.
¤
¤
¤ Before I do this:
¤ dataSet1.Tables[0].Clear();
¤ dataSet1.Tables[0].Dispose();
¤ dataSet1.Tables.RemoveAt(0);
¤ dataGrid1.DataSource = dataSet1;
¤ oracleDataAdapter1.Fill(dataSet1, "newTable");
¤
¤ I see data when DataSource is set to dataSet1 or "newTable". Of course I
¤ debugged the sample but even after executing the 5 lines above debug is:
¤ dataSet1.Tables+Non-Public members+List+[0]+Rows+Count=95
¤ and
¤ dataSet1.Tables+Non-Public members+List+[0]+Rows+TableName="newTable"
¤
¤ but no Rows are shown when datasource is set to dataset1.
¤
¤ Very strange.

I didn't use the Oracle provider but I will give that a try.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
Paul Clement
Guest
Posts: n/a
 
      28th Dec 2005
On Fri, 23 Dec 2005 08:17:02 -0800, mspzzz <(E-Mail Removed)> wrote:

¤ I am using VS2005 and C#, but I had the same problem in VS2003. Did you use
¤ the OracleDataAdaptor? And did you Clear and Dispose? Maybe I should test the
¤ same with SQL or OLEDB.
¤

I was able to repro this issue under C#. I'm taking a closer look to see if there is a reason for
this behavior.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Samsung Laser Refill Problem, HP 1018 any better for refill? lbbss Printers 10 12th Oct 2007 10:37 AM
Minolta 2300DL Still looking for actual toner refill experiences refill Tom Printers 1 4th Nov 2005 06:27 PM
Clone DataTable or Copy DataTable Problem Kelvin Microsoft C# .NET 0 13th Dec 2004 07:55 AM
refill ink problem Trev Printers 4 20th Jan 2004 08:37 PM
now anyone a good compatible refill kit or refill ink for HP designjet 100 zegrea Printers 1 19th Aug 2003 08:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:19 PM.