Trouble Changing Attribute Value

C

Chrisf

I am passing an InfoPath 2007 form as a string to a Web Service and would
like to modify an attribute's value before saving the entire form in a sql
table but can't seem to find the correct way to do it using C sharp.

This is how I am getting the current value:

XmlDocument doc = new XmlDocument();
doc.LoadXml(data);
string aProgID =
doc.GetElementsByTagName("my:program").Item(0).InnerText;

I would like to replace aProgID with newProgID for the Program attribute.

Any help would be deeply appreciated.
 
A

Anuma(GGK Tech)

Hi,

How you are getting "newProgId". Are you getting this value from the form or
you need to generate manually.

You can set the pogId as follows,
newProgId = 123 //sample value;
doc.GetElementsByTagName("my:program").Item(0).InnerText =newprogId;
 
C

Chrisf

Hi Anuma,

I am generating newProgID manually. Using the debugger I see that after
executing the command you gave me the attribute has the correct value, but I
must be missing a step.

The InfoPath form is being passed to the webservice like this:
public void XmlsubmitData(string data)

To extract the data I need from the form I am using these commands:
XmlDocument doc = new XmlDocument();
doc.LoadXml(data);
string aProgID =
doc.GetElementsByTagName("my:program").Item(0).InnerText;

Using the command you gave me, I am replacing the value for my:program
doc.GetElementsByTagName("my:program").Item(0).InnerText = newProgID;

I am saving the entire form in the xml column of a sql table
command.Parameters["@FORM"].Value = data;
command.CommandText = "INSERT INTO dbo.CAPS VALUES
(@DIV,@STARTYR,@PROG,@TITLE,@FORM)";


How do I go about updating data (InfoPath form passed into web service) with
the change I made to doc?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top