Hello,
I've got an InfoPath form that connects and runs a Store Procedure on my SQL Database. The Value returned is a string which i'm then wanting to put into a field on my InfoPath datasource.
My Connection snippet is:
using (SqlCommand command = new SqlCommand("SP_InfoPath", connection))
{
command.CommandType = CommandType.StoredProcedure;
connection.Open();
command.Transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted);
SqlDataReader reader = command.ExecuteReader(CommandBehavior.SingleResult); while (reader.Read())
{
builder.Append(reader[0].ToString()); command.
}
When I try to then put that into a field in my infopath datasource with this code:
string xpath = "/my:myFields/my:field1";
XPathNavigator field = MainDataSource.CreateNavigator().SelectSingleNode(xpath, NamespaceManager);
field.SetValue(builder.ToString);
It comes up with error: Operation is not valid, because of the current state of the object.
The connection is fine as in debug mode builder value is what should be coming through. The destination field is set to string.
Can anyone advise?
Thanks, Iri