473,847 Members | 1,472 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Typed Dataset problem

Bob
Hi,
I have a typed unbound dataset that is passed to a datahandling class to be
filled.
The datahandling class fills it from a sproc using an oledbDataAdapte r
(SQLAnywhere database)
The only table in the dataset has two int32 columns.
There is one row of data and as expected, column 0 contains an int and
column 1 contains a null.
I want to update column1.
The following code executes but the row cell remains unchanged.
I cannot see how an assignment statement can execute without error and the
target remain unchanged.
This in itself seems a bug.
I thought it may have been related to there being a null in the field but
the same thing happens when I try to change the value of the column0.
Can anyone see what is wrong?
thanks
Bob
private void button1_Click(o bject sender, EventArgs e)

{

dsBatchAssignab le ds =new dsBatchAssignab le();// Typed dataset with two int
fields

if (mDt.GetAssigna bleBatches(ds))

{

if ((int)ds.Tables[0].Rows[0].ItemArray[0] ==805) //Proving that table has
been filled.

ds.Tables[0].Rows[0].ItemArray[1] = "3"; //inspection shows System.DBNull
value (expected) before AND AFTER assignment.

if (ds.HasChanges( ))

MessageBox.Show ("Altered"); //Dont get here

}

}



May 24 '06 #1
7 1802
On Wed, 24 May 2006 23:32:54 +1200, "Bob" <bo*@nowhere.co m> wrote:
Hi,
I have a typed unbound dataset that is passed to a datahandling class to be
filled.
The datahandling class fills it from a sproc using an oledbDataAdapte r
(SQLAnywhere database)
The only table in the dataset has two int32 columns.
There is one row of data and as expected, column 0 contains an int and
column 1 contains a null.
I want to update column1.
The following code executes but the row cell remains unchanged.
I cannot see how an assignment statement can execute without error and the
target remain unchanged.
This in itself seems a bug.
I thought it may have been related to there being a null in the field but
the same thing happens when I try to change the value of the column0.
Can anyone see what is wrong?
thanks
Bob
private void button1_Click(o bject sender, EventArgs e)

{

dsBatchAssigna ble ds =new dsBatchAssignab le();// Typed dataset with two int
fields

if (mDt.GetAssigna bleBatches(ds))

{

if ((int)ds.Tables[0].Rows[0].ItemArray[0] ==805) //Proving that table has
been filled.

ds.Tables[0].Rows[0].ItemArray[1] = "3"; //inspection shows System.DBNull
value (expected) before AND AFTER assignment.

if (ds.HasChanges( ))

MessageBox.Sho w("Altered"); //Dont get here

}

ds.Tables[0].Rows[0].ItemArray[1] = 3 (without quotes, it's an int)

However, it's strongly typed, why don't you use its generated
properties?
--
Ludwig Stuyck
http://www.coders-lab.be
May 24 '06 #2
Bob,

This isn't a typed dataset problem. When you return the ItemArray, it
returns a new array, not the array used internally which is holding the
values.

So you end up modifying the value in the array, not the value in the
dataset.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Bob" <bo*@nowhere.co m> wrote in message
news:OA******** ******@TK2MSFTN GP05.phx.gbl...
Hi,
I have a typed unbound dataset that is passed to a datahandling class to
be
filled.
The datahandling class fills it from a sproc using an oledbDataAdapte r
(SQLAnywhere database)
The only table in the dataset has two int32 columns.
There is one row of data and as expected, column 0 contains an int and
column 1 contains a null.
I want to update column1.
The following code executes but the row cell remains unchanged.
I cannot see how an assignment statement can execute without error and the
target remain unchanged.
This in itself seems a bug.
I thought it may have been related to there being a null in the field but
the same thing happens when I try to change the value of the column0.
Can anyone see what is wrong?
thanks
Bob
private void button1_Click(o bject sender, EventArgs e)

{

dsBatchAssignab le ds =new dsBatchAssignab le();// Typed dataset with two
int
fields

if (mDt.GetAssigna bleBatches(ds))

{

if ((int)ds.Tables[0].Rows[0].ItemArray[0] ==805) //Proving that table has
been filled.

ds.Tables[0].Rows[0].ItemArray[1] = "3"; //inspection shows System.DBNull
value (expected) before AND AFTER assignment.

if (ds.HasChanges( ))

MessageBox.Show ("Altered"); //Dont get here

}

}


May 24 '06 #3
Bob
Hi, Ludwig and Nicholas,
Thanks for your replies
Firstly, my apologies for the quotes around the three. It was just my latest
grasping at straws attempt.
Nicholas indicates that I am returning the array and therefore modifying a
copy.
I have to disagree with this. The help file indicates that the Itemarray
property gets / sets the row elements. (Used this technique successfully in
VS2003. see below.)
But the main point is that it is a CLR BUG IMHO. (Made a VB project. Same
behaviour.)

An assignment statement should either complete properly or error. There is
no middle ground.

I have proved that the value is unchanged by:
Hovering the mouse over the instruction and expanding the 'inpection'
Querying the value in the immediate window.

The wearying thing is that this used to work in VS2003.
I have a project that was migrated from VS2003 to VS2005 and it still works
so it is not as simple as 'Duh! they broke it.'
Unfortunately there are number of differences between the two projects in
the data retrieval area. so it is hard to infer what is causing this.

But getting it going is not as important as explaining why the assignment
statement is inert. This should be an impossibility.
Bob

"Bob" <bo*@nowhere.co m> wrote in message
news:OA******** ******@TK2MSFTN GP05.phx.gbl...
Hi,
I have a typed unbound dataset that is passed to a datahandling class to be filled.
The datahandling class fills it from a sproc using an oledbDataAdapte r
(SQLAnywhere database)
The only table in the dataset has two int32 columns.
There is one row of data and as expected, column 0 contains an int and
column 1 contains a null.
I want to update column1.
The following code executes but the row cell remains unchanged.
I cannot see how an assignment statement can execute without error and the
target remain unchanged.
This in itself seems a bug.
I thought it may have been related to there being a null in the field but
the same thing happens when I try to change the value of the column0.
Can anyone see what is wrong?
thanks
Bob
private void button1_Click(o bject sender, EventArgs e)

{

dsBatchAssignab le ds =new dsBatchAssignab le();// Typed dataset with two int fields

if (mDt.GetAssigna bleBatches(ds))

{

if ((int)ds.Tables[0].Rows[0].ItemArray[0] ==805) //Proving that table has
been filled.

ds.Tables[0].Rows[0].ItemArray[1] = "3"; //inspection shows System.DBNull
value (expected) before AND AFTER assignment.

if (ds.HasChanges( ))

MessageBox.Show ("Altered"); //Dont get here

}

}


May 24 '06 #4
On Thu, 25 May 2006 09:01:50 +1200, "Bob" <bo*@nowhere.co m> wrote:

"Bob" <bo*@nowhere.co m> wrote in message
news:OA******* *******@TK2MSFT NGP05.phx.gbl.. .
Hi,
I have a typed unbound dataset that is passed to a datahandling class to

be
filled.
The datahandling class fills it from a sproc using an oledbDataAdapte r
(SQLAnywhere database)
The only table in the dataset has two int32 columns.
There is one row of data and as expected, column 0 contains an int and
column 1 contains a null.
I want to update column1.
The following code executes but the row cell remains unchanged.
I cannot see how an assignment statement can execute without error and the
target remain unchanged.
This in itself seems a bug.
I thought it may have been related to there being a null in the field but
the same thing happens when I try to change the value of the column0.
Can anyone see what is wrong?
thanks
Bob
private void button1_Click(o bject sender, EventArgs e)

{

dsBatchAssignab le ds =new dsBatchAssignab le();// Typed dataset with two

int
fields

if (mDt.GetAssigna bleBatches(ds))

{

if ((int)ds.Tables[0].Rows[0].ItemArray[0] ==805) //Proving that table has
been filled.

ds.Tables[0].Rows[0].ItemArray[1] = "3"; //inspection shows System.DBNull
value (expected) before AND AFTER assignment.

if (ds.HasChanges( ))

MessageBox.Show ("Altered"); //Dont get here

}


And what about:

ds.Tables[0].Rows[0][1] = 3;

By the way - and this is not directly related to the original question
- a few days ago I was at a meeting of our user group and Mr Clemens
Vaster did a presentation on WCF. When talking about remoting and
datasets, it came down to the fact that datasets were pure evil.
Would you guys use datasets in some cases?

--
Ludwig Stuyck
http://www.coders-lab.be
May 24 '06 #5
Bob
Hi Ludwig,
Yep, accessing the cell directly works.
Thank you.
So where to from here?
Do we just carry on or do you agree that it is a bug and should be fixed?
(I know, I know, life is too short. But...)
Bob

"Ludwig" <no**@none.co m> wrote in message
news:4r******** *************** *********@4ax.c om...
On Thu, 25 May 2006 09:01:50 +1200, "Bob" <bo*@nowhere.co m> wrote:

"Bob" <bo*@nowhere.co m> wrote in message
news:OA******* *******@TK2MSFT NGP05.phx.gbl.. .
Hi,
I have a typed unbound dataset that is passed to a datahandling class to
be
filled.
The datahandling class fills it from a sproc using an oledbDataAdapte r
(SQLAnywhere database)
The only table in the dataset has two int32 columns.
There is one row of data and as expected, column 0 contains an int and
column 1 contains a null.
I want to update column1.
The following code executes but the row cell remains unchanged.
I cannot see how an assignment statement can execute without error and

the target remain unchanged.
This in itself seems a bug.
I thought it may have been related to there being a null in the field but the same thing happens when I try to change the value of the column0.
Can anyone see what is wrong?
thanks
Bob
private void button1_Click(o bject sender, EventArgs e)

{

dsBatchAssignab le ds =new dsBatchAssignab le();// Typed dataset with two

int
fields

if (mDt.GetAssigna bleBatches(ds))

{

if ((int)ds.Tables[0].Rows[0].ItemArray[0] ==805) //Proving that table has been filled.

ds.Tables[0].Rows[0].ItemArray[1] = "3"; //inspection shows System.DBNull value (expected) before AND AFTER assignment.

if (ds.HasChanges( ))

MessageBox.Show ("Altered"); //Dont get here

}


And what about:

ds.Tables[0].Rows[0][1] = 3;

By the way - and this is not directly related to the original question
- a few days ago I was at a meeting of our user group and Mr Clemens
Vaster did a presentation on WCF. When talking about remoting and
datasets, it came down to the fact that datasets were pure evil.
Would you guys use datasets in some cases?

--
Ludwig Stuyck
http://www.coders-lab.be

May 24 '06 #6
On Thu, 25 May 2006 09:42:30 +1200, "Bob" <bo*@nowhere.co m> wrote:
Hi Ludwig,
Yep, accessing the cell directly works.
Thank you.
So where to from here?
Do we just carry on or do you agree that it is a bug and should be fixed?
(I know, I know, life is too short. But...)
Bob


Well, have a look at
http://msdn.microsoft.com/library/de...sindataset.asp
As you see, Even Microsoft sais that this is te way to do it! And yes,
in MSDN documentation they say: "You can use this property to set or
get values for this row through an array."

But!

I believe that the getter of the property ItemArray returns a copy of
the cell values, not a reference, so you'll get a new array. Changing
that array does not affect the original cell values.

So according to the documentation this seems like a bug.

--
Ludwig Stuyck
http://www.coders-lab.be
May 24 '06 #7
Bob
Hi Ludwig,
Missed your question on datasets,
I tend to normally pass classes that represent the data structure to / from
a data tier.
I only use datasets where I need the advantage of the inbuilt change
handling.
However a certain amount of laziness also creeps in. It's very attractive
to just Fill and Update. In a remoting situation I would find it harder to
justify datasets to myself.
FWIW
regards
bob
"Ludwig" <no**@none.co m> wrote in message
news:4r******** *************** *********@4ax.c om...
On Thu, 25 May 2006 09:01:50 +1200, "Bob" <bo*@nowhere.co m> wrote:

"Bob" <bo*@nowhere.co m> wrote in message
news:OA******* *******@TK2MSFT NGP05.phx.gbl.. .
Hi,
I have a typed unbound dataset that is passed to a datahandling class to
be
filled.
The datahandling class fills it from a sproc using an oledbDataAdapte r
(SQLAnywhere database)
The only table in the dataset has two int32 columns.
There is one row of data and as expected, column 0 contains an int and
column 1 contains a null.
I want to update column1.
The following code executes but the row cell remains unchanged.
I cannot see how an assignment statement can execute without error and

the target remain unchanged.
This in itself seems a bug.
I thought it may have been related to there being a null in the field but the same thing happens when I try to change the value of the column0.
Can anyone see what is wrong?
thanks
Bob
private void button1_Click(o bject sender, EventArgs e)

{

dsBatchAssignab le ds =new dsBatchAssignab le();// Typed dataset with two

int
fields

if (mDt.GetAssigna bleBatches(ds))

{

if ((int)ds.Tables[0].Rows[0].ItemArray[0] ==805) //Proving that table has been filled.

ds.Tables[0].Rows[0].ItemArray[1] = "3"; //inspection shows System.DBNull value (expected) before AND AFTER assignment.

if (ds.HasChanges( ))

MessageBox.Show ("Altered"); //Dont get here

}


And what about:

ds.Tables[0].Rows[0][1] = 3;

By the way - and this is not directly related to the original question
- a few days ago I was at a meeting of our user group and Mr Clemens
Vaster did a presentation on WCF. When talking about remoting and
datasets, it came down to the fact that datasets were pure evil.
Would you guys use datasets in some cases?

--
Ludwig Stuyck
http://www.coders-lab.be

May 24 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1706
by: Natehop | last post by:
I've been attempting to design an n-tiered framework leveraging .NET's strongly typed Dataset. My Framework will serve as the foundation to several client apps from Windows applications to web sites and web services. The architecture consists of a business rules tier, a data tier, and a common tier. The common tier contains my typed Datasets while the business rules and data tiers contain functions to populate and save the common...
2
2892
by: theWizK | last post by:
Hello all. I have noticed that when I generate a strongly-typed dataset from an xml schema that the DataTables that are generated have their constructors marked as internal. What this means is when I try to instantiate one of the strongly-typed tables from this dataset from a different assembly, I cannot. Let me provide examples... If I have a simple dataset like this:
1
6094
by: Job Lot | last post by:
I am confused how strongly typed dataset is different from un-typed dataset. Is there any good link explaining pros and cons of both? Which one should be used preferably?
1
2129
by: Linesh Gajera | last post by:
Hi Guys i having the same problem with Strongly typed dataset, I have created a stronsetly typed dataset by draging table from Server explorer and now i have retreived xml from SQL server 2000 and tried to populate dataset but it populates 0 rows even though ml contains rows. If i use regular Dataset instead of Typed dataset, then everything works just fine..please help me as soon as possible, here is my code snippet. I think you have...
1
1729
by: Nedu N | last post by:
Hi All, I am facing problem in copying content of table from a untyped dataset into to a table inside the typed dataset. I wanted to copy the data into typed dataset in order to ease the further processing using typed references. DataSet ds = getDataFromDB(); - i am getting the dataset ds from a webservice I have got MyXSD which decsribes the shcema for the table which i am getting from the webservice
1
2185
by: HardBap | last post by:
I've created a strongly typed DataSet (Customers.xsd) using the xsd.exe tool. I want to be able to access fields using ds.Customer.CompanyName. The problem is when I return this DataSet from a Web Service it adds another Table to the DataSet that contains the data. I have to access the data using ds.Tables.Rows.ToString(). This defeats the whole purpose of using a strongly typed DataSet. Thanks in advance for the help.
0
1071
by: Sparky | last post by:
Hi, I am trying to use a typed dataset with a web service and am having problems with type casting errors. I have a typed dataset which is in both my web service and my consuming application. When I try to pass the typed dataset back to the consuming application from the web service through a web service function call, I get a "Specified Cast
6
5058
by: DraguVaso | last post by:
Hi, Something I don't understand about a Typed DataSet: When a value in the DataSet is DBNull, it throws this error: "Cannot get value because it is DBNull". But aren't Typed DataSets invented to make life easier, to be able to get to tge Tables and Values with less code, in less time? But with this thing you need to add a Try-Catch around every statement when using the value, add for each value a default value in your DataSet (and...
3
2772
by: Freeon | last post by:
Hi, I am looking for a way to sort a strong typed dataset. It would seem the most straightforward way is to use a dataview. The only problem is when I use the dataview I seem to loose the strong typed properties from my original dataset Anyone that can point me to an example of how to sort my dataset and maintain the use of my typed properties would be greatly appreciated Thank, Freeon
8
1994
by: Harry Strybos | last post by:
Visual Studio 2005 - SP1 - VB.Net on WinXP SP2 I add a typed dataset to my solution and get the following errors : Error 1 sub 'ReadXmlSerializable' cannot be declared 'Overrides' because it does not override a sub in a base class. C:\AAProjects.Net\TRM8\TRM8.UI\Reports\BillingReport.Designer.vb 125 29 TRM8.UI Error 2 'Protected Overrides Function GetSchemaSerializable() As
0
9892
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9734
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10718
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10347
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9490
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7061
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5725
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5915
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3168
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.