<?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>Re: Reading from a database with code</title><link>https://www.infopathdev.com:443/forums/thread/22202.aspx</link><pubDate>Wed, 08 Aug 2007 01:37:21 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:22202</guid><dc:creator>Patrick Halstead</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/22202.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=22202</wfw:commentRss><description>&lt;p&gt;Hi Nick,&lt;/p&gt;&lt;p&gt;We&amp;#39;re you able to get the Database Accelerator installed? That should get you up and running in minimal time. No code. Form/DB changes down-the-road are easier to handle and you get the ref ID support that you want. It&amp;#39;s a lot of work to code SQL connections up yourself and there are fundamental limitations (you have to start from SQL schema - which limits your data source structure and prevents easy additions later, or you have to write a ton of code and allow SQL Client Permissions which means full trust forms and lots of deployment hassle). &lt;/p&gt;</description></item><item><title>Re: Reading from a database with code</title><link>https://www.infopathdev.com:443/forums/thread/22191.aspx</link><pubDate>Tue, 07 Aug 2007 15:30:48 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:22191</guid><dc:creator>djay</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/22191.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=22191</wfw:commentRss><description>&lt;p&gt;You can do the query with InfoPath&amp;#39;s built in database support.&lt;/p&gt;&lt;p&gt;And you might be able to do the submit as well.&lt;/p&gt;&lt;p&gt;In the tools menu go to data connections and play around with the wizard.&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Reading from a database with code</title><link>https://www.infopathdev.com:443/forums/thread/22134.aspx</link><pubDate>Wed, 01 Aug 2007 19:19:13 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:22134</guid><dc:creator>repole</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/22134.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=22134</wfw:commentRss><description>&lt;p&gt;Really could use some help here guys. I found some sample code online which has helped me get steered in the right direction...somewhat.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;a href="http://www.developerfusion.co.uk/show/6128/"&gt;http://www.developerfusion.co.uk/show/6128/&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;font color="#0000ff"&gt;SqlConnection MyConnection = new SqlConnection(&amp;quot;server=sqlserver;database=yourdatabase;UID=;PWD=;&amp;quot;);&lt;br /&gt;MyConnection.Open();&lt;br /&gt;SqlCommand Cmd = new SqlCommand();&lt;br /&gt;Cmd.Connection = MyConnection;&lt;br /&gt;Cmd.CommandType = CommandType.Text;&lt;br /&gt;Cmd.CommandText = &amp;quot;select * from tblUser&amp;quot;;&lt;br /&gt;SqlDataAdapter DA = new SqlDataAdapter(Cmd);&lt;br /&gt;DataSet DS = new DataSet();&lt;br /&gt;DA.Fill(DS);&lt;/font&gt; &lt;/p&gt;&lt;p&gt;&lt;font color="#0000ff"&gt;thisXDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:field1&amp;quot;).text = DS.Tables[0].Rows[1][1].ToString(); &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font color="#0000ff"&gt;if(DS.Tables[0].Rows[1][1].ToString() == &amp;quot;John Doe&amp;quot;)&lt;br /&gt;{&lt;br /&gt;thisXDocument.UI.Alert(&amp;quot;User name is John Doe.&amp;quot;);&lt;br /&gt;} &lt;/font&gt;&lt;/p&gt;&lt;p&gt;Now I&amp;#39;ve got a number of issues here. I&amp;#39;d REALLY appreciate it if I could send someone my form, and try to explain what I&amp;#39;m trying to do.&lt;/p&gt;&lt;p&gt;1. I can&amp;#39;t seem to connect to the database on my local harddrive. I set up MS SQL Server Management Studio Express, so that it says the server is said to be &lt;span style="font-size:12pt;font-family:'Times New Roman';"&gt;ALMA4-XDSCAN5\SQLEXPRESS and it uses Windows Authentification making the username and password fields uneditable. So my question is, how exactly do I connect to that database?&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman';"&gt;&amp;nbsp;2. Further along, when the SQLDataAdapter is filled, if I go to edit the data in &amp;quot;DA&amp;quot; am I editing the actual data in the database, or am I editing data that&amp;#39;s been pulled and isn&amp;#39;t linked directly to the database?&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman';"&gt;So below is the basic outline of how I need to set this program up. If I knew the language, and if I knew how to work with databases through java script I&amp;#39;d have no problem executing this, but unfortunately I&amp;#39;m pretty lost in that regard.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman';"&gt;&lt;br /&gt;Connect to database&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman';"&gt;CmdLoadForm:OnClick (user puts in a referenceID and clicks button to load info)&lt;br /&gt;-Selects row from Requests table in LegalRequest database which has a referenceID matching the referenceID entered on the form.&lt;br /&gt;-Fills in a few fields&lt;br /&gt;-Selects rows from EventTracker table with matching referenceID&lt;br /&gt;-Iterates through selection&lt;br /&gt;--If &amp;#39;Type&amp;#39; = one thing&lt;br /&gt;---fill out these fields&lt;br /&gt;--If Type = another thing&lt;br /&gt;---insert another repeating section, and fill out those fields (question here, if there&amp;nbsp;are repeating sections, how do you choose say the 2nd repititoin of that section)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman';"&gt;CmdSubmitForm:OnClick&lt;br /&gt;-If referenceID already in Requests table&lt;br /&gt;--Update that row with data from form&lt;br /&gt;-Else&lt;br /&gt;--Insert new row&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman';"&gt;-If docTrackingID already in EventTracking table&lt;br /&gt;--Update that row with data from form&lt;br /&gt;-Else&lt;br /&gt;--Insert new row&lt;/span&gt;&lt;/p&gt;</description></item></channel></rss>