How to access MainDataSource Programmatically - InfoPath Dev
in

InfoPath Dev

How to access MainDataSource Programmatically

Last post 04-29-2008 01:18 PM by Greg Collins. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 04-21-2008 03:30 AM

    • rohit
    • Top 500 Contributor
    • Joined on 03-17-2008
    • Posts 50

    How to access MainDataSource Programmatically

    I could not access this.MainDataSource propery in my C# Code.

    I have added all the required references.Though getting error

    Error 5 'LMC.FormCode' does not contain a definition for 'MainDataSource' 

     

    Thanks,......

     

     

  • 04-21-2008 04:49 PM In reply to

    Re: How to access MainDataSource Programmatically

    I normally just use "MainDataSource" rather than "this.MainDataSource" and it works just fine.

    Double-check in your Tools | Form Options | Programming dialog box to make sure you are set to "C#" and not some other option.

  • 04-21-2008 10:04 PM In reply to

    • rohit
    • Top 500 Contributor
    • Joined on 03-17-2008
    • Posts 50

    Re: How to access MainDataSource Programmatically

    How to access  "MainDataSource.CreateNavigator()" in C# (InfoPath 2003 Compatible).

     

  • 04-23-2008 09:23 AM In reply to

    Re: How to access MainDataSource Programmatically

    You don't when using "C# (InfoPath 2003 Compatible)". You need to use "C#" and not "C# (InfoPath 2003 Compatible)". They are very different programming models. The one you have currently selected knows nothing about "MainDataSource".

  • 04-23-2008 10:25 PM In reply to

    • rohit
    • Top 500 Contributor
    • Joined on 03-17-2008
    • Posts 50

    Re: How to access MainDataSource Programmatically

    I want to access infopath form using following code,Is there any alternative for "this.MainDataSource.CreateNavigator()" in "C# (InfoPath 2003 Compatible)".

    Please suggest some alternative way.

    // Transform the InfoPath form and save the XML into the stream for the part

    trans.Transform(this.MainDataSource.CreateNavigator(), null, partStream);

  • 04-24-2008 04:22 PM In reply to

    Re: How to access MainDataSource Programmatically

    I repeat... there is no way to do this. When you are using "C# (InfoPath 2003 Compatible)" there is no access to the MainDataSource object. It doesn't exist. It won't exist.

    You either need to use InfoPath 2003 compatible coding (i.e. thisXDocument.DOM) or you need to switch to use "C#" (the InfoPath 2007 coding model which DOES have MainDataSource).

    To switch you will want to copy your code somewhere, then go to Tools | Form Options | Programming. Click "Remove Code", and then select "C#". Then add you code back.

    You CANNOT mix the IP03 and IP07 programming models like you are trying to do.

  • 04-25-2008 03:43 AM In reply to

    • rohit
    • Top 500 Contributor
    • Joined on 03-17-2008
    • Posts 50

    Re: How to access MainDataSource Programmatically

    Then how should i access infopath form and save the XML in "C# (InfoPath 2003 Compatible)" ,which i have implemented in C# as follows

    // Transform the InfoPath form and save the XML into the stream for the part

    trans.Transform(this.MainDataSource.CreateNavigator(), null, partStream);

  • 04-25-2008 09:08 AM In reply to

    • Albert
    • Top 500 Contributor
    • Joined on 04-03-2008
    • The Netherlands
    • Posts 32

    Re: How to access MainDataSource Programmatically

    Hi, read : http://msdn2.microsoft.com/nl-nl/library/aa167871(en-us,office.11).aspx and http://msdn2.microsoft.com/en-us/office/aa905435.aspx All the information you need is there, you just have to look for it.

    Good luck.

     

  • 04-27-2008 11:10 PM In reply to

    • rohit
    • Top 500 Contributor
    • Joined on 03-17-2008
    • Posts 50

    Re: How to access MainDataSource Programmatically

    I gone through it,i wont get solution for my query.

     i want to  access infopath form and save the XML using  "C# (InfoPath 2003 Compatible)" model,which i have implemented in C# "infopath 2007" object model.

    the code for the same using "C# (InfoPath 2003 Compatible)" model is as follows.

    // Transform the InfoPath form and save the XML into the stream for the part

    trans.Transform(this.MainDataSource.CreateNavigator(), null, partStream);

  • 04-28-2008 03:49 PM In reply to

    Re: How to access MainDataSource Programmatically

    In 2003 coding you would do something like this:

    IXMLDOMNode oXml = thisXDocument.DOM.selectSingleNode("...xpath to XML Node to be transformed...");
    IXMLDOMNode oXsl = ... // You need to have your XSL loaded into an IXMLDOMDocument, and then select it's root.

    string transformResults = oXml.transformNode(oXsl);

    - - - - -

    But the big question is this: Is all the rest of your code using the IP03 model, or the IP07 model? If IP03, then great, just get this part working in IP03. If the rest of your code is written in the IP07 model, then the right thing to do is to stop using "C# (InfoPath 2003 Compatible)" and move to using "C#".

  • 04-29-2008 03:06 AM In reply to

    • rohit
    • Top 500 Contributor
    • Joined on 03-17-2008
    • Posts 50

    Re: How to access MainDataSource Programmatically

    Thanks for answring blogs

    But finally i decided to use "C#"  instead of "C#(infopath 2003 Compatible)".

     

  • 04-29-2008 01:18 PM In reply to

    Re: How to access MainDataSource Programmatically

    I wish you the best on the rest of the project!

Page 1 of 1 (12 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.