<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/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>Visual Studio Data : Debugging</title><link>http://blogs.msdn.com/vsdata/archive/tags/Debugging/default.aspx</link><description>Tags: Debugging</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Debugging with Local Database File</title><link>http://blogs.msdn.com/vsdata/archive/2009/07/31/debugging-with-local-database-file.aspx</link><pubDate>Fri, 31 Jul 2009 04:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9853950</guid><dc:creator>Yang Cao</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/vsdata/comments/9853950.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsdata/commentrss.aspx?PostID=9853950</wfw:commentRss><wfw:comment>http://blogs.msdn.com/vsdata/rsscomments.aspx?PostID=9853950</wfw:comment><description>&lt;P&gt;Most of the time, your business application needs to deal with data stored in a database. Sometimes the database is on a remote server, while sometimes it is a local database file (SQL Server Compact database file, SQL Server Express database file, or Microsoft Access database file). &lt;BR&gt;One of the frequently asked questions about debugging an application that has a local database file is: “&lt;A&gt;my update method executes successfully, why the database data is not updated&lt;/A&gt;?” &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;My data is not updated!&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;For example, my project has a SQL Server Compact database file (Northwind.sdf), and I add a dataset with Customer table data in my database file: &lt;BR&gt;&lt;A href="file:///C:/Users/yangcao/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles1AF77F5/image3.png" mce_href="file:///C:\Users\yangcao\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles1AF77F5\image3.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=clip_image001 border=0 alt=clip_image001 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DebuggingwithLocalDatabaseFile_89AB/clip_image001_35144abc-ab79-4385-9101-71c193216193.png" width=332 height=307 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DebuggingwithLocalDatabaseFile_89AB/clip_image001_35144abc-ab79-4385-9101-71c193216193.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;In Program.cs file, input following code to Main method:&amp;nbsp; &lt;BR&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'NSimSun','serif'; FONT-SIZE: 9pt; mso-fareast-font-family: nsimsun; mso-bidi-font-family: nsimsun; mso-ansi-language: en-us; mso-fareast-language: zh-cn; mso-bidi-language: ar-sa"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;NorthwindDataSet&lt;/SPAN&gt; ds = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;NorthwindDataSet&lt;/SPAN&gt;(); &lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;NorthwindDataSetTableAdapters.&lt;SPAN style="COLOR: #2b91af"&gt;CustomersTableAdapter&lt;/SPAN&gt; ta = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; ConsoleApplication1.NorthwindDataSetTableAdapters.&lt;SPAN style="COLOR: #2b91af"&gt;CustomersTableAdapter&lt;/SPAN&gt;();&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt; mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-fareast-language: zh-cn; mso-bidi-language: ar-sa; mso-ascii-theme-font: minor-latin; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-latin; mso-bidi-theme-font: minor-bidi"&gt; &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'NSimSun','serif'; FONT-SIZE: 9pt; mso-fareast-font-family: nsimsun; mso-bidi-font-family: nsimsun; mso-ansi-language: en-us; mso-fareast-language: zh-cn; mso-bidi-language: ar-sa"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ta.Fill(ds.Customers); &lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ds.Customers[0].Postal_Code = &lt;SPAN style="COLOR: #a31515"&gt;"11111"&lt;/SPAN&gt;; &lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; result = ta.Update(ds);&lt;/SPAN&gt; &lt;/P&gt;
&lt;P&gt;Now if you hit F5 to debug this project and check the return value of Update method, the value is 1, which means one row was successfully updated. Now double click the Northwind.sdf file in Solution Explorer, and choose “Show Table Data” on Customers table: &lt;BR&gt;&lt;A href="file:///C:/Users/yangcao/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles1AF77F5/image[4].png" mce_href="file:///C:\Users\yangcao\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles1AF77F5\image%5b4%5d.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=clip_image002 border=0 alt=clip_image002 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DebuggingwithLocalDatabaseFile_89AB/clip_image002_ad809305-8a7e-43c4-a2de-18c1fbb1dfa4.png" width=338 height=344 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DebuggingwithLocalDatabaseFile_89AB/clip_image002_ad809305-8a7e-43c4-a2de-18c1fbb1dfa4.png"&gt;&lt;/A&gt; &lt;BR&gt;You will notice that the Postal_Code is not updated at all! &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;What happened?&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Let’s check the property of the local database file: &lt;BR&gt;&lt;A href="file:///C:/Users/yangcao/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles1AF77F5/image[9].png" mce_href="file:///C:\Users\yangcao\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles1AF77F5\image%5b9%5d.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=clip_image003 border=0 alt=clip_image003 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DebuggingwithLocalDatabaseFile_89AB/clip_image003_e8edce6f-4d99-40f4-bf64-7e101b228d74.png" width=353 height=248 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DebuggingwithLocalDatabaseFile_89AB/clip_image003_e8edce6f-4d99-40f4-bf64-7e101b228d74.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;There’s a property “Copy to Output Directory” and the default value is “Copy if newer” (if you’re using .mdf or .mdb file, the default value is “Copy always”). You could check &lt;A href="http://msdn.microsoft.com/en-us/library/ms233817.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms233817.aspx"&gt;this MSDN document&lt;/A&gt; to learn what this property means. In short, the local database file will be copied to Output directory, and THAT database is the one that will get updated.&lt;/P&gt;
&lt;P&gt;Let’s select “Show All Files” button on upper left corner of Solution Explorer, and navigate to bin/Debug folder. Now you could see the Northwind.sdf file in output directory: &lt;BR&gt;&lt;A href="file:///C:/Users/yangcao/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles1AF77F5/image[14].png" mce_href="file:///C:\Users\yangcao\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles1AF77F5\image%5b14%5d.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=clip_image004 border=0 alt=clip_image004 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DebuggingwithLocalDatabaseFile_89AB/clip_image004_13030b8c-e634-4e08-aa94-44b1966228e6.png" width=315 height=355 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DebuggingwithLocalDatabaseFile_89AB/clip_image004_13030b8c-e634-4e08-aa94-44b1966228e6.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If you double click on this file, Server Explorer will create a connection to this database file. “Show Table Data” now! You will see the Postal_Code of first customer is now "11111”.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;What other options do I have?&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;If you don’t want Visual Studio to copy the database file for you, you could set the “Copy to Output Directory” property to “Do not copy”. Then it’s your choice when and how to overwrite the database file. Of course, you still need two copies of database file: at design time, you’re using the database file in solution directory, while at run time, you’re modifying the one in output directory.&lt;/P&gt;
&lt;P&gt;If you want to get rid of this “two-copy-confusion” and want both design time and run time using the same copy of database file, you should select No when IDE offers to “copy the file to your project and modify the connection”. &lt;BR&gt;&lt;A href="file:///C:/Users/yangcao/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles1AF77F5/image[18].png" mce_href="file:///C:\Users\yangcao\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles1AF77F5\image%5b18%5d.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=clip_image005 border=0 alt=clip_image005 src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DebuggingwithLocalDatabaseFile_89AB/clip_image005_2659ca89-c6a6-4180-8c4c-831c45a19192.png" width=445 height=178 mce_src="http://blogs.msdn.com/blogfiles/vsdata/WindowsLiveWriter/DebuggingwithLocalDatabaseFile_89AB/clip_image005_2659ca89-c6a6-4180-8c4c-831c45a19192.png"&gt;&lt;/A&gt; &lt;BR&gt;One thing worth mentioning is, if you leave the database file outside of your project, the path of the database file will actually be hardcoded into your project. Before deployment, please update this setting and replace the full path with a relative path.&lt;/P&gt;
&lt;P&gt;Cheers!&lt;/P&gt;
&lt;P&gt;08/04 Update: this &lt;A href="http://msdn.microsoft.com/en-us/library/ms246989(VS.100).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ms246989(VS.100).aspx"&gt;MSDN How to&lt;/A&gt; is helpful too. It describes in detail how to manage local data files in your project.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9853950" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsdata/archive/tags/SQL+Server+Express/default.aspx">SQL Server Express</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Business+Object/default.aspx">Business Object</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/SQL+Server+Compact/default.aspx">SQL Server Compact</category></item><item><title>My experience on Connect Feedbacks</title><link>http://blogs.msdn.com/vsdata/archive/2009/06/09/my-experience-on-connect-feedbacks.aspx</link><pubDate>Tue, 09 Jun 2009 19:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9711024</guid><dc:creator>John Chen</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/vsdata/comments/9711024.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsdata/commentrss.aspx?PostID=9711024</wfw:commentRss><wfw:comment>http://blogs.msdn.com/vsdata/rsscomments.aspx?PostID=9711024</wfw:comment><description>&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Recently I have been working with some Visual Studio feedbacks reported through &lt;/FONT&gt;&lt;A href="http://connect.microsoft.com/" mce_href="http://connect.microsoft.com/"&gt;&lt;FONT color=#800080 size=3 face=Calibri&gt;Microsoft Connect&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt;. I found that some feedbacks may contain multiple unrelated issues.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;On the other hand, one issue may be reported several times by the same person in different feedbacks. There are also issues about crashing, memory, performance, debugging, etc. I will share some tips here that I think can benefit both Microsoft and our customers. &lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;1. Report only one issue in one feedback. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;As you may know that there are many teams working for Visual Studio and Dot Net framework.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Different issues are more likely handled by different teams, product units or even divisions. Multiple issues in one feedback will be hard to track and individual issues may not be routed to the right team promptly. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;2. Do come back to check the feedback often. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;We may often ask for detail repro information in order to reproduce the issue. If the issue has been resolved as not repro but you have more info, don’t worry or get angry, just reactivate the issue and adding the new information. Some customers tend to open new feedbacks in this case. I think stick to the old issue and continue the communication would be a better approach. Of course, if the time span is too long, a new issue is appropriate. &lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;3. When a crashing occurs and you see the dialog asking you to send the feedback, click the send button. This will send the important crashing information (like call stack) to Microsoft and the information will be analyzed.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;4. If you have issues regarding crashes, hangs, slowness, or out of memory errors, you can collect the information with the performance diagnostic tool available &lt;/FONT&gt;&lt;A href="https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=16951" mce_href="https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=16951"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;here&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt; (you need to log in as a connect user first). &lt;SPAN style="COLOR: #1f497d"&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;5. If you want to use the VS debugger to get a call stack or dump file of an exception of VS, you can do so with a second instance of Visual Studio, see the post I have &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/vsdata/archive/2009/06/08/how-to-get-call-stack-of-visual-studio.aspx" mce_href="http://blogs.msdn.com/vsdata/archive/2009/06/08/how-to-get-call-stack-of-visual-studio.aspx"&gt;&lt;FONT color=#800080 size=3 face=Calibri&gt;here&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt; .&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Hope this helps. &lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9711024" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsdata/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/VS2010/default.aspx">VS2010</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Connect/default.aspx">Connect</category><category domain="http://blogs.msdn.com/vsdata/archive/tags/Debugging/default.aspx">Debugging</category></item></channel></rss>