Search code examples
c#infopathvsta

Call an infopath textfield in codebehind using c#


I have 2 textfields:

Textfield 1 - the user types an input number

Textfield 2 - You get the result from what the user typed in the first textfield.

    public void Txb1_Changed(object sender, XmlEventArgs e)
    {
        AdoQueryConnection conn = (AdoQueryConnection)(this.DataConnections[@"Data Source=****;Initial Catalog=****;Integrated Security=True;Trusted_Connection=True"]);
        string origCommand = "Select Name from TableUsers where ID = '"+"TexField.Text"+"'";
        conn.Command = origCommand;
        conn.Execute();
        TextField2.Text = Database result; //here i want the result

    }

My problem is I don't know how to call textfield1 or textfield2 from my infopath form in order to manipulate them. Both Textfield are under MyFields form and i already made an sql connection which is working well. Hope someone can help


Solution

  • I used another aproach which solved my problem https://naleenbtech.wordpress.com/2011/06/02/getting-data-from-sql-server-to-infopath-form/