473,326 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

DataSet loses original value across an interface

Hi
I have a dataset which holds (amongest other things) a string.
- The dataset gets loaded from the database via a middle tier
- The string value contains "\r\n"
- Its serialised to the web application
- The web application deletes the row. I can see using the below that
before and after the delete the
string value is what it should be

(string)rows[0]["TEXT", DataRowVersion.Original];

In the middle tier however after serializing back that same line now
returns an empty string? The other columns are fine and if I put a
value other than "\r\n" in (e.g. "\r\na") then its fine. The string
column is allowed to be null.

Does this make sense to anyone?

ta

Sep 18 '07 #1
5 2342
Hi,

I do not understand your post, you say that you delete the post. Then later
you talk about serialization back in the middle tier.

Are you sending back the dataset?
after you delete the row?
IIRC the deleted rows will not be serialized.

<co**********@googlemail.comwrote in message
news:11**********************@o80g2000hse.googlegr oups.com...
Hi
I have a dataset which holds (amongest other things) a string.
- The dataset gets loaded from the database via a middle tier
- The string value contains "\r\n"
- Its serialised to the web application
- The web application deletes the row. I can see using the below that
before and after the delete the
string value is what it should be

(string)rows[0]["TEXT", DataRowVersion.Original];

In the middle tier however after serializing back that same line now
returns an empty string? The other columns are fine and if I put a
value other than "\r\n" in (e.g. "\r\na") then its fine. The string
column is allowed to be null.

Does this make sense to anyone?

ta

Sep 18 '07 #2
I do not understand your post, you say that you delete the post. Then later
you talk about serialization back in the middle tier.
I delete a row in a DataSet using row.Delete(). Then the dataset is
sent back to the middle tier. Even though
a row is deleted I would expect to be able to access the original
values until AcceptChanges is called
or the DataSet is put to the database by the DataAdapter, and I can
except in this one odd case.
Are you sending back the dataset?
after you delete the row?
IIRC the deleted rows will not be serialized.
The deleted rows are serialised. The other columns still hold their
original values. So does this row if I put
some other characters in.

I also did an experiment using memory streaming and it had the same
effect, heres the code.

MemoryStream stream = new MemoryStream(1000000);

System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter
bformatter = new
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter();

bformatter.Serialize(stream, theDs);

//de
stream.Seek(0, SeekOrigin.Begin);

bformatter = new
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter();

theDs = (MyDsClass)bformatter.Deserialize(stream);
stream.Close();
Sep 19 '07 #3
Hi
I did a complete, seperate example. Place the logic below in some
file, use right click and resolve to get the 'using'
statements in there and give it a whirl.
The variables text1 and text2 are exactly what you would think the
first time but although text1 is set text2 is empty after serializing/
deserializing

ta
DataSet dataSet = new DataSet();
DataTable table = dataSet.Tables.Add();
table.Columns.Add("normalString", typeof(string));
table.Columns.Add("oddString", typeof(string));
DataRow row = table.NewRow();
table.Rows.Add(row);

row["normalString"] = "hello world";
row["oddString"] = "\r\n";

dataSet.AcceptChanges();
row.Delete();

foreach (DataRow itRow in dataSet.Tables[0].Rows)
{
if (itRow.RowState == DataRowState.Deleted)
{
string text1 = (string)itRow["normalString",
DataRowVersion.Original];
string text2 = (string)itRow["oddString",
DataRowVersion.Original];
}
}

MemoryStream stream = new MemoryStream(1000000);

System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter
bformatter = new
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter();

bformatter.Serialize(stream, dataSet);

//de
stream.Seek(0, SeekOrigin.Begin);

bformatter = new
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter();

DataSet newDs = (DataSet)bformatter.Deserialize(stream);

foreach(DataRow itRow in newDs.Tables[0].Rows)
{
if (itRow.RowState == DataRowState.Deleted)
{
string text1 = (string)itRow["normalString",
DataRowVersion.Original];
string text2 = (string)itRow["oddString",
DataRowVersion.Original];
}
}
stream.Close();
Sep 19 '07 #4
Use DataSet.RemotingFormat:

Your code:

DataSet dataSet = new DataSet();

// I added the following line - It seemed to do the trick
dataSet.RemotingFormat = SerializationFormat.Binary;

DataTable table = dataSet.Tables.Add();
table.Columns.Add("normalString", typeof(string));
..
..
..
later
http://msdn2.microsoft.com/en-us/lib...ingformat.aspx

"co**********@googlemail.com" wrote:
Hi
I did a complete, seperate example. Place the logic below in some
file, use right click and resolve to get the 'using'
statements in there and give it a whirl.
The variables text1 and text2 are exactly what you would think the
first time but although text1 is set text2 is empty after serializing/
deserializing

ta
DataSet dataSet = new DataSet();
DataTable table = dataSet.Tables.Add();
table.Columns.Add("normalString", typeof(string));
table.Columns.Add("oddString", typeof(string));
DataRow row = table.NewRow();
table.Rows.Add(row);

row["normalString"] = "hello world";
row["oddString"] = "\r\n";

dataSet.AcceptChanges();
row.Delete();

foreach (DataRow itRow in dataSet.Tables[0].Rows)
{
if (itRow.RowState == DataRowState.Deleted)
{
string text1 = (string)itRow["normalString",
DataRowVersion.Original];
string text2 = (string)itRow["oddString",
DataRowVersion.Original];
}
}

MemoryStream stream = new MemoryStream(1000000);

System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter
bformatter = new
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter();

bformatter.Serialize(stream, dataSet);

//de
stream.Seek(0, SeekOrigin.Begin);

bformatter = new
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter();

DataSet newDs = (DataSet)bformatter.Deserialize(stream);

foreach(DataRow itRow in newDs.Tables[0].Rows)
{
if (itRow.RowState == DataRowState.Deleted)
{
string text1 = (string)itRow["normalString",
DataRowVersion.Original];
string text2 = (string)itRow["oddString",
DataRowVersion.Original];
}
}
stream.Close();
Oct 8 '07 #5
// I added the following line - It seemed to do the trick
dataSet.RemotingFormat =SerializationFormat.Binary;
That fixs it, ta very much :-)

Oct 29 '07 #6

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

Similar topics

8
by: Bruce Stockwell | last post by:
the setup: Webservice/WinClient application/SQL server. VS.Net (visual basic) winform wizard creates a simple form with load cancel cancelall and datagrid bound to a simple Dataset with one...
2
by: Andreas Palm | last post by:
I have a dataset that has DBNull in certain columns, now when I write out this one to XML, I only get the columns as elements that do have data in it. However I do need also the empty colums as...
1
by: John Lee | last post by:
Hi, When I use DataSet.WriteXml(filename, XmlWriteMode.DiffGram), the xml file contains current values (at <InvDataSet> node) and original value (at <diffgr:before> node) - this means the...
1
by: moonriver | last post by:
It seems that a C# program can not update the original database by mapping all the changes to the dataset, but have to explicitly assign the InsertCommand or UpdateCommand properties of a...
9
by: Dave | last post by:
Compilier will not recognize DataSet object. As you can see below is from a test simple form with no other code. I'm just trying to get any Aspx form to recognize the DataSet object. You can...
12
by: Graham Blandford | last post by:
Hi all, Would someone be able to tell me the most 'graceful' way of removing unwanted rows from a dataset based on a condition prior to update? OR, resetting the rows all to unchanged after they...
1
by: J. Askey | last post by:
I am implementing a web service and thought it may be a good idea to return a more complex class (which I have called 'ServiceResponse') in order to wrap the original return value along with two...
1
by: Steve | last post by:
I have a windows CE application, talking to a C# WebService. In the WebService project I have created a dataset (dsJobList), and there is a web method in there which returns a fully loaded...
15
by: Joseph Geretz | last post by:
I'm a bit puzzled by the current recommendation not to send Datasets or Datatables between application tiers. http://support.microsoft.com/kb/306134 ...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.