D
David D. McCrory
Hello Group,
I am trying to use the Data Adapter.Update() function. I have a record that
has been modified that I am passing to a WebService using the
DataSet.GetXml() function. When I call the DataAdapter.Update() function,
the record is inserted as a new record instead of modifying the existing
record. I wanted to pass the XML string to the WebService instead of passing
a DataSet. So I have 2 questions for the group:
1.How can I pass the XML and retain the status of the records?
2. Shouldn't the Update function compare the record in the DataSet from the
WebService to the DataSource and update the existing row??
Here is the code from the Web Page followed by the code from the WebService
Web Page Code
private void lnkbtnUpdate_Click(object sender, System.EventArgs e)
{
DataRow dr;
Global app = (Global) Context.ApplicationInstance;
//Load the DataSet.
dsUserInfo = app.LoadDataSet("UserInfo", 0);
//Get the current data row.
dr = dsUserInfo.Tables["UserInfo"].Rows[0];
//Set the values equal to the screen values.
dr["FirstName"] = txtFirstName.Text;
dr["MiddleName"] = txtMName.Text;
dr["LastName"] = txtLastName.Text;
dr["SSNumber"] = txtSSNumber.Text;
dr["DateofBirth"] = txtBirthDate.Text;
dr["Gender"] = ddlGender.SelectedValue;
//Call the WebService and pass the updated information.
cmi.UpdateUserInfo(dsUserInfo.GetXml());
}
WebService Code
[WebMethod]
public void UpdateUserInfo(string info)
{
DataSet ds = new DataSet();
ds.ReadXml(new StringReader(info));
try
{
cnCrewManagement.Open();
daUserInfo.Update(ds, "UserInfo");
}
finally
{
cnCrewManagement.Close();
}
}
I am trying to use the Data Adapter.Update() function. I have a record that
has been modified that I am passing to a WebService using the
DataSet.GetXml() function. When I call the DataAdapter.Update() function,
the record is inserted as a new record instead of modifying the existing
record. I wanted to pass the XML string to the WebService instead of passing
a DataSet. So I have 2 questions for the group:
1.How can I pass the XML and retain the status of the records?
2. Shouldn't the Update function compare the record in the DataSet from the
WebService to the DataSource and update the existing row??
Here is the code from the Web Page followed by the code from the WebService
Web Page Code
private void lnkbtnUpdate_Click(object sender, System.EventArgs e)
{
DataRow dr;
Global app = (Global) Context.ApplicationInstance;
//Load the DataSet.
dsUserInfo = app.LoadDataSet("UserInfo", 0);
//Get the current data row.
dr = dsUserInfo.Tables["UserInfo"].Rows[0];
//Set the values equal to the screen values.
dr["FirstName"] = txtFirstName.Text;
dr["MiddleName"] = txtMName.Text;
dr["LastName"] = txtLastName.Text;
dr["SSNumber"] = txtSSNumber.Text;
dr["DateofBirth"] = txtBirthDate.Text;
dr["Gender"] = ddlGender.SelectedValue;
//Call the WebService and pass the updated information.
cmi.UpdateUserInfo(dsUserInfo.GetXml());
}
WebService Code
[WebMethod]
public void UpdateUserInfo(string info)
{
DataSet ds = new DataSet();
ds.ReadXml(new StringReader(info));
try
{
cnCrewManagement.Open();
daUserInfo.Update(ds, "UserInfo");
}
finally
{
cnCrewManagement.Close();
}
}