<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Open form in a different form template</title><link>https://www.infopathdev.com:443/forums/thread/40143.aspx</link><pubDate>Mon, 30 Mar 2009 19:21:42 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:40143</guid><dc:creator>chrisf</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/40143.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=40143</wfw:commentRss><description>&lt;p&gt;I am saving my infopath forms in a sql database and am retrieving them by following this article by S.Y.M. Wong-A-Ton:&lt;br /&gt;&lt;a href="http://www.bizsupportonline.net/infopath2007/retrieve-infopath-form-sql-display-in-new-instance-infopath.htm"&gt;http://www.bizsupportonline.net/infopath2007/retrieve-infopath-form-sql-display-in-new-instance-infopath.htm&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;This is working great, but some users should only be able to view the forms and not add/modify them. I am hoping there is a way to launch the form using a different template or view that is an exact copy of the one that added the form except it does not allow a submit.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;This is the code that opens the form in the submitform.xsn&lt;/p&gt;
&lt;p&gt;// Convert the XML data for the InfoPath form into a byte array&lt;br /&gt;byte[] bytes = Encoding.UTF8.GetBytes(data);&lt;/p&gt;
&lt;p&gt;// Create a temp file&lt;br /&gt;string fileName = Path.GetTempFileName();&lt;/p&gt;
&lt;p&gt;// Read the byte array of the retrieved form into the temp file&lt;br /&gt;using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.ReadWrite))&lt;br /&gt;{&lt;br /&gt;fs.Write(bytes, 0, bytes.Length);&lt;br /&gt;fs.Flush();&lt;br /&gt;fs.Close();&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;// Display the form in a new instance of InfoPath&lt;br /&gt;this.Application.XmlForms.Open(fileName, XmlFormOpenMode.Default);&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;What do I need to replace this.Application.XmlForms.Open(fileName, XmlFormOpenMode.Default); with in order to open it in the nonsubmitform.xsn?&lt;/p&gt;</description></item></channel></rss>