S
Stephen Ahn
Using VS2005, dotnet 2.0.
Here's some code which reproduces the issue.
Web Service code :
==
[WebMethod]
public string SendDataSet(DataSet ds)
{
DataRow dr = ds.Tables[0].Rows[0];
string sCurrent = (string)dr[0, DataRowVersion.Current];
string sOriginal = (string)dr[0, DataRowVersion.Original];
return "current : " + GetStringAsHex(sCurrent) + ", original : "
+ GetStringAsHex(sOriginal);
}
private static string GetStringAsHex(string str)
{
System.Text.StringBuilder sb = new
System.Text.StringBuilder("0x");
for (int i = 0; i < str.Length; i++)
{
sb.AppendFormat("{0:X2}", (int)str);
}
return sb.ToString();
}
==
Run this code on the client end :
==
private void bDataSetTest_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
DataTable dt = ds.Tables.Add("t");
dt.Columns.Add("Data", typeof(string));
DataRow dr = dt.NewRow();
dr["Data"] = "\n";
dt.Rows.Add(dr);
dt.AcceptChanges();
dr["Data"] = "\n";
HelloWorldWebServiceTestApp.localhost.HelloWorldWebService ws =
new HelloWorldWebServiceTestApp.localhost.HelloWorldWebService();
ws.Url = this.tbUrl.Text.Trim();
string res = ws.SendDataSet(ds);
MessageBox.Show(res);
}
==
The messagebox displays : "current : 0x0A, original : 0x".
I was expecting : "current : 0x0A, original : 0x0A".
So, there seems to be a problem with the original value of columns which
only contain whitespace. The web method does not see exactly what the client
has sent.
Any ideas ?
Thanks,
Stephen
Here's some code which reproduces the issue.
Web Service code :
==
[WebMethod]
public string SendDataSet(DataSet ds)
{
DataRow dr = ds.Tables[0].Rows[0];
string sCurrent = (string)dr[0, DataRowVersion.Current];
string sOriginal = (string)dr[0, DataRowVersion.Original];
return "current : " + GetStringAsHex(sCurrent) + ", original : "
+ GetStringAsHex(sOriginal);
}
private static string GetStringAsHex(string str)
{
System.Text.StringBuilder sb = new
System.Text.StringBuilder("0x");
for (int i = 0; i < str.Length; i++)
{
sb.AppendFormat("{0:X2}", (int)str);
}
return sb.ToString();
}
==
Run this code on the client end :
==
private void bDataSetTest_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
DataTable dt = ds.Tables.Add("t");
dt.Columns.Add("Data", typeof(string));
DataRow dr = dt.NewRow();
dr["Data"] = "\n";
dt.Rows.Add(dr);
dt.AcceptChanges();
dr["Data"] = "\n";
HelloWorldWebServiceTestApp.localhost.HelloWorldWebService ws =
new HelloWorldWebServiceTestApp.localhost.HelloWorldWebService();
ws.Url = this.tbUrl.Text.Trim();
string res = ws.SendDataSet(ds);
MessageBox.Show(res);
}
==
The messagebox displays : "current : 0x0A, original : 0x".
I was expecting : "current : 0x0A, original : 0x0A".
So, there seems to be a problem with the original value of columns which
only contain whitespace. The web method does not see exactly what the client
has sent.
Any ideas ?
Thanks,
Stephen