<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4702950152327976706</id><updated>2012-01-30T02:38:11.198-07:00</updated><category term='Windows Mobile'/><category term='MS Access'/><category term='MS Integration Services'/><category term='MS Dynamics CRM'/><category term='Outlook'/><category term='Regular Expressions'/><category term='.Net'/><category term='AJAX'/><category term='Math'/><category term='Plug-ins'/><category term='Security'/><category term='Robotics'/><category term='Oracle'/><category term='IDE'/><category term='Programming'/><category term='ASP.NET'/><category term='Testing'/><category term='WF'/><category term='iPhoto'/><category term='AI'/><category term='Mac OS X'/><category term='Google Mini'/><category term='MS Office'/><category term='Windows 7'/><category term='Network'/><category term='LINQ'/><category term='OVSD'/><category term='CSS'/><category term='MS SQL Server'/><category term='Version Control'/><category term='Web Services'/><category term='SharePoint'/><category term='RIA Services'/><category term='Domain Service'/><category term='Generics'/><category term='Java'/><category term='Registry'/><category term='IIS'/><category term='LDAP'/><category term='VBA'/><category term='PHP'/><category term='Windows Phone 7'/><category term='WCF'/><category term='Database'/><category term='Batch Files'/><category term='System Admin'/><category term='ADO.NET Entity Framework'/><category term='HTML'/><category term='Tools'/><category term='Dynamic Data'/><category term='JSF'/><category term='Methodology'/><category term='JavaScript'/><category term='WF4'/><category term='Silverlight'/><title type='text'>Just geeks</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default?start-index=101&amp;max-results=100'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>339</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-5452390787773020176</id><published>2012-01-19T15:24:00.001-07:00</published><updated>2012-01-25T17:17:05.314-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MS SQL Server'/><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>SQL Server Resources</title><content type='html'>&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ff647793.aspx" target="_blank"&gt;Improving SQL Server Performance&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;This is just one chapter an online book called Improving .NET Application Performance and Scalability.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms187101.aspx" target="_blank"&gt;Locking and Row Versioning&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Pay special attention to the links on the left navigation for information on these topics&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.sommarskog.se/dynamic_sql.html" target="_blank"&gt;The Curse and Blessing of Dynamic SQL&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Very in-depth article on issues associated with Dynamic SQL including escaping quotes.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a title="Arrays and Lists in SQL Server 2008" href="http://www.sommarskog.se/arrays-in-sql-2008.html"&gt;Arrays and Lists in SQL Server 2008&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Very in-depth article on how to work with Arrays and Lists (or the lack thereof). It gives solutions for the different versions of SQL Server.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a title="Using a Table Valued Function in a JOIN" href="http://geekswithblogs.net/bsherwin/archive/2007/06/29/113567.aspx"&gt;Using a Table Valued Function in a JOIN&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Another solution for parsing delimited string. See the above link &lt;a title="Arrays and Lists in SQL Server 2008" href="http://www.sommarskog.se/arrays-in-sql-2008.html"&gt;Arrays and Lists in SQL Server 2008&lt;/a&gt; for more solutions.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms189858.aspx" target="_blank"&gt;Reorganizing and Rebuilding Indexes&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a title="SQL Server script to rebuild all indexes for all tables and all databases" href="http://www.mssqltips.com/sqlservertip/1367/sql-server-script-to-rebuild-all-indexes-for-all-tables-and-all-databases/"&gt;SQL Server script to rebuild all indexes for all tables and all databases&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This is a very handy script to rebuild all your indexes for a list of databases. I call this after a I import a bunch of data into tables. I also call sp_updatestats &lt;a href="http://benchmarkitconsulting.com/colin-stasiuk/2009/02/11/update-statistics-before-or-after-an-index-rebuild/" target="_blank"&gt;AFTER&lt;/a&gt; to update stats on the non-indexed columns. Or force all stats on individual tables (including indexes, columns, etc) to be updated by using UPDATE STATISTICS dbo.MyTableHere WITH FULLSCAN. Since the only time data changes when I import it, I have turned off automatic stats update at the database level so that the query optimizer doesn’t have to make sure the stats are up to date. BTW, rebuilding indexes and then calling sp_updatestats didn’t always update all the stats if it thought they didn’t need to be updated. I prefer to force the update after the import.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms130214.aspx" target="_blank"&gt;SQL Server 2008 R2 Books Online (from Microsoft)&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This is an excellent resource for lots of topics on SQL Server.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://msdn.microsoft.com/en-us/library/ms190421.aspx" href="http://msdn.microsoft.com/en-us/library/ms190421.aspx" target="_blank"&gt;Optimizing Bulk Import Performance&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-5452390787773020176?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/5452390787773020176/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=5452390787773020176' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/5452390787773020176'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/5452390787773020176'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2012/01/sql-server-resources.html' title='SQL Server Resources'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-3380036879471666269</id><published>2012-01-10T13:47:00.001-07:00</published><updated>2012-01-10T13:47:32.472-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='System Admin'/><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><title type='text'>Check if application is running via command line (in Windows)</title><content type='html'>&lt;p&gt;You are probably familiar with Task Manager in Windows. It is very useful for seeing what processes are running. Wouldn’t it be great if there was a command line tool that did the same thing. As it turns out, there is one that is built into Windows. It is called tasklist. It is very easy to use. &lt;/p&gt;  &lt;p&gt;In its simplest usage just type tasklist at the command prompt. You will get a list very much like the Processes tab in Task Manager. &lt;/p&gt;  &lt;p&gt;The cool thing is it has filtering built in. For example, if you just wanted to see the notepad processes you could do something like: tasklist /FI &amp;quot;IMAGENAME eq notepad.exe&amp;quot;&lt;/p&gt;  &lt;p&gt;Type tasklist /? to get a details on the other options you have. There are lots of them. You can specify a remote system, list all tasks currently using a exe or dll, display services hosted in each process, format output as a table, list, or csv, use other filters, turn off headers, etc.&lt;/p&gt;  &lt;p&gt;Very nice little tool to have.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-3380036879471666269?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/3380036879471666269/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=3380036879471666269' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/3380036879471666269'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/3380036879471666269'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2012/01/check-if-application-is-running-via.html' title='Check if application is running via command line (in Windows)'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-5329071364401867883</id><published>2012-01-10T09:30:00.001-07:00</published><updated>2012-01-11T08:59:10.628-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='System Admin'/><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><title type='text'>Zabbix Server Tips</title><content type='html'>&lt;p&gt;Basic installation information including default passwords are located &lt;a href="http://www.zabbix.com/documentation/1.8/manual/installation/appliance" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;To connect to the Zabbix server I use putty.exe. This works well. The default username and password are root/zabbix.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Topics&lt;/h3&gt;  &lt;h4&gt;Zabbix Server is down&lt;/h4&gt;  &lt;p&gt;The Zabbix Dashboard web page shows the status of things. In particular sometimes I see (under the section called Status of Zabbix) that the Parameter &lt;strong&gt;Zabbix server is running&lt;/strong&gt; is No instead of Yes. This means that Zabbix is essentially down. This can be confusing since the Zabbix web page is showing the Dashboard. The important thing to understand is Zabbix has many components. For instance, the Dashboard is actually just a web application that reads data from a database. Since we are able to see the Dashboard that means that the database (MySQL) and the web server (Apache) are both still up and working. However, since the Zabbix server itself is not running according to the Dashboard you should also be able to see under Monitoring tab | Latest data that data has not been collected for a while (since Zabbix server went down). You can also confirm that the Zabbix server is not running by using putty.exe to go to the console and verify that the Zabbix server is not running using something similar to &lt;font color="#008000"&gt;&lt;strong&gt;ps -e | grep &amp;quot;zabbix_server&amp;quot;&lt;/strong&gt;&lt;/font&gt;. You can always start it manually by executing the Zabbix server &lt;font color="#008000"&gt;&lt;strong&gt;/usr/sbin/zabbix_server&lt;/strong&gt;&lt;/font&gt;, but a better plan would be to use &lt;font color="#008000"&gt;&lt;strong&gt;service zabbix_server start&lt;/strong&gt;&lt;/font&gt;. Alternatively, you could bounce the box as a last resort using something like &lt;font color="#008000"&gt;&lt;strong&gt;shutdown –r now&lt;/strong&gt;&lt;/font&gt;.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Checking Log Files&lt;/h4&gt;  &lt;p&gt;The first step is to locate the log files. The best way to do that is probably go to the &lt;strong&gt;&lt;font color="#008000"&gt;/etc/zabbix/zabbix_server.conf&lt;/font&gt;&lt;/strong&gt; configuration file to see where it is. You can do that using &lt;strong&gt;&lt;font color="#008000"&gt;less /etc/zabbix/zabbix_server.conf&lt;/font&gt;&lt;/strong&gt; and then type / and then LogFile and then enter to highlight the file. You will likely see that the LogFile variable is set to &lt;font color="#008000"&gt;&lt;strong&gt;/var/log/zabbix/zabbix_server.log&lt;/strong&gt;&lt;/font&gt;. Type q to exit less. Now go to the&lt;font color="#000000"&gt;&lt;strong&gt; /var/log/zabbix&lt;/strong&gt;&lt;/font&gt; directory. Here you will see a server_problems.log and zabbix_server.log. Open these log files and see what you can see using less or something similar.&lt;/p&gt;  &lt;h4&gt;&amp;#160;&lt;/h4&gt;  &lt;h4&gt;What ports is zabbix listening on&lt;/h4&gt;  &lt;p&gt;netstat -ntpl | grep 'zabbix'&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Check built in items&lt;/h4&gt;  &lt;p&gt;From the machine you are monitoring, you can use the Zabbix agent to test a item by using the syntax &lt;strong&gt;&lt;font color="#008000"&gt;zabbix_agentd.exe -t proc.num[notepad.exe]&lt;/font&gt;. &lt;/strong&gt;In this example I am using the proc.num to determine how processes of notepad.exe are running, but you could replace proc.num with any of the built in items. You will get the result immediately on the command line. In this case I got [u|1] which means 1 instance of notepad.exe is running. I then add a new item for that server using the Zabbix web configuration screens. No client (the machine you are monitoring) side configuration needed.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Checking how many instances of an application are running&lt;/h4&gt;  &lt;p&gt;This can all be done using the Zabbix configuration screens. All you have to do is navigate to the host (or template if you want to perform this check on multiple machines) you want to check and add an item. Click the Items link and then the Create Item button on the top right. Now fill in the form for the new item. In particular, the key you select is the important piece. You need to select proc.num and then edit the key value so that it is proc.num[notepad.exe] if you are monitoring the number of instances of notepad.exe. You will need to change it as desired to you process name (use Task Manager’s process tab to view these).&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Documentation of all the built in items&lt;/h4&gt;  &lt;p&gt;&lt;a title="http://www.zabbix.com/documentation/1.8/manual/config/items" href="http://www.zabbix.com/documentation/1.8/manual/config/items"&gt;http://www.zabbix.com/documentation/1.8/manual/config/items&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-5329071364401867883?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/5329071364401867883/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=5329071364401867883' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/5329071364401867883'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/5329071364401867883'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2012/01/zabbix-server-tips.html' title='Zabbix Server Tips'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-6522183204797759242</id><published>2012-01-05T10:35:00.001-07:00</published><updated>2012-01-05T10:51:15.342-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Dynamic Data'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Adding Time Zone Support to Dynamic Data</title><content type='html'>&lt;p&gt;I love the ASP.NET Dynamic Data architecture. It really makes developing applications so much easier. It is quite easy to extend once you get used to how it all works. I always store my dates/times as UTC in the database. This means by default that is what users will see when the Dynamic Data application displays the date/time. Most people don’t think about UTC, so it is of little meaning to most people. In an ideal world all date/time fields would be displayed in the current users time zone of choice. &lt;/p&gt;  &lt;p&gt;This can be done quite easily actually when you are using Dynamic Data. The reason is that all the date/time fields are displayed and edited using a common user controls that you have in your project. In particular if you open your ASP.NET Dynamic Data web site / project you will see there is a &lt;font color="#008000"&gt;DynamicData &lt;/font&gt;directory and then a &lt;font color="#008000"&gt;FieldTemplates&lt;/font&gt; directory. Here you will find two user controls: DateTime.ascx and DateTime_Edit. These are the controls that are used to display&amp;#160; and edit respectively all data/time data in your DynamicData application. So, all we have to do is convert UTC to desired timezone before it is displayed, and on save we need to convert desired timezone to UTC. That way the user will see the date/time in a time zone they understand, but the date/time is stored in UTC in the database. &lt;/p&gt;  &lt;h2&gt;Enhancing DateTime.ascx&lt;/h2&gt;  &lt;p&gt;The key to extending the DateTime.ascx control is knowing where to hook into the architecture of Dynamic Data Field Templates. The answer for this control is to override the FieldValue property.&lt;/p&gt; &lt;span style="color: #008000"&gt;   &lt;pre class="csharpcode"&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; FieldValue&lt;br /&gt;        {&lt;br /&gt;            get&lt;br /&gt;            {&lt;br /&gt;                var dateUI =  Convert.ToDateTime(&lt;span class="kwrd"&gt;base&lt;/span&gt;.FieldValue).GetDateTimeForUI();&lt;br /&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt; dateUI;&lt;br /&gt;            }&lt;br /&gt;            set&lt;br /&gt;            {&lt;br /&gt;                &lt;span class="kwrd"&gt;base&lt;/span&gt;.FieldValue = &lt;span class="kwrd"&gt;value&lt;/span&gt;;&lt;br /&gt;            }&lt;br /&gt;        }&lt;/pre&gt;&lt;br /&gt;  &lt;style type="text/css"&gt;&lt;br /&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;That is all that is required. I’ll show the meat of the &lt;font color="#008000"&gt;GetDateTimeForUI()&lt;/font&gt; extension below. Alternatively, you could do your own time zone conversion here. The key is that this is where you convert the &lt;font color="#008000"&gt;base.FieldValue&lt;/font&gt; (which is UTC) to the time zone you desire.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Enhancing DateTime_Edit.ascx&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;To extending the DateTime_Edit.ascx control the key is again knowing where to hook into the architecture of Dynamic Data Field Templates. The answer for this control is to override the &lt;font color="#008000"&gt;DataBind()&lt;/font&gt; method and the &lt;font color="#008000"&gt;ConvertEditedValue()&lt;/font&gt; method.&lt;/p&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;&lt;span style="color: #008000"&gt;&lt;br /&gt;    &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; DataBind()&lt;br /&gt;{&lt;br /&gt;    &lt;span class="kwrd"&gt;base&lt;/span&gt;.DataBind();&lt;br /&gt; &lt;br /&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (Mode == DataBoundControlMode.Edit &amp;amp;&amp;amp; FieldValue != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;    {&lt;br /&gt;        TextBox1.Text = DateTime.Parse(FieldValueEditString).GetDateTimeForUI().ToString();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;&lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; ConvertEditedValue(&lt;span class="kwrd"&gt;string&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;    &lt;span class="kwrd"&gt;string&lt;/span&gt; valueToSave = DateTime.Parse(&lt;span class="kwrd"&gt;value&lt;/span&gt;).GetUtcDateTime().ToString();&lt;br /&gt; &lt;br /&gt;    &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;base&lt;/span&gt;.ConvertEditedValue(valueToSave);&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;    &lt;style type="text/css"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;That is all that is required. I’ll show the meat of the &lt;font color="#008000"&gt;GetUtcDateTime()&lt;/font&gt; extension below. Alternatively, you could do your own time zone conversion here. The key is that in the &lt;font color="#008000"&gt;DataBind()&lt;/font&gt; method you convert the &lt;font color="#008000"&gt;FieldValueEditString&lt;/font&gt; (which is in UTC) to the time zone you desire, and that in the &lt;font color="#008000"&gt;ConvertEditedValue()&lt;/font&gt; method you convert &lt;font color="#008000"&gt;value&lt;/font&gt; (which is in the desired time zone) to UTC.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Doing the actual Timezone Conversion&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;I implemented the conversion methods as an extensions to the DateTime class. This is just for ease of use, but you can do this however you see best. In .NET 3.5 Microsoft added a very nice class called TimeZoneInfo. It makes converting between time zones trivial. The best thing is that it takes Day light savings into consideration when it does the conversion. Below is my implementation for displaying date/times in Pacific Standard Time (PST). For simplicity and limiting scope,&amp;#160; in this case I have hard coded the desired timezone, but you could pull it from the Profile of the current user if you collect that info from the user in some UI.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;font color="#008000"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; MyApp.Helpers&lt;br /&gt;{&lt;br /&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; DateTimeExtensions&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="rem"&gt;// call when displaying value from db to the ui&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; DateTime GetDateTimeForUI(&lt;span class="kwrd"&gt;this&lt;/span&gt; DateTime dateAsUtc)&lt;br /&gt;        {&lt;br /&gt;            DateTime dateForUI = TimeZoneInfo.ConvertTime(dateAsUtc, TimeZoneInfo.Utc, TimeZoneInfo.FindSystemTimeZoneById(Config.DefaultTimeZone));&lt;br /&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; dateForUI;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;// call when saving value to db from the ui&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; DateTime GetUtcDateTime(&lt;span class="kwrd"&gt;this&lt;/span&gt; DateTime dateFromUI)&lt;br /&gt;        {&lt;br /&gt;            DateTime dateAsUtc = TimeZoneInfo.ConvertTime(dateFromUI, TimeZoneInfo.FindSystemTimeZoneById(Config.DefaultTimeZone), TimeZoneInfo.Utc);&lt;br /&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; dateAsUtc;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/font&gt;&lt;/pre&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-6522183204797759242?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/6522183204797759242/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=6522183204797759242' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/6522183204797759242'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/6522183204797759242'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2012/01/adding-time-zone-support-to-dynamic.html' title='Adding Time Zone Support to Dynamic Data'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-3519371852350499555</id><published>2011-12-22T15:08:00.001-07:00</published><updated>2011-12-27T15:06:42.558-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='MS SQL Server'/><category scheme='http://www.blogger.com/atom/ns#' term='MS Access'/><title type='text'>Converting CLng in MS Access SQL to T-SQL (SQL Server)</title><content type='html'>&lt;p&gt;The problem I need to solve is how do I reproduce the exact functionality of the CLng (function built-in to MS Access SQL) in MS SQL Sever. The answer is not so difficult, but knowing what the question to ask was not so obvious. &lt;/p&gt;  &lt;p&gt;After much frustration I finally realized that how &lt;strong&gt;CLng&lt;/strong&gt; in MS Access SQL works is actually quite unintuitive. My situation can be explained quite simply. I have a query in MS Access that I need to convert to run completely on SQL Server. In parts of the MS Access queries the CLng function is used. CLng is similar to Round() in SQL Server, but is not the same particularly when it comes to values that end in .5. Initially I thought it would just truncate the decimals of a double. For example, I thought CLng(.5) should be 1, but MS Access says it is 0. Interestingly, CLng(3.5) is 4, not 3 and CLng(2.5) is 2, not 3. This behavior is very inconsistent to me, but I need to reproduce it on SQL Server using T-SQL so that I can compare the queries. &lt;/p&gt;  &lt;p&gt;After some reading about issues related to rounding in general on &lt;a href="http://en.wikipedia.org/wiki/Rounding#Stochastic_rounding" target="_blank"&gt;Wikipedia&lt;/a&gt; I found out that there are many ways to round. After reading a &lt;a href="http://support.microsoft.com/kb/196652" target="_blank"&gt;technical article&lt;/a&gt; from Microsoft I found out that indeed VBA (and appears to be MS Access SQL) do not round the same as MS SQL Server. From this I learned the key to the solution; the CLng function in MS Access implements rounding using the Banker’s Rounding method described in both of the above sources. I did find an implementation of Banker’s Rounding once I knew what to search for. I found a good solution &lt;a href="http://www.sqlservercentral.com/Forums/Topic246556-8-1.aspx" target="_blank"&gt;here&lt;/a&gt;. I have copy and pasted the solution below.&lt;/p&gt;  &lt;p&gt;Here is that function you can execute on SQL Server that will do the same thing as Clng on MS Access SQL because it is an implementation of Banker’s Rounding.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;font color="#008000"&gt;create function MSAccessClng(@x as float)     &lt;br /&gt;returns int      &lt;br /&gt;as      &lt;br /&gt;BEGIN      &lt;br /&gt;Declare @DecimalPlaces as tinyint      &lt;br /&gt;Set @DecimalPlaces = 0&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;set @x = @x * power(10, @DecimalPlaces)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;return     &lt;br /&gt;&amp;#160; case when @x = floor(@x) then @x      &lt;br /&gt;&amp;#160; else      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; case sign(ceiling(@x) - 2*@x + floor(@x))      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; when 1 then floor(@x)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; when -1 then ceiling(@x)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; else 2*round(@x/2,0) end      &lt;br /&gt;&amp;#160; end / power(10, @DecimalPlaces)       &lt;br /&gt;END&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Now you have a function you can use on SQL Server just like you have on MS Access. Keep in mind this is a Scalar-valued function and this means there is a performance penalty for using it, but if you need this functionality you need the functionality.&lt;/p&gt;  &lt;p&gt;Below are different examples of what I used to test that the functionality is the same on MS Access and MS SQL Server (T-SQL). Notice, the ones that say SAME means that CLng() has the same functionality as cast(). The ones that say DIFFERENCE means that the special logic was needed to implement differences. You can also see the usage of the function.&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;-- SAME      &lt;br /&gt;select clng(-3.3) -- -3       &lt;br /&gt;select cast(-3.3 as int) -- -3       &lt;br /&gt;select Round(-3.3, 0) -- 3       &lt;br /&gt;select dbo.MSAccessClng(-3.3) -- -3&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;-- SAME      &lt;br /&gt;select clng(-0.3) -- 0       &lt;br /&gt;select cast(-0.3 as int) -- 0       &lt;br /&gt;select round(-.3,0) -- 0       &lt;br /&gt;select dbo.MSAccessClng(-0.3) -- 0&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;-- DIFFERENCE      &lt;br /&gt;select clng(-3.5) -- -4       &lt;br /&gt;select cast(-3.5 as int) -- -3       &lt;br /&gt;select Round(-3.5,0) -- -4       &lt;br /&gt;select dbo.MSAccessClng(-3.5) -- -4&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;-- SAME      &lt;br /&gt;select clng(-0.5) -- 0       &lt;br /&gt;select cast(-0.5 as int) -- 0       &lt;br /&gt;select round(-0.5, 0) -- error       &lt;br /&gt;select dbo.MSAccessClng(-0.5) -- -0&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;-- DIFFERENCE      &lt;br /&gt;select clng(-0.51) -- -1       &lt;br /&gt;select cast(-0.51 as int) -- 0       &lt;br /&gt;select round(-0.51, 0) -- error       &lt;br /&gt;select dbo.MSAccessClng(-0.51) -- -1&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;-- DIFFERENCE      &lt;br /&gt;select clng(-0.8) -- -1       &lt;br /&gt;select cast(-0.8 as int) -- 0       &lt;br /&gt;select round(-0.8, 0) -- error       &lt;br /&gt;select dbo.MSAccessClng(-0.8) -- -1&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;-- SAME      &lt;br /&gt;select clng(-1) -- -1       &lt;br /&gt;select cast(-1 as int) -- -1       &lt;br /&gt;select round(-1, 0) -- -1       &lt;br /&gt;select dbo.MSAccessClng(-1) -- -1&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;-- SAME      &lt;br /&gt;select clng(-100000) -- -10000       &lt;br /&gt;select cast(-100000 as int) -- -10000       &lt;br /&gt;select round(-100000, 0) -- -10000       &lt;br /&gt;select dbo.MSAccessClng(-100000) -- -10000&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;font color="#008000"&gt;-- SAME      &lt;br /&gt;select clng(3.3) -- 3       &lt;br /&gt;select cast(3.3 as int) -- 3       &lt;br /&gt;select Round(3.3, 0) -- 3       &lt;br /&gt;select dbo.MSAccessClng(3.3) -- 3&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;-- SAME      &lt;br /&gt;select clng(0.3) -- 0       &lt;br /&gt;select cast(0.3 as int) -- 0       &lt;br /&gt;select round(0.3,0) -- 0       &lt;br /&gt;select dbo.MSAccessClng(0.3) -- 0&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;-- DIFFERENCE      &lt;br /&gt;select clng(3.5) -- 4       &lt;br /&gt;select cast(3.5 as int) -- 3       &lt;br /&gt;select Round(3.5,0) -- 4       &lt;br /&gt;select dbo.MSAccessClng(3.5) -- 4&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;-- SAME      &lt;br /&gt;select clng(0.5) -- 0       &lt;br /&gt;select cast(0.5 as int) -- 0       &lt;br /&gt;select round(0.5, 0) -- error       &lt;br /&gt;select dbo.MSAccessClng(0.5) -- 0&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;-- DIFFERENCE      &lt;br /&gt;select clng(0.51) -- 1       &lt;br /&gt;select cast(0.51 as int) -- 0       &lt;br /&gt;select round(0.51, 0) -- error       &lt;br /&gt;select dbo.MSAccessClng(0.51) -- 1&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;-- DIFFERENCE      &lt;br /&gt;select clng(0.8) -- 1       &lt;br /&gt;select cast(0.8 as int) -- 0       &lt;br /&gt;select round(0.8, 0) -- error       &lt;br /&gt;select dbo.MSAccessClng(0.8) -- 1&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;-- SAME      &lt;br /&gt;select clng(1) -- 1       &lt;br /&gt;select cast(1 as int) -- 1       &lt;br /&gt;select round(1, 0) -- 1       &lt;br /&gt;select dbo.MSAccessClng(1) – 1&lt;/font&gt;&lt;/p&gt; &lt;font color="#008000"&gt;-- DIFFERENCE    &lt;br /&gt;select clng(34.5) -- 34     &lt;br /&gt;select cast(34.5 as int) -- 34     &lt;br /&gt;select Round(34.5,0) -- 35     &lt;br /&gt;select dbo.MSAccessClng(34.5) -- 4&lt;/font&gt;   &lt;p&gt;&lt;font color="#008000"&gt;-- DIFFERENCE      &lt;br /&gt;select clng(0) -- 0       &lt;br /&gt;select cast(0 as int) -- 0       &lt;br /&gt;select round(0, 0) -- 0       &lt;br /&gt;select dbo.MSAccessClng(0) – 0&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;-- SAME      &lt;br /&gt;select clng(100000) -- 10000       &lt;br /&gt;select cast(100000 as int) -- 10000       &lt;br /&gt;select round(100000, 0) -- 10000       &lt;br /&gt;select dbo.MSAccessClng(100000) -- 10000&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-3519371852350499555?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/3519371852350499555/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=3519371852350499555' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/3519371852350499555'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/3519371852350499555'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/12/converting-clng-in-ms-access-sql-to-t.html' title='Converting CLng in MS Access SQL to T-SQL (SQL Server)'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-1750535508353340294</id><published>2011-12-06T15:32:00.001-07:00</published><updated>2011-12-06T15:33:52.441-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MS SQL Server'/><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>Get First or Second Word using T-SQL</title><content type='html'>&lt;p&gt;When working with SQL (T-SQL) I often need to work with words with-in a string (nvarchar or varchar). For instance I want to display only the first word (first name in this case) of a field (FullName in this case) or maybe the second word in other cases. Words are funny things, they can be separated by commas, spaces, hyphens, and other characters such as semi-colons, exclamation point, parenthesis, brackets perhaps. &lt;/p&gt;  &lt;p&gt;Below is the code to create a Scalar-valued Functions in SQL Server (T-SQL) that get the first word or second word.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;/h3&gt;  &lt;h3&gt;Get First Word&lt;/h3&gt;  &lt;p&gt;&lt;font color="#008000"&gt;create function GetFirstWord(@Name as nvarchar(100))     &lt;br /&gt;returns nvarchar(100)      &lt;br /&gt;as      &lt;br /&gt;BEGIN&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Declare @FirstWord as nvarchar(100)     &lt;br /&gt;Declare @SpaceIdx as int&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;-- convert word separators to space for simplicity     &lt;br /&gt;Set @Name = Replace(@Name, ',', ' ') -- comma to space      &lt;br /&gt;Set @Name = Replace(@Name, '.', ' ') -- period to space      &lt;br /&gt;Set @Name = Replace(@Name, '-', ' ') -- hyphen to space&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Set @SpaceIdx = CHARINDEX(' ', @Name)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;if (@SpaceIdx &amp;gt; 0)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; SET @FirstWord = SUBSTRING(@Name, 0, @SpaceIdx)      &lt;br /&gt;else -- all one word      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; SET @FirstWord = @Name&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;return @FirstWord;     &lt;br /&gt;END;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Get Second Word&lt;/h3&gt;  &lt;p&gt;&lt;font color="#008000"&gt;create function GetSecondWord(@Name as nvarchar(100))     &lt;br /&gt;returns nvarchar(100)      &lt;br /&gt;as      &lt;br /&gt;BEGIN&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Declare @SecondWord as nvarchar(100)     &lt;br /&gt;Declare @AfterWord1 as nvarchar(100)      &lt;br /&gt;Declare @SpaceIdx as int      &lt;br /&gt;Declare @Space2Idx as int&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;-- convert word separators to space for simplicity     &lt;br /&gt;Set @Name = Replace(@Name, ',', ' ') -- comma to space      &lt;br /&gt;Set @Name = Replace(@Name, '.', ' ') -- period to space      &lt;br /&gt;Set @Name = Replace(@Name, '-', ' ') -- hyphen to space&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Set @SpaceIdx = CHARINDEX(' ', @Name)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;if (@SpaceIdx = 0) return ''&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Set @AfterWord1 = SUBSTRING(@Name, @SpaceIdx+1, len(@Name) - @SpaceIdx)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Set @Space2Idx = CHARINDEX(' ', @AfterWord1)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;if (@Space2Idx &amp;gt; 0)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; SET @SecondWord = SUBSTRING(@AfterWord1, 0, @Space2Idx)      &lt;br /&gt;else -- remainder of word      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; SET @SecondWord = @AfterWord1&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;-- if second word is the same as the original, then we only have one word     &lt;br /&gt;if @SecondWord = @Name return ''&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;return @SecondWord;     &lt;br /&gt;END;&lt;/font&gt;&lt;/p&gt;  &lt;h3&gt;Usage&lt;/h3&gt;  &lt;p&gt;select GetFirstWord(‘Joe Smith’)&lt;/p&gt;  &lt;p&gt;returns: Joe&lt;/p&gt;  &lt;p&gt;select GetSecondWord(‘Joe Smith’)&lt;/p&gt;  &lt;p&gt;returns: Smith&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Extending the Code&lt;/h3&gt;  &lt;p&gt;In the example above was just concerned with with commas, spaces, and hyphens, but you can extend the code quite easily by adding additional replace statements.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Note on Performance&lt;/h3&gt;  &lt;p&gt;I have implemented these functions as Scalar-valued functions which are known to incur a noticeable performance hit when you use them in a select statement.&amp;#160; &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-1750535508353340294?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/1750535508353340294/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=1750535508353340294' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1750535508353340294'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1750535508353340294'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/12/get-first-or-second-word-using-t-sql.html' title='Get First or Second Word using T-SQL'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-3582802745604135500</id><published>2011-12-06T14:16:00.001-07:00</published><updated>2011-12-06T14:16:57.167-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MS SQL Server'/><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>Efficiently Counting Spaces using T-SQL</title><content type='html'>&lt;p&gt;Let’s assume you have a table called Person and it has a column called FullName. As you might expect, the FullName is really just a concatenation of the persons first and last name separated by a space. If I want to get some stats on how many people have only one space (implying two words only) it is actually quite easy to figure this out. Consider the following SQL statement&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;select FullName from Person&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Let pretend it returns something like&lt;/p&gt;  &lt;p&gt;&lt;font color="#666666"&gt;Ben Wheel      &lt;br /&gt;James Johnson Jr.       &lt;br /&gt;Jane Dela Cruz       &lt;br /&gt;Jeff Jones       &lt;br /&gt;Lance Strong&lt;/font&gt;&lt;/p&gt;  &lt;h3&gt;Exactly 1 Space&lt;/h3&gt;  &lt;p&gt;To get all rows that have &lt;strong&gt;exactly one&lt;/strong&gt; space in them you could do the following&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;select FullName from Person      &lt;br /&gt;where len(FullName) - len(Replace(FullName, ' ', '')) = &lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;strong&gt;1&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#666666"&gt;Jeff Jones      &lt;br /&gt;Lance Strong       &lt;br /&gt;Ben Wheel&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#666666"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;h3&gt;Exactly 2 Space&lt;/h3&gt;  &lt;p&gt;To get all rows that have &lt;strong&gt;exactly one&lt;/strong&gt; space in them you could do the following&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;select FullName from Person      &lt;br /&gt;where len(FullName) - len(Replace(FullName, ' ', '')) = &lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;strong&gt;2&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#666666"&gt;James Johnson Jr.      &lt;br /&gt;Jane Dela Cruz&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#666666"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;h3&gt;Less than or equal to 3 Space&lt;/h3&gt;  &lt;p&gt;To get all rows that have &lt;strong&gt;exactly one&lt;/strong&gt; space in them you could do the following&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;select FullName from Person      &lt;br /&gt;where len(FullName) - len(Replace(FullName, ' ', '')) &lt;font color="#ff0000"&gt;&lt;strong&gt;&amp;lt;&lt;/strong&gt;&lt;/font&gt;= &lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;strong&gt;3&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#666666"&gt;Ben Wheel      &lt;br /&gt;James Johnson Jr.       &lt;br /&gt;Jane Dela Cruz       &lt;br /&gt;Jeff Jones       &lt;br /&gt;Lance Strong&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;As you can see it is relatively easy to count occurrences of a character using T-SQL. You can expand on these queries just by changing the stuff in red.&lt;font color="#666666"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-3582802745604135500?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/3582802745604135500/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=3582802745604135500' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/3582802745604135500'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/3582802745604135500'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/12/efficiently-counting-spaces-using-t-sql.html' title='Efficiently Counting Spaces using T-SQL'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-3761360061227579736</id><published>2011-11-02T13:58:00.001-07:00</published><updated>2011-11-02T13:58:55.409-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><category scheme='http://www.blogger.com/atom/ns#' term='Registry'/><title type='text'>Open 2 Excel Files in separate windows</title><content type='html'>&lt;p&gt;WARNING: Changing your registry can be dangerous to the health of your computer. Do so at your own risk.&lt;/p&gt;  &lt;p&gt;This change makes it so when you click an Excel file it will ALWAYS open in a new window (a different instance of Excel)&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;.XLSX&lt;/h2&gt;  &lt;ol&gt;   &lt;li&gt;I highly recommend you back up your registry before making any changes. &lt;/li&gt;    &lt;li&gt;Open regedit.exe &lt;/li&gt;    &lt;li&gt;Navigate to &lt;strong&gt;HKEY_CLASSES_ROOT/Excel.Sheet.12/shell/Open/command&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;Open (Double-click) the key called &lt;strong&gt;(Default)&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;Change the value from      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;&amp;quot;C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.EXE&amp;quot; /e        &lt;br /&gt;&lt;/strong&gt;to &lt;strong&gt;&amp;quot;C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.EXE&amp;quot; /e “%1”&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;Click the OK button &lt;/li&gt;    &lt;li&gt;Below the &lt;strong&gt;(Default)&lt;/strong&gt; key you will see a key with the name &lt;strong&gt;command&lt;/strong&gt;.       &lt;br /&gt;Right click it and select &lt;strong&gt;Rename&lt;/strong&gt;.       &lt;br /&gt;Change the name to something else (it doesn’t matter what) &lt;/li&gt;    &lt;li&gt;Your screen should now look something like the following (I appended bv to the command key, but you should probably use something different)      &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/-IZrenrs3SuI/TrGu04RfOmI/AAAAAAABLkI/yCZhJ1GrqSg/s1600-h/image%25255B4%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/-bxJzLJbycOE/TrGu2IOfHcI/AAAAAAABLkQ/gKmCy8CKp2Q/image_thumb%25255B5%25255D.png?imgmax=800" width="1257" height="309" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Navigate to &lt;strong&gt;HKEY_CLASSES_ROOT/Excel.Sheet.12/shell/Open/ddeexec        &lt;br /&gt;&lt;/strong&gt;Right click it and select Rename.       &lt;br /&gt;Change the name to something else (it doesn’t matter what) &lt;/li&gt;    &lt;li&gt;Your screen should now look something like the following:      &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://lh5.ggpht.com/-wJT39G8EI3U/TrGu3YS-dlI/AAAAAAABLkY/XivOTdB77t4/s1600-h/image%25255B14%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/-G24OspUXTq0/TrGu40NoLYI/AAAAAAABLkg/5YXvs8CaC5U/image_thumb%25255B17%25255D.png?imgmax=800" width="967" height="367" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;You have now successfully made it so that when you open an existing Excel file (that has the extension .xlsx) it will open in a new window. This allows you to easily compare or view two Excel file at the same time. This is particular helpful if you have two monitors. You can also ways revert back if you decide you don’t like the change by undoing the changes made here, that is why we renamed instead of deleted the keys. &lt;/li&gt; &lt;/ol&gt;  &lt;h2&gt;.XLS&lt;/h2&gt;  &lt;p&gt;You can follow the same instructions for .XLS except you will want to amend the instruction so that where ever you see &lt;strong&gt;Excel.Sheet.12&lt;/strong&gt;, replace it with &lt;strong&gt;Excel.Sheet.8&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;BTW, I found this tip &lt;a href="http://answers.microsoft.com/en-us/office/forum/office_2010-excel/i-want-to-open-2-excel-files-in-separate-windows/f7588d9a-3c41-466f-8f01-3b6ab9661ae3" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-3761360061227579736?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/3761360061227579736/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=3761360061227579736' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/3761360061227579736'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/3761360061227579736'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/11/open-2-excel-files-in-separate-windows.html' title='Open 2 Excel Files in separate windows'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/-bxJzLJbycOE/TrGu2IOfHcI/AAAAAAABLkQ/gKmCy8CKp2Q/s72-c/image_thumb%25255B5%25255D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-3638045434799065412</id><published>2011-10-06T12:36:00.001-07:00</published><updated>2011-10-06T12:36:46.302-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><title type='text'>PNG Compression Tools</title><content type='html'>&lt;p&gt;PNG is a great format, but not all applications that save them create the same size files. There are at least four major tools out there that do nothing more than optimize the size using lossless techniques. Some of these tools even work on other formats also.&lt;/p&gt;  &lt;p&gt;I have not personally benchmarked them, but &lt;a href="http://www.gracepointafterfive.com/punypng-benchmarks" target="_blank"&gt;this person&lt;/a&gt; has. Below are some excerpts from their post.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.punypng.com" target="_blank"&gt;punypng&lt;/a&gt;: the new kid of the block. &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.smush.it" target="_blank"&gt;smush.it&lt;/a&gt;: Uses pngcrush as the main PNG optimizer.&amp;#160; Currently, available in Yahoo’s YSlow Firefox plug-in.&amp;#160; I believe it uses the -brute option for pngcrush. &lt;/li&gt;    &lt;li&gt;&lt;a href="http://optipng.sourceforge.net/" target="_blank"&gt;OptiPNG&lt;/a&gt;: A slighlty better algorithm, compared to pngcrush.&amp;#160; In case you’re wondering, Google’s &lt;a href="http://code.google.com/speed/page-speed/"&gt;PageSpeed&lt;/a&gt; plugin also uses OptiPNG for it’s compression library. &lt;/li&gt;    &lt;li&gt;&lt;a href="http://pornel.net/imageoptim/en" target="_blank"&gt;ImageOptim&lt;/a&gt;: The heavyweight contender.&amp;#160; Available for OS X, ImageOptim uses every major library out there: advdef, pngcrush, optipng, pngcrush, jpegoptim, jpegtran, and optionally pngout.&amp;#160; I ran this the benchmarks with pngout enabled. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-2MFdyinKADw/To4DSf9vcnI/AAAAAAABLUE/yNG7vCyRY9o/s1600-h/image%25255B4%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/-V-lX5z3IA_o/To4DTdUvFAI/AAAAAAABLUI/FJdhsdB6zCg/image_thumb%25255B2%25255D.png?imgmax=800" width="507" height="388" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If file size is critical I suggest trying all of them since it seems one does better than the other depending on the file.&lt;/p&gt;  &lt;p&gt;I use Paint.NET a lot and there is a &lt;a href="http://forums.getpaint.net/index.php?/topic/6305-optipng-file-type-plugin-november-30-2008/" target="_blank"&gt;plug-in&lt;/a&gt; for it if you use OptiPNG.&lt;/p&gt;  &lt;p&gt;If you want to use Visual Studio, there is a &lt;a href="http://visualstudiogallery.msdn.microsoft.com/a56eddd3-d79b-48ac-8c8f-2db06ade77c3" target="_blank"&gt;plug-in&lt;/a&gt; for it that uses punypng and smush.it. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-3638045434799065412?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/3638045434799065412/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=3638045434799065412' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/3638045434799065412'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/3638045434799065412'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/10/png-compression-tools.html' title='PNG Compression Tools'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/-V-lX5z3IA_o/To4DTdUvFAI/AAAAAAABLUI/FJdhsdB6zCg/s72-c/image_thumb%25255B2%25255D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-8086017672517668256</id><published>2011-09-23T17:06:00.001-07:00</published><updated>2011-09-23T17:07:31.103-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='AI'/><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><title type='text'>A look at the topic of Artificial Intelligence (AI)</title><content type='html'>&lt;h2&gt;General AI&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Artificial_intelligence" target="_blank"&gt;Artificial Intelligence Wiki&lt;/a&gt; – a good place to start to understand what AI encompasses and its different areas.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://jmlr.csail.mit.edu/" target="_blank"&gt;Journal of Machine Learning Research&lt;/a&gt; – Amazingly complex scientific papers of AI algorithms. Not for light reading.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://jmlr.csail.mit.edu/mloss/" target="_blank"&gt;Machine Learning Open Source Software&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;Areas of interest for me:&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Reinforcement_learning" target="_blank"&gt;Reinforcement Learning&lt;/a&gt; – concerned with how an agent ought to take actions in an environment so as to maximize some notion of cumulative &lt;em&gt;reward.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;  &lt;h3&gt;Data Mining&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Data_mining" target="_blank"&gt;Data Mining&lt;/a&gt; – good starting point for learning about data mining&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;  &lt;h3&gt;Text Mining&lt;/h3&gt;  &lt;p&gt;Basically Text Mining is data mining on unstructured data like documents, web pages, etc. instead of a database.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Natural_language_processing" target="_blank"&gt;Natural Language Processing&lt;/a&gt; – Imagine a machine being able to scour the internet and actually extract knowledge about what it read. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Text_mining" target="_blank"&gt;Text Mining&lt;/a&gt; – an area of Natural Language Processing, has many commercial uses even today. i.e. Bing&lt;/p&gt;  &lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Semantic_web"&gt;Semantic Web&lt;/a&gt; – a machine readable version of the web.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://wiki.dbpedia.org/" target="_blank"&gt;DBpedia&lt;/a&gt; – An effort to translate Wikipedia into machine understandable format to facilitate complex queries and meanings of words, not just matches. &lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.freebase.com/" href="http://www.freebase.com/"&gt;Freebase&lt;/a&gt; – Similar to DBpedia, but it is hand crafted. DBpedia has lots of links to it as well. A database of “bar codes” for all entities on the web. Aliasing… Also powers Bing&lt;/p&gt;  &lt;p&gt;&lt;a href="http://people.ischool.berkeley.edu/~hearst/text-mining.html"&gt;What is Text Mining&lt;/a&gt; – describes how text mining is more complex than data mining since it involves natural language processing.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Carrot2"&gt;Carrot2&lt;/a&gt; – text and search results clustering framework. Very cool way to browse search results and get to what you are looking for&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-8086017672517668256?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/8086017672517668256/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=8086017672517668256' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/8086017672517668256'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/8086017672517668256'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/09/look-at-topic-of-artificial.html' title='A look at the topic of Artificial Intelligence (AI)'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-6330929860801964222</id><published>2011-09-21T14:08:00.001-07:00</published><updated>2011-09-21T14:08:52.091-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MS Office'/><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Reading a MS Word 2007 Document in .docx format using C#</title><content type='html'>&lt;p&gt;If you want need to read (or write) from a MS Word 2007 Document that has been saved in the Open XML format (.docx) then you can use the &lt;a href="http://msdn.microsoft.com/en-us/library/bb448854.aspx" target="_blank"&gt;Open XML SDK 2.0 for Microsoft Office&lt;/a&gt; to do just. The first thing you will need to do is download and install the &lt;a href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;amp;id=5124" target="_blank"&gt;SDK&lt;/a&gt;. In particular, you must download and install the &lt;strong&gt;OpenXMLSDKv2.msi&lt;/strong&gt;. In addition, you can download the &lt;strong&gt;OpenXMLSDKTool.msi&lt;/strong&gt; if you want. It has some VERY nice features like generating code from an existing .docx file.&lt;/p&gt;  &lt;p&gt;Now that you have the files you need, open Visual Studio (2008 or 2010 works fine), open the project you want to use, and add a reference to the &lt;strong&gt;DocumentFormat.OpenXml&lt;/strong&gt; (I had to browse to it in the adding references windows by going to C:\Program Files (x86)\Open XML SDK\V2.0\lib) and &lt;strong&gt;WindowsBase&lt;/strong&gt; (mine was located in the list of .NET tab when adding references). Please note, this code does not require MS Word be installed and is safe to run on the server such as with ASP.NET.&lt;/p&gt;  &lt;p&gt;Now that you have the api, the rest is just working with the document. To get a better understand on how to work with the parts (&lt;a href="http://msdn.microsoft.com/en-us/library/gg278308.aspx" target="_blank"&gt;structure&lt;/a&gt;) of the Word Document, &lt;a href="http://msdn.microsoft.com/en-us/library/gg278327.aspx" target="_blank"&gt;click here&lt;/a&gt;.&amp;#160; For a list of “How do I…” code samples, &lt;a href="http://msdn.microsoft.com/en-us/library/cc850833.aspx" target="_blank"&gt;click here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Here is example code on how to get the body of the document.&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;using DocumentFormat.OpenXml.Packaging;     &lt;br /&gt;using DocumentFormat.OpenXml.Wordprocessing;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;…&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;using (WordprocessingDocument wordDocument = WordprocessingDocument.Open(Filename, false))     &lt;br /&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var body = wordDocument.MainDocumentPart.Document.Body;      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Here is an example of a more complex line of code that can be used to navigate the structure of the document using LINQ. In this case the document has a table in it and we are getting the first row and first cell of that row and the second element.&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;wordDocument.MainDocumentPart.Document.Body.ChildElements.First&amp;lt;Table&amp;gt;().ChildElements.First&amp;lt;TableRow&amp;gt;().ChildElements.First&amp;lt;TableCell&amp;gt;().ElementAt(2).InnerText&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;I hope this gives you an idea of how to get started. There are lots of good links, examples, etc &lt;a href="http://msdn.microsoft.com/en-us/library/bb448854.aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-6330929860801964222?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/6330929860801964222/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=6330929860801964222' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/6330929860801964222'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/6330929860801964222'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/09/reading-ms-word-2007-document-in-docx.html' title='Reading a MS Word 2007 Document in .docx format using C#'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-6475124819869739133</id><published>2011-09-20T18:03:00.001-07:00</published><updated>2011-09-20T18:03:39.570-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Convert a batch of .doc files to .docx using C# and Word 2007</title><content type='html'>&lt;p&gt;I recently inherited a bunch of Microsoft Word files that are in the .doc format. I want to convert them all to .docx so I can easily parse them later without needing MS Word installed (i.e. on a server). You can do the conversion with no code at all if you have the time. All you have to do is open the file up in MS Word 2007 and save the file as a .docx; Word will do the work for you. This is great, but I had hundred of files to convert, and I could not bear doing something that many times (I’m a programmer after all). Unbelievably there are products that cost $150 and more to do this. There are so trial editions that do 5 at a time, etc, and even some command line ones. Command line might work, but it still involves me figuring out where in a bunch of nested directories where the .doc files are and coming up with the command line arguments. That isn’t much better than opening Word, though I could script that solution at least. &lt;/p&gt;  &lt;p&gt;In the end, I decided it really wasn’t that difficult to just sit down and write the code to do this. The code is very simple. I have put it in one class so that you can easily include it in your own project. It could be a command line or WPF or WinForms. It doesn’t really matter. All the code does is &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Take the directory path that you pass it and recursively finds all the .doc files (even if they are in sub-directories of sub-directories) &lt;/li&gt;    &lt;li&gt;Open MS Word in the background (You can see winword.exe in your Processes under Task Manager). &lt;/li&gt;    &lt;li&gt;Loop through each file found &lt;/li&gt;    &lt;li&gt;Open the current file &lt;/li&gt;    &lt;li&gt;Tell MS Word 2007 to save the file as .docx &lt;/li&gt;    &lt;li&gt;Close the File &lt;/li&gt;    &lt;li&gt;Close MS Word when all files have been processed. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;You will find all the new files right next to the .doc files. You can then search in Windows for .doc and delete them quickly once you have comfortable everything went smoothly.&lt;/p&gt;  &lt;p&gt;Things you will need to use the class below. &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Visual Studio &lt;/li&gt;    &lt;li&gt;MS Word installed on the same machine as you run your program you create &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;When you create your project you will need to add a reference to your project for Microsoft.Office.Interop.Word. Besure you choose the version 12 and not version 11 like I did initially. If you do you will get a compiler error.&lt;/p&gt;  &lt;p&gt;Below is the actual code you need.&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;using System;      &lt;br /&gt;using System.Collections.Generic;       &lt;br /&gt;using System.Linq;       &lt;br /&gt;using System.Text;       &lt;br /&gt;using System.IO;       &lt;br /&gt;using Microsoft.Office.Interop.Word;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;namespace ConvertDocToDocx      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class DocToDocxConverter       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; List&amp;lt;string&amp;gt; AllWordFiles { get; set; }      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DirectoryInfo StartingDir { get; set; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public DocToDocxConverter(DirectoryInfo startingDir)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; StartingDir = startingDir;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void ConvertAll()      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; AllWordFiles = new List&amp;lt;string&amp;gt;();       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // NOTE: Since .xls is a also in .xlsx this search will find .xls and .xlsx files       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // If the extension is different then this can be called again to include them.       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; FindWordFilesRecursively(StartingDir.FullName, &amp;quot;*.doc&amp;quot;);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // only open and close Word once to maximize performance      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Application word = new Application();&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; try      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; foreach (string filename in AllWordFiles)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // exclude the .docx (only include .doc) files as we don't need to convert them. :)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (filename.ToLower().EndsWith(&amp;quot;.doc&amp;quot;))       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; try       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var srcFile = new FileInfo(filename);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // convert the source file      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var doc = word.Documents.Open(srcFile.FullName);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string newFilename = srcFile.FullName.Replace(&amp;quot;.doc&amp;quot;, &amp;quot;.docx&amp;quot;);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Be sure to include the correct reference to Microsoft.Office.Interop.Word      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // in the project refences. In this case we need version 12 of Office to get the new formats.       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; doc.SaveAs(FileName: newFilename, FileFormat: WdSaveFormat.wdFormatXMLDocument);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; finally       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // we want to make sure the document is always closed       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; word.ActiveDocument.Close();       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; finally       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; word.Quit();       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; void FindWordFilesRecursively(string sDir, string filter)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; foreach (string d in Directory.GetDirectories(sDir))      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; foreach (string f in Directory.GetFiles(d, filter))       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; AllWordFiles.Add(f);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; FindWordFilesRecursively(d, filter);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;}       &lt;br /&gt;&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-6475124819869739133?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/6475124819869739133/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=6475124819869739133' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/6475124819869739133'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/6475124819869739133'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/09/convert-batch-of-doc-files-to-docx.html' title='Convert a batch of .doc files to .docx using C# and Word 2007'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-6346884334565167655</id><published>2011-09-14T16:01:00.001-07:00</published><updated>2011-09-14T16:01:09.194-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='System Admin'/><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><title type='text'>Email Aliases in Gmail</title><content type='html'>&lt;p&gt;Gmail doesn't offer traditional aliases, but you can receive messages sent to your.username+any.alias@gmail.com. For example, messages sent to jane.doe+notes@gmail.com are delivered to jane.doe@gmail.com. &lt;/p&gt;  &lt;p&gt;You can set up filters to automatically direct these messages to Trash, apply a label or star, skip the inbox, or forward to another email account. &lt;/p&gt;  &lt;p&gt;This is great for testing user registration in your app. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-6346884334565167655?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/6346884334565167655/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=6346884334565167655' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/6346884334565167655'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/6346884334565167655'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/09/email-aliases-in-gmail.html' title='Email Aliases in Gmail'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-5105816832097903220</id><published>2011-08-25T11:55:00.001-07:00</published><updated>2012-01-25T17:25:31.979-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Free Options for reading and writing Excel Files</title><content type='html'>&lt;p&gt;In general there are three main categories of tools that allow you to interact with Excel files. &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;MS Excel Primary Interop Assembly (PIA) Based: These require MS Excel be installed and licensed. Not a good option of server environment since it basically spins up Excel. &lt;/li&gt;    &lt;li&gt;OleDB Based: These are very fast a light weight solutions generally that are server friendly. No license or installation of Excel required. I highly recommend the ACE driver instead of JET driver. You can do read, write, update with this option. See OLE DB Article section below for details. &lt;/li&gt;    &lt;li&gt;Other: This means they have coded their own solution typically using some kind of XML format, but sometimes using binary format. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I have not tested many of these solutions other than using PIA or OLE DB. The exception to that is CarlosAg Excel Xml Writer Library which I do like, but it is only for Writing Excel files, not reading them. It has good performance and works well for tabular and non-tabular spreadsheets.&lt;/p&gt;  &lt;p&gt;I would love to add other solutions to the list so please let me know your favorite solutions.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;table border="1" cellspacing="0" cellpadding="2" width="581"&gt;&lt;tbody&gt;     &lt;tr bgcolor="#c0c0c0"&gt;       &lt;td valign="top" width="117"&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="62"&gt;&lt;strong&gt;Requires Excel / Uses PIA&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="46"&gt;&lt;strong&gt;Uses OleDB&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="36"&gt;&lt;strong&gt;Uses XML&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="58"&gt;&lt;strong&gt;Server Friendly&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="62"&gt;&lt;strong&gt;Supports Read&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="62"&gt;&lt;strong&gt;Supports Write&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="62"&gt;&lt;strong&gt;Supports            &lt;br /&gt;.XLS&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="74"&gt;&lt;strong&gt;Supports            &lt;br /&gt;.XLSX&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="117"&gt;MS Excel Interop (PIA)&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="46"&gt;No&lt;/td&gt;        &lt;td valign="top" width="36"&gt;No&lt;/td&gt;        &lt;td valign="top" width="58"&gt;&amp;nbsp;&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="74"&gt;Yes&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="117"&gt;.NET Framework Data Provider for OLE DB (using ACE OLEDB 12.0)&lt;/td&gt;        &lt;td valign="top" width="62"&gt;No&lt;/td&gt;        &lt;td valign="top" width="46"&gt;ACE or JET&lt;/td&gt;        &lt;td valign="top" width="36"&gt;No&lt;/td&gt;        &lt;td valign="top" width="58"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;&amp;nbsp;&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="74"&gt;Yes&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="117"&gt;&lt;a href="http://www.microsoft.com/download/en/details.aspx?id=5124" target="_blank"&gt;Open XML SDK 2.0 for MS Office&lt;/a&gt;&lt;/td&gt;        &lt;td valign="top" width="62"&gt;No&lt;/td&gt;        &lt;td valign="top" width="46"&gt;No&lt;/td&gt;        &lt;td valign="top" width="36"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="58"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;No&lt;/td&gt;        &lt;td valign="top" width="74"&gt;Yes&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="117"&gt;&lt;a href="http://exceldatareader.codeplex.com/" target="_blank"&gt;Excel Data Reader&lt;/a&gt;&lt;/td&gt;        &lt;td valign="top" width="62"&gt;No&lt;/td&gt;        &lt;td valign="top" width="46"&gt;No&lt;/td&gt;        &lt;td valign="top" width="36"&gt;No&lt;/td&gt;        &lt;td valign="top" width="58"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;No&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="74"&gt;Yes&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="117"&gt;&lt;a href="https://github.com/mvba/ExcelMapper" target="_blank"&gt;ExcelMapper&lt;/a&gt;           &lt;br /&gt;for tabular data&lt;/td&gt;        &lt;td valign="top" width="62"&gt;No&lt;/td&gt;        &lt;td valign="top" width="46"&gt;ACE &amp;amp; JET&lt;/td&gt;        &lt;td valign="top" width="36"&gt;No&lt;/td&gt;        &lt;td valign="top" width="58"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="74"&gt;Yes&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="117"&gt;&lt;a href="http://www.carlosag.net/Tools/ExcelXmlWriter/" target="_blank"&gt;CarlosAg Excel Xml Writer Library&lt;/a&gt; – uses old xml spreadsheet format&lt;/td&gt;        &lt;td valign="top" width="62"&gt;No&lt;/td&gt;        &lt;td valign="top" width="46"&gt;No&lt;/td&gt;        &lt;td valign="top" width="36"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="58"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;No&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;No&lt;/td&gt;        &lt;td valign="top" width="74"&gt;No (only .xml)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="117"&gt;&lt;a href="http://www.gemboxsoftware.com/spreadsheet/free-version" target="_blank"&gt;GemBox (for small files it is free)&lt;/a&gt;&lt;/td&gt;        &lt;td valign="top" width="62"&gt;No&lt;/td&gt;        &lt;td valign="top" width="46"&gt;No?&lt;/td&gt;        &lt;td valign="top" width="36"&gt;No?&lt;/td&gt;        &lt;td valign="top" width="58"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="74"&gt;Yes&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="117"&gt;&lt;a href="http://sourceforge.net/projects/koogra/" target="_blank"&gt;Koogra&lt;/a&gt;&lt;/td&gt;        &lt;td valign="top" width="62"&gt;No&lt;/td&gt;        &lt;td valign="top" width="46"&gt;No&lt;/td&gt;        &lt;td valign="top" width="36"&gt;No&lt;/td&gt;        &lt;td valign="top" width="58"&gt;Yes?&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;No?&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes?&lt;/td&gt;        &lt;td valign="top" width="74"&gt;Yes&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="117"&gt;&lt;a href="http://sourceforge.net/projects/myxls/" target="_blank"&gt;MyXLS&lt;/a&gt;&lt;/td&gt;        &lt;td valign="top" width="62"&gt;No&lt;/td&gt;        &lt;td valign="top" width="46"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="36"&gt;No&lt;/td&gt;        &lt;td valign="top" width="58"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="74"&gt;No&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="117"&gt;&lt;a href="http://extrememl.codeplex.com/" target="_blank"&gt;ExtremeML&lt;/a&gt;&lt;/td&gt;        &lt;td valign="top" width="62"&gt;No&lt;/td&gt;        &lt;td valign="top" width="46"&gt;No&lt;/td&gt;        &lt;td valign="top" width="36"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="58"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;No?&lt;/td&gt;        &lt;td valign="top" width="74"&gt;Yes&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="117"&gt;&lt;a href="http://closedxml.codeplex.com/" target="_blank"&gt;ClosedXML&lt;/a&gt;&lt;/td&gt;        &lt;td valign="top" width="62"&gt;No&lt;/td&gt;        &lt;td valign="top" width="46"&gt;No&lt;/td&gt;        &lt;td valign="top" width="36"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="58"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;Yes&lt;/td&gt;        &lt;td valign="top" width="62"&gt;No&lt;/td&gt;        &lt;td valign="top" width="74"&gt;Yes&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Using Excel PIA Articles:&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://www.codeproject.com/KB/cs/Excel_Application_in_C_.aspx" target="_blank"&gt;Loading and reading the Microsoft Excel file content using C#&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://csharp.net-informations.com/excel/csharp-excel-export.htm" href="http://csharp.net-informations.com/excel/csharp-excel-export.htm" target="_blank"&gt;How to export database to Excel file&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://csharp.net-informations.com/excel/csharp-excel-tutorial.htm" href="http://csharp.net-informations.com/excel/csharp-excel-tutorial.htm"&gt;C# Excel Tutorial&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;OLE DB Articles&lt;/h3&gt;  &lt;p&gt;OLE DB can use either JET or ACE. ACE is MUCH better than JET because it doesn’t have the same pitfalls with guessing data that JET does, etc. So when using OLE DB change the connection string to use ACE instead of JET driver for OleDB. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.connectionstrings.com/excel-2007#p20" target="_blank"&gt;Connection strings for Excel 2007&lt;/a&gt; - Connection Strings for Excel / ACE OLE DB 12.0&lt;/p&gt;  &lt;p&gt;&lt;a title="http://csharp.net-informations.com/excel/csharp-excel-oledb.htm" href="http://csharp.net-informations.com/excel/csharp-excel-oledb.htm"&gt;How to read from an Excel file using OLEDB&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://csharp.net-informations.com/excel/csharp-excel-oledb-insert.htm" href="http://csharp.net-informations.com/excel/csharp-excel-oledb-insert.htm"&gt;How to insert data to Excel file using OLEDB&lt;/a&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a title="http://csharp.net-informations.com/excel/csharp-excel-oledb-update.htm" href="http://csharp.net-informations.com/excel/csharp-excel-oledb-update.htm"&gt;How to update data in Excel file using OLEDB&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;font size="4"&gt;My favorite Option is to use the Open XML format&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/b/brian_jones/archive/2010/06/22/writing-large-excel-files-with-the-open-xml-sdk.aspx" target="_blank"&gt;Writing Large Excel File with the Open XML SDK&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://polymathprogrammer.com/2009/11/09/how-to-create-stylesheet-in-excel-open-xml/" target="_blank"&gt;How to create a stylesheet in Excel Open XML&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="4"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Other Useful Links&lt;/h3&gt;  &lt;p&gt;&lt;a title="http://www.filehelpers.com/" href="http://www.filehelpers.com/"&gt;FileHelpers&lt;/a&gt; – import/export data from fixed length or delimited records using strongly type values&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sourceforge.net/projects/gelsheet/" target="_blank"&gt;Web Spreadsheet&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2009/06/02/4730.aspx" target="_blank"&gt;OpenXMLDeveloper.org&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://polymathprogrammer.com/store/spreadsheetlight/" href="http://polymathprogrammer.com/store/spreadsheetlight/" target="_blank"&gt;SpreadsheetLight&lt;/a&gt; – Not free, but no hassle license and it a reasonable price and looks very simple to use.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-5105816832097903220?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/5105816832097903220/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=5105816832097903220' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/5105816832097903220'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/5105816832097903220'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/08/free-options-for-reading-and-writing.html' title='Free Options for reading and writing Excel Files'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-2448662903019233371</id><published>2011-08-23T14:32:00.001-07:00</published><updated>2011-08-25T16:30:00.982-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><title type='text'>Configuring Subversion for MS Office files</title><content type='html'>&lt;p&gt;Subversion works well, and does a fair job of handling MS Office documents (or any other unmergeable file) out of the box, but it is not what I would call obvious. There are some tweaks I would recommend in order to make it work much better.&lt;/p&gt;  &lt;p&gt;To accomplish this we need to do a few things. I am assuming you are using &lt;a href="http://tortoisesvn.net/downloads.html" target="_blank"&gt;TortoiseSVN&lt;/a&gt;, but most subversion clients should have similar features if they implement the full set of subversion features.&lt;/p&gt;  &lt;p&gt;I have three goals. I have listed them below and explained what is needed to achieve each of the goals.&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Goal 1: Make subversion not automatically merge MS Office files&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;I think is met by default, but if nothing else will be handled by the time we are done.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Goal 2: Lock the file so others cannot make changes and commit them.&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;This is actually built into subversion. Before you edit a file you should always get an update (Right-click file | &lt;strong&gt;SVN Update&lt;/strong&gt;) to it to make sure you have the most recent copy of it. You should make sure no one else has a lock on the file by right-clicking the file | &lt;strong&gt;TortoiseSVN | Check for Modification&lt;/strong&gt;. Assuming the file is not locked by someone else, we need to lock the file (Right-click file | &lt;strong&gt;TortoiseSVN | Get Lock…&lt;/strong&gt; OR Right-click file | &lt;strong&gt;SVN Get Lock…&lt;/strong&gt;).&amp;#160; We have now prevented people from ACCIDENTALLY overwriting our un-committed changes by committing first. I say accidentally because they can still break locks if they really feel they are more important. The problem is that unless they use the &lt;strong&gt;Check for Modifications…&lt;/strong&gt; like we did, they won’t know the file is locked until they try to commit the file since the lock prevents commits, not editing. Which leads us to our next goal.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Goal 3: Automatically communicate to other users that the file is locked.&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;This is not the same thing as actually locking the file, but really is more of a communication tool to let the other users know that someone else is editing it. We want to be more proactive really so that we or someone else never starts editing a file that is already locked. Up to this point, everything has been under your control, but to meet this goal, it is client configuration, not a server configuration. This means that you can recommend this to your team members to add to their subversion configuration file, but you can’t force them. Luckily it is more about convenience that enforcement on this requirement.&lt;/p&gt;  &lt;p&gt;To meet this goal, we need to open out config file and add the &lt;font color="#008000"&gt;&lt;strong&gt;svn:needs-lock&lt;/strong&gt;&lt;/font&gt; property to any MS Office file extension. You will need to add them if they are not already there (they probably aren’t unless you have a customized file already). You will also need to uncomment the line with &lt;font color="#ff0000"&gt;enable-auto-props = yes&lt;font color="#000000"&gt;. Also, be sure the [auto-props] line is uncommented. See the example config file below for examples. Once you do that once you get an update (Right-click file | &lt;strong&gt;SVN Update&lt;/strong&gt;) from subversion the file will now be read-only if you don’t have a lock on it and it will also have a new icon (&lt;a href="http://lh4.ggpht.com/-8qTkCuKap-0/TlQcWpax97I/AAAAAAABIik/xtH3Bci1utM/s1600-h/image%25255B11%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-R7EcpSAPtU0/TlQcY6mgkPI/AAAAAAABIio/zQutrwMR5Yw/image_thumb%25255B12%25255D.png?imgmax=800" width="21" height="16" /&gt;&lt;/a&gt;). &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;font color="#333333"&gt;&lt;font color="#ff0000" size="4"&gt;&lt;strong&gt;WARNING&lt;/strong&gt;&lt;/font&gt;: The automatic properties are NOT applied except on &lt;strong&gt;Add&lt;/strong&gt; or &lt;strong&gt;Import &lt;/strong&gt;into subversion. This means that any if you are trying implement this on an existing repository that already has Office files in it that you need to manually add the &lt;font color="#008000"&gt;svn:needs-lock&lt;/font&gt; property to the properties. &lt;/font&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;font color="#333333"&gt;You can do that in TortoiseSVN and getting a lock for the file(s) then &lt;strong&gt;Right-Clicking the file | TortoiseSVN | Properties | New… button&lt;/strong&gt; and then choose &lt;strong&gt;&lt;font color="#008000"&gt;svn:needs-lock&lt;/font&gt;&lt;/strong&gt; for the &lt;strong&gt;Property Name&lt;/strong&gt; field and * for the &lt;strong&gt;Property value&lt;/strong&gt; field. &lt;/font&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;font color="#333333"&gt;You can also do the same thing at the directory level or for multiple files and even recursively by selecting a directory or multiple files then TortoiseSVN by &lt;strong&gt;Right-Clicking the file | TortoiseSVN | Properties | New… button&lt;/strong&gt; and then choose &lt;strong&gt;&lt;font color="#008000"&gt;svn:needs-lock&lt;/font&gt;&lt;/strong&gt; for the &lt;strong&gt;Property Name&lt;/strong&gt; field and * for the &lt;strong&gt;Property value&lt;/strong&gt; field and then click &lt;strong&gt;Apply property recursively&lt;/strong&gt; checkbox if applicable. Keep in mind this will apply the property to ALL files you select and those files may not be Office docs, so be aware of what you are selecting.&amp;#160; If you have a lot of file mixed in with mergeable file to do this to you may want to automate the task. &lt;/font&gt;&lt;/em&gt;&lt;a title="http://www.orcaware.com/svn/wiki/Automatic_lock-modify-unlock" href="http://www.orcaware.com/svn/wiki/Automatic_lock-modify-unlock" target="_blank"&gt;&lt;em&gt;&lt;font color="#333333"&gt;Here&lt;/font&gt;&lt;/em&gt;&lt;/a&gt;&lt;em&gt;&lt;font color="#333333"&gt; is a good explanation of how this can be done. After you set the property, you will need to &lt;strong&gt;Commit&lt;/strong&gt; the change like you would any other changes. &lt;/font&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;font color="#333333"&gt;In all cases, after you are done making you changes and have commited them, be sure to release the lock on the file(s).&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;&lt;font color="#000000"&gt;Now when you get a lock (Right-click file | &lt;strong&gt;TortoiseSVN | Get Lock…&lt;/strong&gt; OR Right-click file | &lt;strong&gt;SVN Get Lock…&lt;/strong&gt;) on the file the icon changes to a yellow lock and the file is no longer read-only. You are now safe to make your changes. &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;font style="font-weight: bold"&gt;Unlocking&lt;/font&gt;&lt;/h3&gt;  &lt;p&gt;There are two ways to unlock a file. The first is simply to commit your changes (assuming you made some). NOTE: The &lt;a href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-locking.html" target="_blank"&gt;Tortoisesvn docs&lt;/a&gt; seem to indicate the lock is released even if you don’t make a change, but that isn’t how it seems to work on my version. The lock is only released when I make a change before committing. It definitely should release the lock if you make a change first though. So, I guess your mileage may vary. The other option is to manually release it by Right-clicking file | &lt;strong&gt;TortoiseSVN | Release Lock&lt;/strong&gt;. Once the lock is removed other people can get a lock on the file.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;font style="font-weight: bold"&gt;Additional Resources&lt;/font&gt;&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://tortoisesvn.net/downloads.html" target="_blank"&gt;Download&lt;/a&gt; TortoiseSVN&lt;/p&gt;  &lt;p&gt;To read up more on how to use locking in TortoiseSVN &lt;a href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-locking.html" target="_blank"&gt;click here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://svnbook.red-bean.com/" target="_blank"&gt;&lt;strong&gt;Here&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; is a seemingly good online book on subversion – FREE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.orcaware.com/svn/wiki/Automatic_lock-modify-unlock" href="http://www.orcaware.com/svn/wiki/Automatic_lock-modify-unlock" target="_blank"&gt;Automatic Lock - Modify – Unlock&lt;/a&gt; – scripts to help do this for existing files in subversion&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;h3&gt;&lt;font style="font-weight: bold"&gt;Example Configuration File&lt;/font&gt;&lt;/h3&gt;  &lt;p&gt;The configuration file is located at (in Windows): &lt;/p&gt;  &lt;p&gt;C:\Users\yourUserNameHere\AppData\Roaming\Subversion or maybe C:\Users\yourUserNameHere\AppData\Subversion (not sure for non-roaming profiles).&lt;/p&gt;  &lt;p&gt;If you are using &lt;a href="http://tortoisesvn.net/downloads.html" target="_blank"&gt;TortoiseSVN&lt;/a&gt; you can edit the config file by going to Settings | General tab | Edit button. &lt;/p&gt;  &lt;p&gt;### This file configures various client-side behaviors.    &lt;br /&gt;###     &lt;br /&gt;### The commented-out examples below are intended to demonstrate     &lt;br /&gt;### how to use this file.&lt;/p&gt;  &lt;p&gt;### Section for authentication and authorization customizations.    &lt;br /&gt;[auth]     &lt;br /&gt;### Set password stores used by Subversion. They should be     &lt;br /&gt;### delimited by spaces or commas. The order of values determines     &lt;br /&gt;### the order in which password stores are used.     &lt;br /&gt;### Valid password stores:     &lt;br /&gt;###&amp;#160;&amp;#160; gnome-keyring&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; (Unix-like systems)     &lt;br /&gt;###&amp;#160;&amp;#160; kwallet&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; (Unix-like systems)     &lt;br /&gt;###&amp;#160;&amp;#160; keychain&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; (Mac OS X)     &lt;br /&gt;###&amp;#160;&amp;#160; windows-cryptoapi&amp;#160;&amp;#160;&amp;#160; (Windows)     &lt;br /&gt;#password-stores = windows-cryptoapi     &lt;br /&gt;###     &lt;br /&gt;### The rest of this section in this file has been deprecated.     &lt;br /&gt;### Both 'store-passwords' and 'store-auth-creds' can now be     &lt;br /&gt;### specified in the 'servers' file in your config directory.     &lt;br /&gt;### Anything specified in this section is overridden by settings     &lt;br /&gt;### specified in the 'servers' file.     &lt;br /&gt;###     &lt;br /&gt;### Set store-passwords to 'no' to avoid storing passwords in the     &lt;br /&gt;### auth/ area of your config directory.&amp;#160; It defaults to 'yes',     &lt;br /&gt;### but Subversion will never save your password to disk in     &lt;br /&gt;### plaintext unless you tell it to (see the 'servers' file).     &lt;br /&gt;### Note that this option only prevents saving of *new* passwords;     &lt;br /&gt;### it doesn't invalidate existing passwords.&amp;#160; (To do that, remove     &lt;br /&gt;### the cache files by hand as described in the Subversion book.)     &lt;br /&gt;# store-passwords = no     &lt;br /&gt;### Set store-auth-creds to 'no' to avoid storing any subversion     &lt;br /&gt;### credentials in the auth/ area of your config directory.     &lt;br /&gt;### It defaults to 'yes'.&amp;#160; Note that this option only prevents     &lt;br /&gt;### saving of *new* credentials;&amp;#160; it doesn't invalidate existing     &lt;br /&gt;### caches.&amp;#160; (To do that, remove the cache files by hand.)     &lt;br /&gt;# store-auth-creds = no&lt;/p&gt;  &lt;p&gt;### Section for configuring external helper applications.    &lt;br /&gt;[helpers]     &lt;br /&gt;### Set editor-cmd to the command used to invoke your text editor.     &lt;br /&gt;###&amp;#160;&amp;#160; This will override the environment variables that Subversion     &lt;br /&gt;###&amp;#160;&amp;#160; examines by default to find this information ($EDITOR,     &lt;br /&gt;###&amp;#160;&amp;#160; et al).     &lt;br /&gt;# editor-cmd = editor (vi, emacs, notepad, etc.)     &lt;br /&gt;### Set diff-cmd to the absolute path of your 'diff' program.     &lt;br /&gt;###&amp;#160;&amp;#160; This will override the compile-time default, which is to use     &lt;br /&gt;###&amp;#160;&amp;#160; Subversion's internal diff implementation.     &lt;br /&gt;# diff-cmd = diff_program (diff, gdiff, etc.)     &lt;br /&gt;### Set diff3-cmd to the absolute path of your 'diff3' program.     &lt;br /&gt;###&amp;#160;&amp;#160; This will override the compile-time default, which is to use     &lt;br /&gt;###&amp;#160;&amp;#160; Subversion's internal diff3 implementation.     &lt;br /&gt;# diff3-cmd = diff3_program (diff3, gdiff3, etc.)     &lt;br /&gt;### Set diff3-has-program-arg to 'yes' if your 'diff3' program     &lt;br /&gt;###&amp;#160;&amp;#160; accepts the '--diff-program' option.     &lt;br /&gt;# diff3-has-program-arg = [yes | no]     &lt;br /&gt;### Set merge-tool-cmd to the command used to invoke your external     &lt;br /&gt;### merging tool of choice. Subversion will pass 4 arguments to     &lt;br /&gt;### the specified command: base theirs mine merged     &lt;br /&gt;# merge-tool-cmd = merge_command&lt;/p&gt;  &lt;p&gt;### Section for configuring tunnel agents.    &lt;br /&gt;[tunnels]     &lt;br /&gt;### Configure svn protocol tunnel schemes here.&amp;#160; By default, only     &lt;br /&gt;### the 'ssh' scheme is defined.&amp;#160; You can define other schemes to     &lt;br /&gt;### be used with 'svn+scheme://hostname/path' URLs.&amp;#160; A scheme     &lt;br /&gt;### definition is simply a command, optionally prefixed by an     &lt;br /&gt;### environment variable name which can override the command if it     &lt;br /&gt;### is defined.&amp;#160; The command (or environment variable) may contain     &lt;br /&gt;### arguments, using standard shell quoting for arguments with     &lt;br /&gt;### spaces.&amp;#160; The command will be invoked as:     &lt;br /&gt;###&amp;#160;&amp;#160; &amp;lt;command&amp;gt; &amp;lt;hostname&amp;gt; svnserve -t     &lt;br /&gt;### (If the URL includes a username, then the hostname will be     &lt;br /&gt;### passed to the tunnel agent as &amp;lt;user&amp;gt;@&amp;lt;hostname&amp;gt;.)&amp;#160; If the     &lt;br /&gt;### built-in ssh scheme were not predefined, it could be defined     &lt;br /&gt;### as:     &lt;br /&gt;# ssh = $SVN_SSH ssh -q     &lt;br /&gt;### If you wanted to define a new 'rsh' scheme, to be used with     &lt;br /&gt;### 'svn+rsh:' URLs, you could do so as follows:     &lt;br /&gt;# rsh = rsh     &lt;br /&gt;### Or, if you wanted to specify a full path and arguments:     &lt;br /&gt;# rsh = /path/to/rsh -l myusername     &lt;br /&gt;### On Windows, if you are specifying a full path to a command,     &lt;br /&gt;### use a forward slash (/) or a paired backslash (\\) as the     &lt;br /&gt;### path separator.&amp;#160; A single backslash will be treated as an     &lt;br /&gt;### escape for the following character.&lt;/p&gt;  &lt;p&gt;### Section for configuring miscelleneous Subversion options.    &lt;br /&gt;[miscellany]     &lt;br /&gt;### Set global-ignores to a set of whitespace-delimited globs     &lt;br /&gt;### which Subversion will ignore in its 'status' output, and     &lt;br /&gt;### while importing or adding files and directories.     &lt;br /&gt;### '*' matches leading dots, e.g. '*.rej' matches '.foo.rej'.     &lt;br /&gt;# global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo     &lt;br /&gt;#&amp;#160;&amp;#160; *.rej *~ #*# .#* .*.swp .DS_Store&lt;/p&gt;  &lt;p&gt;global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo ~* *~&lt;/p&gt;  &lt;p&gt;### Set log-encoding to the default encoding for log messages    &lt;br /&gt;# log-encoding = latin1     &lt;br /&gt;### Set use-commit-times to make checkout/update/switch/revert     &lt;br /&gt;### put last-committed timestamps on every file touched.     &lt;br /&gt;# use-commit-times = yes     &lt;br /&gt;### Set no-unlock to prevent 'svn commit' from automatically     &lt;br /&gt;### releasing locks on files.     &lt;br /&gt;# no-unlock = yes     &lt;br /&gt;### Set mime-types-file to a MIME type registry file, used to     &lt;br /&gt;### provide hints to Subversion's MIME type auto-detection     &lt;br /&gt;### algorithm.     &lt;br /&gt;# mime-types-file = /path/to/mime.types     &lt;br /&gt;### Set preserved-conflict-file-exts to a whitespace-delimited     &lt;br /&gt;### list of patterns matching file extensions which should be     &lt;br /&gt;### preserved in generated conflict file names.&amp;#160; By default,     &lt;br /&gt;### conflict files use custom extensions.     &lt;br /&gt;# preserved-conflict-file-exts = doc ppt xls od?     &lt;br /&gt;### Set enable-auto-props to 'yes' to enable automatic properties     &lt;br /&gt;### for 'svn add' and 'svn import', it defaults to 'no'.     &lt;br /&gt;### Automatic properties are defined in the section 'auto-props'.     &lt;br /&gt;&lt;font color="#ff0000"&gt;enable-auto-props = yes      &lt;br /&gt;&lt;/font&gt;### Set interactive-conflicts to 'no' to disable interactive     &lt;br /&gt;### conflict resolution prompting.&amp;#160; It defaults to 'yes'.     &lt;br /&gt;# interactive-conflicts = no     &lt;br /&gt;### Section for configuring automatic properties.     &lt;br /&gt;[auto-props]     &lt;br /&gt;### The format of the entries is:     &lt;br /&gt;###&amp;#160;&amp;#160; file-name-pattern = propname[=value][;propname[=value]...]     &lt;br /&gt;### The file-name-pattern can contain wildcards (such as '*' and     &lt;br /&gt;### '?').&amp;#160; All entries which match (case-insensitively) will be     &lt;br /&gt;### applied to the file.&amp;#160; Note that auto-props functionality     &lt;br /&gt;### must be enabled, which is typically done by setting the     &lt;br /&gt;### 'enable-auto-props' option.     &lt;br /&gt;*.awk&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.bat&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native;svn:executable     &lt;br /&gt;*.c&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.ccf&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.cd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.cdl&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.cpp&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.cs&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.csv&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.ddl&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;&lt;font color="#ff0000"&gt;*.doc&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:needs-lock      &lt;br /&gt;*.docm&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:needs-lock       &lt;br /&gt;*.docx&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:needs-lock       &lt;br /&gt;&lt;/font&gt;*.dot&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:needs-lock     &lt;br /&gt;*.dotm&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:needs-lock     &lt;br /&gt;*.dotx&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:needs-lock     &lt;br /&gt;*.dsp&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=CRLF     &lt;br /&gt;*.dsw&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=CRLF     &lt;br /&gt;*.g&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.gif&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:mime-type=image/gif     &lt;br /&gt;*.h&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.hd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.hpp&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.htm&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native;svn:mime-type=text/html     &lt;br /&gt;*.html&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native;svn:mime-type=text/html     &lt;br /&gt;*.ico&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:mime-type=image/ico     &lt;br /&gt;*.id&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.idl&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.include&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.inf&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native;svn:executable     &lt;br /&gt;*.ini&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.java&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.jpe?g&amp;#160;&amp;#160;&amp;#160; = svn:mime-type=image/jpeg     &lt;br /&gt;*.jpg&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:mime-type=image/jpeg     &lt;br /&gt;*.ld&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.lk&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.m3u&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:mime-type=audio/x-mpegurl     &lt;br /&gt;*.mdb&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:needs-lock     &lt;br /&gt;*.mk&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.mmf&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.pdf&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:needs-lock     &lt;br /&gt;*.pl&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.pm&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.png&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:mime-type=image/png     &lt;br /&gt;&lt;font color="#ff0000"&gt;*.ppt*&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:needs-lock      &lt;br /&gt;&lt;/font&gt;*.py&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.pyw&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.qconf&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.rgd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.rtf&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:needs-lock     &lt;br /&gt;*.s&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.sh&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native;svn:executable     &lt;br /&gt;*.sldm&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:needs-lock     &lt;br /&gt;*.sldx&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:needs-lock     &lt;br /&gt;*.tex&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;*.thmx&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:needs-lock     &lt;br /&gt;*.txt&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;&lt;font color="#ff0000"&gt;*.xlam&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:needs-lock      &lt;br /&gt;*.xls&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:needs-lock       &lt;br /&gt;*.xlsb&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:needs-lock       &lt;br /&gt;*.xlsm&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:needs-lock       &lt;br /&gt;*.xlsx&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:needs-lock       &lt;br /&gt;*.xltm&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:needs-lock       &lt;br /&gt;*.xltx&amp;#160;&amp;#160;&amp;#160;&amp;#160; = svn:needs-lock       &lt;br /&gt;&lt;/font&gt;Makefile&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;makefile&amp;#160;&amp;#160; = svn:eol-style=native     &lt;br /&gt;SConscript = svn:eol-style=native     &lt;br /&gt;SConstruct = svn:eol-style=native&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-2448662903019233371?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/2448662903019233371/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=2448662903019233371' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/2448662903019233371'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/2448662903019233371'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/08/configuring-subversion-for-ms-office.html' title='Configuring Subversion for MS Office files'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/-R7EcpSAPtU0/TlQcY6mgkPI/AAAAAAABIio/zQutrwMR5Yw/s72-c/image_thumb%25255B12%25255D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-7850817714745196519</id><published>2011-08-18T12:18:00.001-07:00</published><updated>2011-08-18T12:18:41.157-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><title type='text'>Change Default Paste to Unformatted Text in MS Word 2007</title><content type='html'>&lt;p&gt;Are you tired of MS Word 2007 and higher pasting formatted text your document when all you really want is unformatted text to be pasted? The temporary solution is to go to the Home ribbon | Paste (down arrow) | Paste Special… | Select Unformatted Text | OK. That is a lot of clicking for just a simple paste that I think should be the default.&lt;/p&gt;  &lt;p&gt;Finally in MS Word 2007 they added some nice features to address this very issue. Go to the Word menu &lt;a href="http://lh6.ggpht.com/-izy36gCcyaM/Tk1lcrYS9YI/AAAAAAABIYw/ct9fiQRQ4gA/s1600-h/image%25255B2%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/-tf9BcVGsfxE/Tk1le9aszGI/AAAAAAABIY0/yr4JOuZySes/image_thumb.png?imgmax=800" width="45" height="51" /&gt;&lt;/a&gt;&amp;#160; | Word Options | Advanced and then make the changes as noted by the four arrows below.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-dMgKRcGZ1es/Tk1lhKQiP6I/AAAAAAABIY4/LftqgtIcHgg/s1600-h/image%25255B6%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/-wQP1i2swTBE/Tk1lj5DJhgI/AAAAAAABIZA/2qaR_KdC7D4/image_thumb%25255B2%25255D.png?imgmax=800" width="844" height="689" /&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Now when you copy and paste you will always get text only unless you do like would have done before and to to Home ribbon | Paste (down arrow) | Paste Special… but now choose Formatted Text (RTF) or HTML Format depending on your source.&lt;/p&gt;  &lt;p&gt;Thank you Microsoft!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-7850817714745196519?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/7850817714745196519/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=7850817714745196519' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/7850817714745196519'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/7850817714745196519'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/08/change-default-paste-to-unformatted.html' title='Change Default Paste to Unformatted Text in MS Word 2007'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/-tf9BcVGsfxE/Tk1le9aszGI/AAAAAAABIY0/yr4JOuZySes/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-8120684788932523775</id><published>2011-08-03T13:41:00.001-07:00</published><updated>2011-08-03T13:41:58.435-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='System Admin'/><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><title type='text'>How to add another user’s inbox to Outlook</title><content type='html'>&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;In Outlook you can open another users inbox if they make you a delegate / share it with you. You can also add it to your list of Mail Folders so that you can easily view it. Below are the instructions to do both of these things.&lt;/p&gt;  &lt;p&gt;In Outlook 2007 (maybe similar for other versions) do the follow:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Open &lt;strong&gt;Outlook 2007&lt;/strong&gt; if you have not already&lt;/li&gt;    &lt;li&gt;Go to the &lt;strong&gt;Tools &lt;/strong&gt;menu and choose &lt;strong&gt;Account Settings…&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Assuming you are now on the &lt;strong&gt;E-mail &lt;/strong&gt;tab, click your default account.&lt;/li&gt;    &lt;li&gt;Click the &lt;strong&gt;Change…&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Click &lt;strong&gt;More Settings…&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Click the &lt;strong&gt;Advanced&lt;/strong&gt; tab&lt;/li&gt;    &lt;li&gt;Click the &lt;strong&gt;Add…&lt;/strong&gt; button&lt;/li&gt;    &lt;li&gt;Type in the name of the user who’s mailbox or calendar, etc that you want to access&lt;/li&gt;    &lt;li&gt;Click &lt;strong&gt;OK &lt;/strong&gt;and &lt;strong&gt;OK &lt;/strong&gt;until you are back on the screen titled &lt;strong&gt;Change E-mail Account.&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Wait until the &lt;strong&gt;Next &amp;gt;&lt;/strong&gt; button becomes active and then click it.&lt;/li&gt;    &lt;li&gt;Click the &lt;strong&gt;Finish&lt;/strong&gt; button.&lt;/li&gt;    &lt;li&gt;Click the &lt;strong&gt;Close &lt;/strong&gt;button.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;You should now see your mailbox near your current inbox on the Navigation Pane (aka &lt;strong&gt;Mail Folder&lt;/strong&gt; pane). This will bring over the calendar, tasks, inbox, etc.&lt;/p&gt;  &lt;p&gt;If you don’t want to always have this person’s stuff in your Outlook, you can also access it by opening each time. To do this do the following:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Open &lt;strong&gt;Outlook 2007&lt;/strong&gt; if you have not already.&lt;/li&gt;    &lt;li&gt;Go to the &lt;strong&gt;File&lt;/strong&gt; menu and choose &lt;strong&gt;Open&lt;/strong&gt; and then &lt;strong&gt;Other User’s Folder…&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Type the name of the person in the &lt;strong&gt;Name… &lt;/strong&gt;textbox.&lt;/li&gt;    &lt;li&gt;Select what you want to access from the &lt;strong&gt;Folder type &lt;/strong&gt;drop down list. For example &lt;strong&gt;Inbox&lt;/strong&gt; to view the email or &lt;strong&gt;Calendar&lt;/strong&gt; for Calendar.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;NOTE: This opens it but does not keep it readily available to you. To access it again you can follow the same basic steps (Go to the &lt;strong&gt;File&lt;/strong&gt; menu and choose &lt;strong&gt;Open&lt;/strong&gt; and then choose the item you added – it should show at the end of the menu).&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-8120684788932523775?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/8120684788932523775/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=8120684788932523775' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/8120684788932523775'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/8120684788932523775'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/08/how-to-add-another-users-inbox-to.html' title='How to add another user’s inbox to Outlook'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-5375652739691035026</id><published>2011-08-01T11:15:00.001-07:00</published><updated>2011-08-01T11:15:45.320-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><category scheme='http://www.blogger.com/atom/ns#' term='Testing'/><title type='text'>Screen-scraping / Automation Tools</title><content type='html'>&lt;p&gt;In general I don’t recommend screenscraping at all, and it should only be a last resort. I do recommend test automation of UI if you are developing software though. Screenscraping will consume a ton of time to build it, and then to maintain it when the screens change in very minor ways. The main reason is inevitably the thing you want access to on the screen is not easy to get to and interact with. In many cases a tool will get you 80% to 90% of the way there and then you will hit a block wall or at least an endless pit that sucks all your time and resources to find a solution.&lt;/p&gt;  &lt;p&gt;Assuming you have decided that screen-scraping is worth it or you are doing UI test automation I do have a few recommendations if you use C# and are on the Windows platform. Some things to consider: What are you trying to scrap? What type of content are you trying to scrape? For example, is it a web page (does it have AJAX), Silverlight, or is it a desktop app (Is it Java or Native Windows). Will this be on a server and if so can you install FireFox (FF) or Internet Explorer (IE)? How will you can these tools. It also depends on how you will execute tool. For example, some tools can be called directly from C# while other are Java or even XML based. Some can be called from command line other can’t. &lt;/p&gt;  &lt;p&gt;Before I recommend the tool I HIGHLY recommend commenting the heck out of your code with Page and Page element you are working with. It is easy enough to write it and figure out what page you are and what element on that page you are working with when you are writing it for the first time because you are looking at it. However, when something changes and you have to modify it, it will be very time consuming to try to debug and/or figure out what you were doing. The reason is that often code becomes very cryptic because you are navigating through arrays of arrays or arrays or in general trying to get to things that can difficult to do.&lt;/p&gt;  &lt;p&gt;Ok, enough lecturing, here is what I recommend:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;   &lt;table border="1" cellspacing="0" cellpadding="0" width="852"&gt;&lt;tbody&gt;       &lt;tr&gt;         &lt;td valign="top" width="90"&gt;           &lt;p&gt;&lt;b&gt;Tool&lt;/b&gt;&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="54"&gt;           &lt;p&gt;&lt;b&gt;HTML (No AJAX)&lt;/b&gt;&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="54"&gt;           &lt;p&gt;&lt;b&gt;HTML (w/ AJAX)&lt;/b&gt;&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="77"&gt;           &lt;p&gt;&lt;b&gt;Silverlight&lt;/b&gt;&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="73"&gt;           &lt;p&gt;&lt;b&gt;Windows Desktop&lt;/b&gt;&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="85"&gt;           &lt;p&gt;&lt;b&gt;Java Application&lt;/b&gt;&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="106"&gt;           &lt;p&gt;&lt;b&gt;Language&lt;/b&gt;&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="311"&gt;           &lt;p&gt;&lt;b&gt;Comment&lt;/b&gt;&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="90"&gt;           &lt;p&gt;&lt;a href="http://white.codeplex.com/"&gt;White&lt;/a&gt;&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="54"&gt;           &lt;p&gt;N&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="54"&gt;           &lt;p&gt;N&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="77"&gt;           &lt;p&gt;Y&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="73"&gt;           &lt;p&gt;Y&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="85"&gt;           &lt;p&gt;Y&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="106"&gt;           &lt;p&gt;C#&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="311"&gt;           &lt;p&gt;This is my tool of choice for Silverlight or Windows Desktop or even Java applications. It reminds me of Watin (see below) as far as programming style and being easy and intuitive. Requires IE/FF. Don’t use the mouse when running, but can “help script” if gets stuck by moving mouse.&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="90"&gt;           &lt;p&gt;&lt;a href="http://watin.org/"&gt;Watin&lt;/a&gt;&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="54"&gt;           &lt;p&gt;Y&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="54"&gt;           &lt;p&gt;Y&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="77"&gt;           &lt;p&gt;N&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="73"&gt;           &lt;p&gt;N&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="85"&gt;           &lt;p&gt;N&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="106"&gt;           &lt;p&gt;C#&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="311"&gt;In general this is the tool of choice for HTML with or without AJAX. Easy and intuitive to work with.&lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="90"&gt;           &lt;p&gt;&lt;a href="http://web-harvest.sourceforge.net/"&gt;WebHarvest&lt;/a&gt;&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="54"&gt;           &lt;p&gt;Y&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="54"&gt;           &lt;p&gt;N&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="77"&gt;           &lt;p&gt;N&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="73"&gt;           &lt;p&gt;N&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="85"&gt;           &lt;p&gt;N&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="106"&gt;           &lt;p&gt;Java or Command Line&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="311"&gt;           &lt;p&gt;This is nice because it simulates browser so no browser needed, but this also means no support for AJAX or javascript. It is XML based and you don’t really write java code, you write XML, so it is all declarative programming. Kind of different, but quick and effective for plain HTML sites.&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="90"&gt;&lt;a href="http://seleniumhq.org/" target="_blank"&gt;Selenium&lt;/a&gt;&lt;/td&gt;          &lt;td valign="top" width="54"&gt;Y&lt;/td&gt;          &lt;td valign="top" width="54"&gt;Y&lt;/td&gt;          &lt;td valign="top" width="77"&gt;* See Silverlight-Selenium&lt;/td&gt;          &lt;td valign="top" width="73"&gt;N&lt;/td&gt;          &lt;td valign="top" width="85"&gt;N&lt;/td&gt;          &lt;td valign="top" width="106"&gt;C#/Java, Command Line, and most popular languages.&lt;/td&gt;          &lt;td valign="top" width="311"&gt;I would try Watin first in most cases, but don’t discount Selenium either. It is a scalable solution that is supported by many languages and platforms and browsers. Has a recorder that can be useful. Has complete IDE. XPath based which I find not as intuitive or easy to debug as Watin, but can be effective at navigating a page.&lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="90"&gt;&lt;a href="http://code.google.com/p/silverlight-selenium/" target="_blank"&gt;Silverlight-Selenium&lt;/a&gt;&lt;/td&gt;          &lt;td valign="top" width="54"&gt;N&lt;/td&gt;          &lt;td valign="top" width="54"&gt;N&lt;/td&gt;          &lt;td valign="top" width="77"&gt;Y&lt;/td&gt;          &lt;td valign="top" width="73"&gt;N&lt;/td&gt;          &lt;td valign="top" width="85"&gt;N&lt;/td&gt;          &lt;td valign="top" width="106"&gt;C#&lt;/td&gt;          &lt;td valign="top" width="311"&gt;This still uses Selenium is actually just an extension to Selenium. I think White is easier to use and a bit more robust, but if White doesn’t work for your Silverlight app try this.&lt;/td&gt;       &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-5375652739691035026?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/5375652739691035026/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=5375652739691035026' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/5375652739691035026'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/5375652739691035026'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/08/screen-scraping-automation-tools.html' title='Screen-scraping / Automation Tools'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-2161475444433256250</id><published>2011-07-28T13:58:00.001-07:00</published><updated>2011-07-28T13:58:43.155-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='System Admin'/><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Batch Files'/><title type='text'>Using command line to control Windows Scheduled Tasks</title><content type='html'>&lt;p&gt;You can control, monitor, change, etc Windows Scheduled Tasks using &lt;strong&gt;schtasks &lt;/strong&gt;from the command line. You can use it on your local machine or a remote machine such as a server.&lt;/p&gt;  &lt;p&gt;In the examples below let’s assume that the Windows Scheduled Task you are interested in is called EventLogImport. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;&lt;font size="5"&gt;IMPORTANT: &lt;/font&gt;For any of the commands or examples below, you can add a /S and then the servername to execute the command against a remote machine running Windows. &lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;h2&gt;Monitoring&lt;/h2&gt;  &lt;h3&gt;&lt;font style="font-weight: bold"&gt;Basic Info on local machine&lt;/font&gt;&lt;/h3&gt;  &lt;p&gt;&lt;font color="#008000"&gt;schtasks /QUERY /TN EventLogImport&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;font style="font-weight: bold"&gt;Basic Info for remote machine&lt;/font&gt;&lt;/h3&gt;  &lt;p&gt;&lt;font color="#008000"&gt;schtasks /QUERY /S serverNameHere /TN EventLogImport&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;font style="font-weight: bold"&gt;Verbose Info&lt;/font&gt;&lt;/h3&gt;  &lt;p&gt;&lt;font color="#008000"&gt;schtasks /QUERY /V /TN EventLogImport&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;font style="font-weight: bold"&gt;Verbose Info with CSV output to screen&lt;/font&gt;&lt;/h3&gt;  &lt;p&gt;&lt;font color="#008000"&gt;schtasks /QUERY /FO CSV /V /TN EventLogImport&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;NOTE: Other options are TABLE and LIST. The /V is for Verbose.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;To remove the header row you can use the MORE command to start reading at the second line&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;schtasks /QUERY /FO CSV /V /TN EventLogImport | more +1&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;font style="font-weight: bold"&gt;Verbose Info with CSV output to file&lt;/font&gt;&lt;/h3&gt;  &lt;p&gt;This will clear the status.csv if it exists, else it will create a new file.&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;schtasks /QUERY /FO CSV /V /TN EventLogImport &amp;gt; c:\temp\status.csv&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;To append to the file if you call two or more of these in a row, use the &amp;gt;&amp;gt; instead of &amp;gt;.&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;schtasks /QUERY /FO CSV /V /TN EventLogImport &amp;gt;&amp;gt; c:\temp\status.csv&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;To remove the header row you can use the MORE command to start reading at the second line&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;schtasks /QUERY /FO CSV /V /TN EventLogImport | more +1 &amp;gt;&amp;gt; EventLogImportScheduledJobStatus.csv&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;Controlling&lt;/h2&gt;  &lt;h3&gt;&lt;/h3&gt;  &lt;h3&gt;&lt;font style="font-weight: bold"&gt;Disable a Scheduled Task&lt;/font&gt;&lt;/h3&gt;  &lt;p&gt;&lt;font color="#008000"&gt;schtasks /CHANGE /TN EventLogImport /DISABLE&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;font style="font-weight: bold"&gt;Enable a Scheduled Task&lt;/font&gt;&lt;/h3&gt;  &lt;p&gt;&lt;font color="#008000"&gt;schtasks /CHANGE /TN EventLogImport /ENABLE&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;Other Commands&lt;/h2&gt;  &lt;p&gt;You can also create, delete, run, or kill scheduled tasks as well. For information on how to do this, I recommend typing &lt;font color="#008000"&gt;&lt;strong&gt;schtasks /?&lt;/strong&gt;&lt;/font&gt; at any command prompt.&lt;/p&gt;  &lt;p&gt;For help on a specific switch, try one of the following:&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;SCHTASKS     &lt;br /&gt;SCHTASKS /?      &lt;br /&gt;SCHTASKS /Run /?      &lt;br /&gt;SCHTASKS /End /?      &lt;br /&gt;SCHTASKS /Create /?      &lt;br /&gt;SCHTASKS /Delete /?      &lt;br /&gt;SCHTASKS /Query&amp;#160; /?      &lt;br /&gt;SCHTASKS /Change /?      &lt;br /&gt;SCHTASKS /ShowSid /?&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-2161475444433256250?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/2161475444433256250/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=2161475444433256250' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/2161475444433256250'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/2161475444433256250'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/07/using-command-line-to-control-windows.html' title='Using command line to control Windows Scheduled Tasks'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-7608011747177693438</id><published>2011-07-26T14:43:00.001-07:00</published><updated>2011-07-26T14:43:40.971-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Getting Started with Microsoft Charting</title><content type='html'>&lt;p&gt;Microsoft has provided a very nice charting package that is available on the WinForms and ASP.NET and is included (built into) .NET 4. It is also available for download with .NET 3.5. It is a VERY robust charting package that is extremely customizable. In fact, you can even modify the images before they are sent to the user (in the case of ASP.NET). I am sure there is something this package can’t do, but I have not ran into it yet.&lt;/p&gt;  &lt;p&gt;It is actually quite easy to use, but it is best if you read through some examples. The best way to get started in my opinion is to follow the first link below. If you go through the tutorial you will be in good shape. Once you have done that, you may want to check the second link out for additional references. Next check the official docs when you need more info on specific properties, etc. The final link is really just a cool snippet of code to get you started in the right direction if you need to generate your own gradients for your charts; for example in a bar or column chart.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.4guysfromrolla.com/articles/072209-1.aspx" target="_blank"&gt;Using Microsoft’s Chart Controls In An ASP.NET Application: Getting Started (by Scott Mitchell)&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2010/02/07/built-in-charting-controls-vs-2010-and-net-4-series.aspx" target="_blank"&gt;Built-in Charting Control (VS 2010 and .NET 4 Series) – ScottGu’s Blog&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd467029.aspx" target="_blank"&gt;Official Documentation&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://forums.asp.net/t/1333757.aspx/1?rectangle+with+a+gradient+fill+and+bottom+and+right+border+poor+quality+" target="_blank"&gt;Post that shows basic idea of how to create your own gradient image that can then be used as a background in a chart.&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-7608011747177693438?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/7608011747177693438/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=7608011747177693438' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/7608011747177693438'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/7608011747177693438'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/07/getting-started-with-microsoft-charting.html' title='Getting Started with Microsoft Charting'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-2043422831321651496</id><published>2011-07-15T11:28:00.001-07:00</published><updated>2011-07-15T11:30:18.889-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Easily Disable Row Selection for a Silverlight DataGrid</title><content type='html'>&lt;p&gt;This technique actually prevents the row from being selected and prevents an unwanted cell from being selected. The visual effect is that the row or cell in that row never appears to be selected.&lt;/p&gt;  &lt;p&gt;I assume you know how to load you DataGrid with data, etc. In my example, I only have one column of data. The trick to this solution is almost all in code behind. Also, this all assumes that you have set IsReadOnly=&amp;quot;True&amp;quot; either in the XAML or the code behind.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;In this example my DataGrid is named dgAnnouncements. I handle the SelectionChanged event as show in the method below.&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;private void dgAnnouncements_SelectionChanged(object sender, SelectionChangedEventArgs e)     &lt;br /&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; dgAnnouncements.SelectedItem = null;      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;The above gets us most of the way there, however you will notice that the cell itself can still be selected. To handle this we have to do a trick. &lt;/p&gt;  &lt;p&gt;In the XAML for the DataGrid you will need to add an invisible column at position 0 so that we can select it whenever someone tries to select another cell that they can see. &lt;/p&gt;  &lt;p&gt;Here is an example of the XAML for the DataGrid.&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;lt;sdk:DataGrid x:Name=&amp;quot;dgAnnouncements&amp;quot;      &lt;br /&gt;ItemsSource=&amp;quot;{Binding Data, ElementName=dsAnnouncements}&amp;quot;      &lt;br /&gt;AutoGenerateColumns=&amp;quot;False&amp;quot;       &lt;br /&gt;IsReadOnly=&amp;quot;True&amp;quot;       &lt;br /&gt;CurrentCellChanged=&amp;quot;DataGrid_CurrentCellChanged&amp;quot;       &lt;br /&gt;SelectionChanged=&amp;quot;dgAnnouncements_SelectionChanged&amp;quot;&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;sdk:DataGrid.Columns&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;sdk:DataGridTextColumn Binding=&amp;quot;{Binding Path=Nothing}&amp;quot; MinWidth=&amp;quot;0&amp;quot; MaxWidth=&amp;quot;0&amp;quot; /&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;sdk:DataGridTextColumn Binding=&amp;quot;{Binding Path=Title}&amp;quot;&amp;#160; /&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/sdk:DataGrid.Columns&amp;gt;      &lt;br /&gt;&amp;lt;/sdk:DataGrid&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Here is the code behind to redirect the current cell to our invisible cell.&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;private void DataGrid_CurrentCellChanged(object sender, EventArgs e)     &lt;br /&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if (dgAnnouncements.CurrentColumn != null)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; dgAnnouncements.CurrentColumn = dgAnnouncements.Columns[0];      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-2043422831321651496?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/2043422831321651496/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=2043422831321651496' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/2043422831321651496'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/2043422831321651496'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/07/easily-disable-row-selection-in.html' title='Easily Disable Row Selection for a Silverlight DataGrid'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-8935221294072015073</id><published>2011-07-14T13:33:00.001-07:00</published><updated>2011-07-14T13:33:31.447-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Creating your own MessageBox in Silverlight</title><content type='html'>&lt;p&gt;The MessageBox built into Silverlight is nice enough to use for simple OK, Cancel scenarios, but sometimes I want to change the text of the buttons in the MessageBox. For example, I may want Yes, No instead of OK, Cancel or maybe completely different text like Finished Now, Finish Later. The syntax of the MessageBox is simple enough so I decided to mirror it as closely as I could. This makes it as painless as possible to change from a MessageBox to my message box. The biggest difference in usage that I couldn’t figure out how to get around is that the MessageBox is a blocking call, but the UI thread still continues to render. When I tried to do the same, the UI thread did not continue to render. I looked at the code for MessageBox and it appears to be calling a Windows native MessageBox that is most likely different for OS that Silverlight is implemented on. So, I decided that in the Silverlight manor I would use asynchronous calls (event handlers) instead of a blocking call. When I use delegates the code is similar to using MessageBox.&lt;/p&gt;  &lt;p&gt;Okay, enough description I think. Here is source code for my version of MessageBox called MessageBox2&lt;/p&gt;  &lt;h3&gt;Download Source Code for Control&lt;/h3&gt;  &lt;p&gt;&lt;a href="https://sites.google.com/site/justgeeksextras/Home/MessageBox2.xaml.cs?attredirects=0&amp;amp;d=1"&gt;MessageBox2.xaml.cs&lt;/a&gt;&amp;#160;&amp;#160; &lt;a href="https://sites.google.com/site/justgeeksextras/Home/MessageBox2.xaml?attredirects=0&amp;amp;d=1"&gt;MessageBox2.xaml&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;Usage&lt;/h3&gt;  &lt;p&gt;You’ll notice I have 3 Show() methods instead of the standard 2 that MessageBox has. The reason is that I added one so that you can specify the text of OK and Cancel buttons. You’ll notice that I don’t return a MessageBoxResult and instead return the MessageBox itself.&amp;#160; Below is how you would use the MessageBox versus MessageBox2.&lt;/p&gt;  &lt;h4&gt;MessageBox&lt;/h4&gt;  &lt;p&gt;&lt;font color="#008000"&gt;MessageBoxResult result = MessageBox.Show(&amp;quot;This is a choice test&amp;quot;, &amp;quot;Some caption&amp;quot;, MessageBoxButton.OKCancel);     &lt;br /&gt;if (result == MessageBoxResult.OK)      &lt;br /&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; DoSomethingUsefulHere();      &lt;br /&gt;}      &lt;br /&gt;else if (result == MessageBoxResult.Cancel)      &lt;br /&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; DoSomethingUsefulHere();      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;h4&gt;MessageBox2&lt;/h4&gt;  &lt;p&gt;&lt;font color="#008000"&gt;var msgBox2 = MessageBox2.Show(&amp;quot;This is a choice test&amp;quot;, &amp;quot;Some caption&amp;quot;, MessageBoxButton.OKCancel, &amp;quot;Yes&amp;quot;, &amp;quot;No&amp;quot;);     &lt;br /&gt;msgBox2.OKButton.Click += delegate(object sender2, RoutedEventArgs e2) { DoSomethingUsefulHere(); };      &lt;br /&gt;msgBox2.CancelButton.Click += delegate(object sender2, RoutedEventArgs e2) { DoSomethingUsefulHere(); };&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;You could also use the Closed event and check the DialogResult to see if it was accepted or cancelled. Also, notice I changed the OK button to Yes and the Cancel button to No.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-8935221294072015073?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/8935221294072015073/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=8935221294072015073' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/8935221294072015073'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/8935221294072015073'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/07/creating-your-own-messagebox-in.html' title='Creating your own MessageBox in Silverlight'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-3383445709867400155</id><published>2011-06-28T09:45:00.001-07:00</published><updated>2011-06-28T09:46:03.733-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='MS SQL Server'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Reliable Sending of Email for.Net/C# using SQL Server</title><content type='html'>&lt;p&gt;If you want more reliable sending of emails from your .Net code you may think it is too much work to implement logging, retrying if smtp server is unavailable, control returned to user while email is sending, etc. The truth is that if you try to do it all via ASP.NET this can involve a lot of work. Thankfully, there is an easy way to meet all these requirements and not have to do much work at all. &lt;/p&gt;  &lt;p&gt;As it turns out SQL Server has a robust facility for sending emails called &lt;a href="http://msdn.microsoft.com/en-us/library/ms190307.aspx"&gt;Database Mail&lt;/a&gt;. It meets all the above requirements and these requirements are configurable. I have posted many entries on Database Mail such as resending emails, reviewing logs, etc. Just search on my blog for them. Much of the configuration comes from the Profile and Account settings you configure when you setup this info for your app.&lt;/p&gt;  &lt;p&gt;Below is a C# method that you can add to your project. Calling this will allow you to send email reliably from your app and not have to worry about the delivery of it. it assumes that you have a class called Config with two static methods YourConnectionString and AllowEmailsToBeSent. You can hard code those obviously. The two methods just pull the values from the Web.config, but it could be anywhere in theory. The first is just your database connection string and the second controls whether the contents of the email will be written to a hard coded path on your harddrive for testing or it will be connect to SQL Server and actually send the email. This is useful for development / testing when you don’t want to disturb real users.&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;/// &amp;lt;summary&amp;gt;     &lt;br /&gt;/// Calls SQL Server Send Mail procedure, or logs to log file      &lt;br /&gt;/// &amp;lt;/summary&amp;gt;      &lt;br /&gt;/// &amp;lt;param name=&amp;quot;fromEmailAddress&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;      &lt;br /&gt;/// &amp;lt;param name=&amp;quot;toEmailAddresses&amp;quot;&amp;gt;semi-colon separated list of recipients&amp;lt;/param&amp;gt;      &lt;br /&gt;/// &amp;lt;param name=&amp;quot;subject&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;      &lt;br /&gt;/// &amp;lt;param name=&amp;quot;body&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;      &lt;br /&gt;public void SendEmail(string fromEmailAddress, string toEmailAddresses, string subject, string body)      &lt;br /&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // this should never happen, but just so I will know about it      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if (string.IsNullOrEmpty(toEmailAddresses))      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; toEmailAddresses = &amp;quot;test@yourdomain.com&amp;quot;;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // this should never happen, but just so I will know about it      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if (string.IsNullOrEmpty(fromEmailAddress))      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; fromEmailAddress = &amp;quot;test@yourdomain.com&amp;quot;;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160; if (Config.AllowEmailsToBeSent)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // send email here      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; using (SqlConnection conn = new SqlConnection(Config.YourConnectionString))      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; conn.Open();&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // use sql server database mail instead of .net mail     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // so that we get retry, logging, automatic batching, etc for free. Better reliability and recover.      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; //-- for all parameters: &lt;/font&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/ms190307.aspx"&gt;&lt;font color="#008000"&gt;http://msdn2.microsoft.com/en-us/library/ms190307.aspx&lt;/font&gt;&lt;/a&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SqlCommand cmd = new SqlCommand(&amp;quot;msdb.dbo.sp_send_dbmail&amp;quot;, conn);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.CommandType = CommandType.StoredProcedure;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.Parameters.Add(&amp;quot;@profile_name&amp;quot;, SqlDbType.VarChar).Value = &amp;quot;Your Profile name here&amp;quot;;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.Parameters.Add(&amp;quot;@recipients&amp;quot;, SqlDbType.VarChar).Value = toEmailAddresses;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.Parameters.Add(&amp;quot;@subject&amp;quot;, SqlDbType.VarChar).Value = subject;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.Parameters.Add(&amp;quot;@body&amp;quot;, SqlDbType.VarChar).Value = body;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.ExecuteNonQuery();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; else      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; StreamWriter writer = new StreamWriter(@&amp;quot;c:\Email.log&amp;quot;, true);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; using (writer)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; writer.WriteLine(&amp;quot;\r\n\r\nDate/Time Stamp: &amp;quot; + DateTime.Now.ToLocalTime());      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; writer.WriteLine(&amp;quot;From: &amp;quot; + fromEmailAddress);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; writer.WriteLine(&amp;quot;To: &amp;quot; + toEmailAddresses);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; writer.WriteLine(&amp;quot;Subject: &amp;quot; + subject);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; writer.WriteLine(&amp;quot;Body: &amp;quot; + body);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;}      &lt;br /&gt;&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-3383445709867400155?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/3383445709867400155/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=3383445709867400155' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/3383445709867400155'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/3383445709867400155'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/06/reliable-sending-of-email-fornetc-using.html' title='Reliable Sending of Email for.Net/C# using SQL Server'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-6726281097225672490</id><published>2011-06-27T15:39:00.001-07:00</published><updated>2011-06-27T15:39:56.425-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Show JavaScript alert() or execute other code from Code-Behind</title><content type='html'>&lt;p&gt;I find that sometimes I need to show the user a JavaScript alert for something I don’t want them to be able to miss and I only want to show it based on some server-side (Code-Behind) code. This will work for most any chunk of JavaScript code as well.&lt;/p&gt;  &lt;p&gt;Below is the code that you can put in your Page_Load()&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;if (!Page.ClientScript.IsClientScriptBlockRegistered(&amp;quot;MyMadeUpNameHere&amp;quot;))     &lt;br /&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; string jscript = &amp;quot;alert('test here');&amp;quot;;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), &amp;quot;MyMadeUpNameHere&amp;quot;, jscript, true);      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Notice that MyMadeUpNameHere is some unique string that allows you to not have multiple copies of your code on the page. This ensures that you will only have it execute once. If you don’t want that functionality then don’t do the check.&lt;/p&gt;  &lt;p&gt;In this example, the user will see the ‘test here’ in a JavaScript alert (Message Box).&lt;/p&gt;  &lt;p&gt;Note, that the RegisterClientScriptBlock puts the JavaScript immediately below the opening form tag. If your code references any form elements or any other elements on the page this is most likely going to be too early since the page has not finished loading. This makes this method good for simple things like I did here that doesn’t really care about the page, or you can use it to register JavaScript functions that is executed later in the page or in an event handler. &lt;/p&gt;  &lt;p&gt;If you want your code to execute LATER then I recommend using the RegisterStartupScript and IsStartUpScriptRegistered methods instead. This code executes at the end of the page after all the items on the page have finished loading. Here is the same code as above, but with the StartUp versions.&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;if (!Page.ClientScript.IsStartupScriptRegistered(&amp;quot;MyMadeUpNameHere&amp;quot;))     &lt;br /&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; string jscript = &amp;quot;alert('test here');&amp;quot;;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Page.ClientScript.RegisterStartupScript(this.GetType(), &amp;quot;MyMadeUpNameHere&amp;quot;, jscript, true);      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Like I said before, if you had more complex logic you could put it earlier in the page and just execute the function using the RegisterStartupScript. You can also put your complex logic in functions in JScript include and use the RegisterClientScriptInclude. See &lt;a href="http://justgeeks.blogspot.com/2009/10/add-javascript-file-to-master-page-in.html"&gt;here&lt;/a&gt; for more details on that.&lt;/p&gt;  &lt;p&gt;I don’t know why I can never remember which methods to use for showing a JavaScript alert or executing other JavaScript code when the page loads, so I am writing in down for me and everyone else to have.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-6726281097225672490?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/6726281097225672490/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=6726281097225672490' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/6726281097225672490'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/6726281097225672490'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/06/show-javascript-alert-or-execute-other.html' title='Show JavaScript alert() or execute other code from Code-Behind'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-139118252593149948</id><published>2011-06-21T17:29:00.001-07:00</published><updated>2011-06-21T17:29:28.240-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MS SQL Server'/><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>Get usage for all columns in a SQL Server database</title><content type='html'>&lt;p&gt;First if you just want to know how one column is used you want to use the UI or check out my &lt;a title="http://justgeeks.blogspot.com/2007/10/finding-column-references-in-sql-server.html" href="http://justgeeks.blogspot.com/2007/10/finding-column-references-in-sql-server.html"&gt;other entry&lt;/a&gt;. If however you want to scan your entire database and determine the dependencies (usage) of each and every column in the database then stay here. The code found in either of these places will only look at the database references (stored procedures, functions, views, triggers). This means if you are using something like SSIS, LINQ, Entity Framework, embedded SQL in your code, etc you will need to check these area on your own. &lt;/p&gt;  &lt;p&gt;With that said, I really just continued the thought from my &lt;a title="http://justgeeks.blogspot.com/2007/10/finding-column-references-in-sql-server.html" href="http://justgeeks.blogspot.com/2007/10/finding-column-references-in-sql-server.html"&gt;other entry&lt;/a&gt; (same as the one I noted above). The first step is to convert the stored procedure used there to one that just dumps the data to a table for later querying. I call this table ColumnUsage. I also add a TagName to the table so that you can easily identify your results among other results in that table. That way you can compare results over time, or just support multiple users. The table will be created the first time the stored procedure is executed.&lt;/p&gt;  &lt;p&gt;Here is the new stored proc&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;/****** Object:&amp;#160; StoredProcedure [dbo].[UTL_07_WriteColumnUsageToColumnUsageTable]&amp;#160;&amp;#160;&amp;#160; Script Date: 06/21/2011 15:25:47 ******/     &lt;br /&gt;SET ANSI_NULLS ON      &lt;br /&gt;GO      &lt;br /&gt;SET QUOTED_IDENTIFIER ON      &lt;br /&gt;GO&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;alter PROCEDURE [dbo].[UTL_07_WriteColumnUsageToColumnUsageTable]     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; @vcTableName varchar(100),      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; @vcColumnName varchar(100),      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; @tagName varchar(100)      &lt;br /&gt;AS      &lt;br /&gt;/************************************************************************************************      &lt;br /&gt;DESCRIPTION:&amp;#160;&amp;#160;&amp;#160; writes all stored procedures, views, triggers      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; and user-defined functions that reference the      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; table/column passed into this proc into the ColumnUsage table.      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;PARAMETERS:      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; @vcTableName - table containing searched column      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; @vcColumnName&amp;#160;&amp;#160;&amp;#160; - column being searched for      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; @tagName - a name you make up to so you can later query for your results&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; This procedure must be installed in the database where it will     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; be run due to it's use of database system tables.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;USAGE:&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160; UTL_07_WriteColumnUsageToColumnUsageTable 'schema.tablename', 'columnname', 'tagName'      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;AUTHOR:&amp;#160;&amp;#160;&amp;#160; Karen Gayda&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;DATE: 07/19/2007&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;MODIFICATION HISTORY:     &lt;br /&gt;WHO&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DATE&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DESCRIPTION      &lt;br /&gt;---&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ----------&amp;#160;&amp;#160;&amp;#160; -------------------------------------------      &lt;br /&gt;Brent Vermilion&amp;#160;&amp;#160;&amp;#160; 06.21.2011&amp;#160;&amp;#160;&amp;#160; Recreated such that writes to a table instead of output      &lt;br /&gt;*************************************************************************************************/      &lt;br /&gt;SET NOCOUNT ON&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;IF (NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dbo' AND&amp;#160; TABLE_NAME = 'ColumnUsage'))     &lt;br /&gt;BEGIN      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; CREATE TABLE dbo.ColumnUsage      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; (      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ID int NOT NULL IDENTITY (1, 1),      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; TableName varchar(500) NOT NULL,      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ColumnName varchar(500) NOT NULL,      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; UsedByType varchar(50) NOT NULL,      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; UsedByName varchar(2000) NOT NULL,      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; TagName varchar(100) NOT NULL      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; )&amp;#160; ON [PRIMARY]&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;&amp;#160;&amp;#160;&amp;#160; ALTER TABLE dbo.ColumnUsage ADD CONSTRAINT     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; PK_ColumnUsage PRIMARY KEY CLUSTERED       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; (      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ID      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;END&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;insert into dbo.ColumnUsage(TableName, ColumnName, UsedByType, TagName, UsedByName)     &lt;br /&gt;SELECT DISTINCT @vcTableName, @vcColumnName, 'Stored Procedure', @tagName, SUBSTRING(o.NAME,1,60) AS [Procedure Name]      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; FROM sysobjects o      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; INNER JOIN syscomments c      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ON o.ID = c.ID      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WHERE&amp;#160;&amp;#160;&amp;#160;&amp;#160; o.XTYPE = 'P'      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; AND c.Text LIKE '%' + @vcColumnName + '%' + @vcTableName + '%'&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ORDER BY&amp;#160; [Procedure Name]&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;font color="#008040"&gt;insert into dbo.ColumnUsage(TableName, ColumnName, UsedByType, TagName, UsedByName)     &lt;br /&gt;SELECT DISTINCT @vcTableName, @vcColumnName, 'View', @tagName, SUBSTRING(o.NAME,1,60) AS [View Name]      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; FROM sysobjects o      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; INNER JOIN syscomments c      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ON o.ID = c.ID      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WHERE&amp;#160;&amp;#160;&amp;#160;&amp;#160; o.XTYPE = 'V'      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; AND c.Text LIKE '%' + @vcColumnName + '%' + @vcTableName + '%'&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ORDER BY&amp;#160; [View Name]&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;font color="#008040"&gt;insert into dbo.ColumnUsage(TableName, ColumnName, TagName, UsedByName, UsedByType)     &lt;br /&gt;SELECT DISTINCT @vcTableName, @vcColumnName, @tagName, SUBSTRING(o.NAME,1,60) AS [Function Name],       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CASE WHEN o.XTYPE = 'FN' THEN 'Scalar Function'      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WHEN o.XTYPE = 'IF' THEN 'Inline Function'      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WHEN o.XTYPE = 'TF' THEN 'Table Function'      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ELSE '? Function'      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; END       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; as [Function Type]      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; FROM sysobjects o      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; INNER JOIN syscomments c      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ON o.ID = c.ID      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WHERE&amp;#160;&amp;#160;&amp;#160;&amp;#160; o.XTYPE IN ('FN','IF','TF')      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; AND c.Text LIKE '%' + @vcColumnName + '%' + @vcTableName + '%'&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ORDER BY&amp;#160; [Function Name]&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;font color="#008040"&gt;insert into dbo.ColumnUsage(TableName, ColumnName, UsedByType, TagName, UsedByName)     &lt;br /&gt;SELECT DISTINCT @vcTableName, @vcColumnName, 'Trigger', @tagName, SUBSTRING(o.NAME,1,60) AS [Trigger Name]      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; FROM sysobjects o      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; INNER JOIN syscomments c      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ON o.ID = c.ID      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WHERE&amp;#160;&amp;#160;&amp;#160;&amp;#160; o.XTYPE = 'TR'      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; AND c.Text LIKE '%' + @vcColumnName + '%' + @vcTableName + '%'&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ORDER BY&amp;#160; [Trigger Name]      &lt;br /&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Now that we have that we can write another stored proc that will loop over every column in our database and call the above stored procedure for each column. Please note, depending on how complex your schema, the number of stored procedures, number of columns, etc this query could take quite a long time. Here is the stored proc to scan your database.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;font color="#008000"&gt;/****** Object:&amp;#160; StoredProcedure [dbo].[UTL_08_WriteAllColumnUsageToColumnUsageTable]&amp;#160;&amp;#160;&amp;#160; Script Date: 06/21/2011 15:25:47 ******/     &lt;br /&gt;SET ANSI_NULLS ON      &lt;br /&gt;GO      &lt;br /&gt;SET QUOTED_IDENTIFIER ON      &lt;br /&gt;GO&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;alter PROCEDURE [dbo].[UTL_08_WriteAllColumnUsageToColumnUsageTable]     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; @TagName varchar(100)      &lt;br /&gt;AS      &lt;br /&gt;/************************************************************************************************      &lt;br /&gt;DESCRIPTION:&amp;#160;&amp;#160;&amp;#160; writes all stored procedures, views, triggers      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; and user-defined functions that reference the      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; table/column passed into this proc into the ColumnUsage table.      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;PARAMETERS:      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; @TagName - a name you make up to so you can later query for your results&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; This procedure must be installed in the database where it will     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; be run due to it's use of database system tables.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;USAGE:&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160; UTL_08_WriteAllColumnUsageToColumnUsageTable 'tagName'      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;AUTHOR:&amp;#160;&amp;#160;&amp;#160; Brent Vermilion&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;DATE: 06/21/2011     &lt;br /&gt;*************************************************************************************************/&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Declare @TableName as nvarchar(512)     &lt;br /&gt;Declare @ColumnName as nvarchar(300)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Declare ColumnCursor CURSOR FAST_FORWARD FOR     &lt;br /&gt;SELECT TABLE_SCHEMA + '.' + TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS order by TABLE_SCHEMA, TABLE_NAME, ORDINAL_POSITION, COLUMN_NAME&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;OPEN ColumnCursor     &lt;br /&gt;FETCH NEXT FROM ColumnCursor      &lt;br /&gt;into @TableName, @ColumnName&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;WHILE @@FETCH_STATUS = 0     &lt;br /&gt;BEGIN      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; -- do row specific stuff here      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; exec UTL_07_WriteColumnUsageToColumnUsageTable @TableName, @ColumnName, @TagName&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160; FETCH NEXT FROM ColumnCursor     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; into @TableName, @ColumnName      &lt;br /&gt;END&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;CLOSE ColumnCursor     &lt;br /&gt;DEALLOCATE ColumnCursor&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;After executing the either of the stored procedure on your database you can answer some very useful questions.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;What columns are not being used?&lt;/li&gt;    &lt;p&gt;&lt;font color="#008000"&gt;select distinct allcols.TABLE_SCHEMA + '.' + allcols.TABLE_NAME, COLUMN_NAME, UsedByName from        &lt;br /&gt;INFORMATION_SCHEMA.COLUMNS allcols         &lt;br /&gt;left outer join ColumnUsage usage         &lt;br /&gt;on (allcols.TABLE_SCHEMA + '.' + allcols.TABLE_NAME = usage.TableName and allcols.COLUMN_NAME = usage.ColumnName)        &lt;br /&gt;where UsedByName is null&lt;/font&gt;&lt;/p&gt;    &lt;li&gt;What is using a particular column?     &lt;br /&gt;&lt;font color="#008040"&gt;select * from ColumnUsage where TableName = 'MyTableHere' and ColumnName = 'MyColumnHere'&lt;/font&gt;&lt;/li&gt; &lt;/ol&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-139118252593149948?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/139118252593149948/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=139118252593149948' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/139118252593149948'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/139118252593149948'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/06/get-usage-for-all-columns-in-sql-server.html' title='Get usage for all columns in a SQL Server database'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-1046904666979504894</id><published>2011-06-17T14:05:00.001-07:00</published><updated>2011-06-17T16:58:37.411-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><category scheme='http://www.blogger.com/atom/ns#' term='RIA Services'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Deploying RIA Services seems a bit too complicated</title><content type='html'>&lt;p&gt;I have spent many hours troubleshooting deployments my Silverlight application (server side) just to figure out that I have the wrong version of a .dll. It seems that the easiest way to guarantee that you have the correct assemblies is to open your web project and select all the References and change the Copy Local property to True. I didn’t notice more than a second or two delay in build time and then when I deploy I know that I will get all the assemblies I need. &lt;/p&gt;  &lt;p&gt;Generally, you don’t need to worry about the references changing except when you get a service pack, a new version, upgrade, etc so if you like you can keep the Copy Local set to False most of the time. Then when your references change be sure to change the Copy Local back to True.&lt;/p&gt;  &lt;p&gt;I’m so lost as to why this is so difficult.&lt;/p&gt;  &lt;p&gt;If anyone has a better way, please let me know. What price can you put on sanity? &lt;img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://lh3.ggpht.com/-sQi3ywTz14Q/TfvBtdqicCI/AAAAAAAA_nY/H-e5s45Gc2w/wlEmoticon-smile%25255B2%25255D.png?imgmax=800" /&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-1046904666979504894?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/1046904666979504894/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=1046904666979504894' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1046904666979504894'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1046904666979504894'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/06/deploying-ria-services-seems-bit-too.html' title='Deploying RIA Services seems a bit too complicated'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/-sQi3ywTz14Q/TfvBtdqicCI/AAAAAAAA_nY/H-e5s45Gc2w/s72-c/wlEmoticon-smile%25255B2%25255D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-2979818723132621095</id><published>2011-06-15T16:31:00.001-07:00</published><updated>2011-06-15T16:31:45.265-07:00</updated><title type='text'>Renaming a Visual Studio Project</title><content type='html'>&lt;p&gt;I had a project I wanted to rename from ProjectA to ProjectB. I wasn’t quite sure how to do this. I mean, I wanted the namespaces to change, the default namespaced (used for new files), project file names, filenames, etc. In my case, I had multiple projects in my solution. I wasn’t sure how this would work. &lt;/p&gt;  &lt;p&gt;In the end, I used a search and replace tool to change every reference in every fiel from ProjectA to ProjectB. Then I renamed all the files. To find the files that need to be renamed, you might want to &lt;a href="http://justgeeks.blogspot.com/2011/06/using-batch-file-or-command-line-to.html"&gt;check here&lt;/a&gt;. Then I opened the solution up in Visual Studio 2010 (VS2010) and it just worked! So cool! Thanks to most files being text or XML this worked seamlessly.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-2979818723132621095?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/2979818723132621095/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=2979818723132621095' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/2979818723132621095'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/2979818723132621095'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/06/renaming-visual-studio-project.html' title='Renaming a Visual Studio Project'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-1880844199565478424</id><published>2011-06-15T14:49:00.001-07:00</published><updated>2011-06-15T14:49:58.992-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='System Admin'/><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Batch Files'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows 7'/><title type='text'>Using Batch File or Command Line to recursively find all files that have a filename that contains a particular string</title><content type='html'>&lt;p&gt;It sounds like a tall order at first, but then it also sounds like something that should be built into Windows. In particular, I am using Windows 7, but I assume it works on XP as well.&lt;/p&gt;  &lt;p&gt;The solution is actually quite simple and is indeed built into Windows 7.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;dir /s /b *my string*&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;This will give you something similar to:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;c:\temp\This is a test of my string.txt&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;c:\mydocs\My string could be found here.txt&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;As shown above it will search the current directory and all directories below the current one for files that contain ‘my string’. You can also specify something like this to specify the directory you want to start searching in regardless of your current directory.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;dir /s /b “c:\mydocs\*my string*” &lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You can use all the standard wild card syntax such as the following to search only .html files. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;dir /s /b “c:\mydocs\*my string*.html” &lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;In case you are wondering the /s is for recursive and the /b is to return just the path\filename (no file info such as date, size, etc).&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-1880844199565478424?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/1880844199565478424/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=1880844199565478424' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1880844199565478424'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1880844199565478424'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/06/using-batch-file-or-command-line-to.html' title='Using Batch File or Command Line to recursively find all files that have a filename that contains a particular string'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-4969192023689655695</id><published>2011-06-15T13:17:00.001-07:00</published><updated>2011-06-15T13:17:16.505-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Easy Way to remove Visual Studio 2010 project from Visual SourceSafe</title><content type='html'>&lt;p&gt;Visual SourceSafe creates .scc files when you add a Visual Studio 2010 (VS2010) project to Visual SourceSafe. The easiest way I know to remove a project from Visual SourceSafe version control (while still leaving the actual files in SourceSafe) is to do the following. You might want to do this if you want to make a copy of your project to use as a starting point for your new project or maybe want to share the project with someone else or maybe you are changing version control systems. Regardless, below are the steps to do this.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Make a copy of your project using copy and paste in Windows Explorer.&lt;/li&gt;    &lt;li&gt;Recursively Search the project directory for all files that end in .scc. You can do this using the Search in Windows 7 or Search Companion (I think it was called in XP).&lt;/li&gt;    &lt;li&gt;Delete the results found.&lt;/li&gt;    &lt;li&gt;Open solution in VS2010. It will complain and eventually ask if you want to permanently remove the bindings. Do so for each project in your solution. You can go to the File menu | Source Control | Change Source Control… If there are any projects that are still bound, you can unbind them. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;That’s it. Relatively easy actually.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-4969192023689655695?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/4969192023689655695/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=4969192023689655695' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/4969192023689655695'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/4969192023689655695'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/06/easy-way-to-remove-visual-studio-2010.html' title='Easy Way to remove Visual Studio 2010 project from Visual SourceSafe'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-3061314423732860486</id><published>2011-06-15T11:52:00.001-07:00</published><updated>2011-06-15T11:52:26.213-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='RIA Services'/><category scheme='http://www.blogger.com/atom/ns#' term='ADO.NET Entity Framework'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><category scheme='http://www.blogger.com/atom/ns#' term='Domain Service'/><title type='text'>Compiler error with VS2010 SP1 and SL 4 with WCF RIA Services and Entity Framework 4</title><content type='html'>&lt;p&gt;Did you have a VS2010 project (before installing VS2010 SP1 or RIA Service Pack 1) that used Silverlight 4 and WCF RIA Services and Entity Framework 4 (EF4) and now that VS2010 Service Pack 1 is installed (or maybe some other framework) your Silverlight Project no longer compiles. Chances are if you are using RIA Services you may have created files that you want to share (called &lt;a href="http://msdn.microsoft.com/en-us/library/ee707371%28v=vs.91%29.aspx" target="_blank"&gt;Shared Code&lt;/a&gt;)on the Server and the SL Client. This is done in RIA by using the .shared.cs file extension on a filename. &lt;/p&gt;  &lt;p&gt;After I installed either VS2010 SP1 or RIA Services SP1 and then I tried to compile my project and got a compiler error similar to:&lt;/p&gt;  &lt;h2&gt;&lt;font color="#ff0000"&gt;error CS0102: The type 'MyApp.Model.MyClassHere' already contains a definition for 'MyPropertyHere'&lt;/font&gt;&lt;/h2&gt;  &lt;p&gt;I learned that this may be a RIA Services SP1 regression bug from &lt;a href="http://forums.silverlight.net/forums/p/145841/481468.aspx" target="_blank"&gt;this forum&lt;/a&gt;. The &lt;a href="http://forums.silverlight.net/forums/p/207513/488706.aspx#488706" target="_blank"&gt;beta&lt;/a&gt; had issues also.&lt;/p&gt;  &lt;p&gt;It appears that this MAY be fixed now, but I’m not sure since I don’t have an issue exactly like what they had. I only have the issue if I have to shared files and one the classes (in one of the files) has a property or method that has a return type that is the other class type. If I get rid of that dependency and just return the object type instead then it compiles fine. While returning the type object, I have to cast every time I use it and that is silly and kind of a pain / ugly.&lt;/p&gt;  &lt;p&gt;I hope that helps someone. If anyone else has this issue I’d love to know about it.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-3061314423732860486?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/3061314423732860486/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=3061314423732860486' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/3061314423732860486'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/3061314423732860486'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/06/compiler-error-with-vs2010-sp1-and-sl-4.html' title='Compiler error with VS2010 SP1 and SL 4 with WCF RIA Services and Entity Framework 4'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-5539061134934136290</id><published>2011-06-03T18:57:00.001-07:00</published><updated>2011-06-03T18:57:23.214-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='CSS'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>How to Download File from inside an UpdatePanel in ASP.NET</title><content type='html'>&lt;p&gt;PartialPageRendering when used with the UpdatePanel is a great thing in general. One problem comes when you want to mess with the Response and call things like End which is required when you return want to return a file instead of the page you were on. An example of this is a GridView with a Download button below it. If you are not using the UpdatePanel then there is no problem and clicking the Download button will all you to download the file as expected. There are lots of posts on the web on how to do this so I won’t go into the code. However, it involves calling things like Response.Clear(), Response.ContentType, Response.AddHeader(), Response.End(). &lt;/p&gt;  &lt;p&gt;Now let’s assume you put the GridView in an UpdatePanel. All those Response calls noted above are things that the PartialPageRendering and UpdatePanel don’t know what to do with because they were expected something like the page that made the request. So we need to work around the issue. I found &lt;a href="http://forums.asp.net/t/1320694.aspx"&gt;some solutions&lt;/a&gt; on the internet, but didn’t really find them very easy or straight forward. So, I came up with my own.&lt;/p&gt;  &lt;h3&gt;Solution 1&lt;/h3&gt;  &lt;p&gt;One solution is to put the Download button outside the UpdatePanel. This tends to work best, but is not always possible.&lt;/p&gt;  &lt;h3&gt;Solution 2&lt;/h3&gt;  &lt;p&gt;If you can’t do solution 1, then consider faking it. What I mean is move the Download button which in my case is implemented as a LinkButton outside the UpdatePanel and hide it using css. Then add a Hyperlink inside the UpdatePanel. Now, on your page load you can set the hyperlink to have the same postback url as the LinkButton that is outside the UpdatePanel. That way when you click the hyperlink inside the UpdatePanel you are effectively doing the same thing as if you clicked the hidden LinkButton that is outside the UpdatePanel. Fairly simple.&lt;/p&gt;  &lt;p&gt;Here is the snippets of code to help you see what I am talking about.&lt;/p&gt;  &lt;p&gt;Here is the HyperLink that is inside the UpdatePanel and is also the button that you will be clicking in the Browser.&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;&amp;lt;asp:HyperLink ID=&amp;quot;btnExportToExcelClicker&amp;quot; runat=&amp;quot;server&amp;quot; Text=&amp;quot;Export all rows to Excel&amp;quot; /&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Here is the LinkButton that is invisible to the user and is outside the UpdatePanel&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;&amp;lt;asp:LinkButton ID=&amp;quot;btnExportToExcel&amp;quot; runat=&amp;quot;server&amp;quot; onclick=&amp;quot;btnExportToExcel_Click&amp;quot; Text=&amp;quot;Export all rows to Excel&amp;quot; style=&amp;quot;display:none;&amp;quot; /&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Here is the code-behind. In my code btnExportToExcelClicker is the button that is in the UpdatePanel and btnExportToExcel is the button that is outside the UpdatePanel. You will actually be clicking btnExportToExcelClicker because btnExportToExcel is hidden.&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;protected void Page_Load(object sender, EventArgs e)     &lt;br /&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; btnExportToExcelClicker.NavigateUrl = Page.ClientScript.GetPostBackClientHyperlink(btnExportToExcel, null);      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;This technique uses &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.getpostbackclienthyperlink.aspx" target="_blank"&gt;GetPostBackClientHperlink&lt;/a&gt; and can be expanded for other purposes and other controls. In some cases you may need to consider using &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.getpostbackeventreference.aspx" target="_blank"&gt;GetPostBackEventReferences&lt;/a&gt;, though I haven’t tried it. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-5539061134934136290?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/5539061134934136290/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=5539061134934136290' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/5539061134934136290'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/5539061134934136290'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/06/how-to-download-file-from-inside.html' title='How to Download File from inside an UpdatePanel in ASP.NET'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-7683686674962654018</id><published>2011-05-26T15:49:00.001-07:00</published><updated>2011-05-26T15:49:43.236-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Programmatically Setting Header on ASP.NET GridView</title><content type='html'>&lt;p&gt;It is actually very frustrating to change the header text on an ASP.NET GridView if you don’t do it in the right place. At first, I thought I would do it in the PreRender event as I figured that was plenty late in the cycle and should stick. Then I noticed it would not stick when I would sort for example. &lt;/p&gt;  &lt;p&gt;In the end, it was very easy once I figured out what the proper event in the page lifecycle to use. You answer to this riddle is the &lt;strong&gt;RowCreated&lt;/strong&gt; event. My GridView is called GridView1 in this example. I added &lt;strong&gt;&lt;font color="#008000"&gt;onrowcreated=”GridView1_RowCreated”&lt;/font&gt;&lt;/strong&gt; to my GridView in my .aspx file. In my code behind this is the code I used.&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)     &lt;br /&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if (e.Row.RowType == DataControlRowType.Header &amp;amp;&amp;amp; e.Row.Cells.Count &amp;gt; SOME_COLUMN_INDEX)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; e.Row.Cells[SOME_COLUMN_INDEX].Text = &amp;quot;New Header Text here&amp;quot;;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Some things to know. You can’t reference the HeaderRow because it is still null at this point. It is there, but not accessible via the GridView1.HeaderRow property. You need to use e.Row instead. You can be guaranteed that this is not null since we are its event handler. You may also want to make sure the cell you are trying to set is not out of bounds. As long as you check to make sure you are in the header row you should be ok though. An example of when you would not have cells is when you get the EmptyData row which is displayed only when there are no rows to display. In that case, there are no headers. So, in general, I found it safe to always check to make sure the item I assume is in the array is actually in the array.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-7683686674962654018?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/7683686674962654018/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=7683686674962654018' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/7683686674962654018'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/7683686674962654018'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/05/programmatically-setting-header-on.html' title='Programmatically Setting Header on ASP.NET GridView'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-5466929212140141089</id><published>2011-05-18T17:01:00.001-07:00</published><updated>2011-05-18T17:01:30.419-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='RIA Services'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><category scheme='http://www.blogger.com/atom/ns#' term='Domain Service'/><title type='text'>Programmatically adding Query Parameter to ASP.NET DomainDataSource</title><content type='html'>&lt;p&gt;I love the new ASP.NET DomainDataSource because it allows me to talk to my Domain Service. &lt;/p&gt;  &lt;p&gt;You could do this declaratively like the following:&lt;/p&gt;  &lt;h2&gt;Declaratively&lt;/h2&gt;  &lt;p&gt;&amp;lt;asp:DomainDataSource ID=&amp;quot;dsDetails&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;   &lt;br /&gt;&amp;lt;QueryParameters&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:ControlParameter ControlID=&amp;quot;GridView1&amp;quot; PropertyName=&amp;quot;SelectedValue&amp;quot; Name=&amp;quot;id&amp;quot; Type=&amp;quot;Int32&amp;quot; /&amp;gt;    &lt;br /&gt;&amp;lt;/QueryParameters&amp;gt;    &lt;br /&gt;&amp;lt;/asp:DomainDataSource&amp;gt;&lt;/p&gt;  &lt;p&gt;In this example, this a DomainDataSource that I have connect to a FormView. I want the FormView to update when a GridView called GridView1.SelectedValue changes. I am setting the QueryName and the DomainServiceTypeName in my Page_Init so you don’t see it in the declaration above, but you could put it there as well.&lt;/p&gt;  &lt;p&gt;In this scenario, the Query in my Domain Service is expecting a parameter called id. This must the Name property of the ControlParameter control.&lt;/p&gt;  &lt;h2&gt;Programmatically (Good Option)&lt;/h2&gt;  &lt;p&gt;We can do the same thing with the parameters, but this time do it programmatically. The declaration would now look like this:&lt;/p&gt;  &lt;p&gt;&amp;lt;asp:DomainDataSource ID=&amp;quot;dsDetails&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;   &lt;br /&gt;&amp;lt;/asp:DomainDataSource&amp;gt;&lt;/p&gt;  &lt;p&gt;Notice there is not QueryParameters declared, so we need to do this in code. The best place is in the Page_Init() method since it is very early in the page lifecycle.&lt;/p&gt;  &lt;p&gt;Add the following line to the Page_Init() method:&lt;/p&gt;  &lt;p&gt;dsDetails.QueryParameters.Add(new ControlParameter(&amp;quot;id&amp;quot;, TypeCode.Int32, &amp;quot;GridView1&amp;quot;, &amp;quot;SelectedValue&amp;quot;));&lt;/p&gt;  &lt;p&gt;This will do exactly the same as doing it declaratively, but now you nave more control of all the values passed since you are in code. One thing to point out is that when the GridView1.SelectedValue changes, the dsDetails datasource executes the query again automatically. That is why I like this method. &lt;/p&gt;  &lt;h2&gt;Programmatically (Okay Option)&lt;/h2&gt;  &lt;p&gt;The above is identical and great and my first choice. This approach here works best if you are getting your value from something that doesn’t change like the QueryString. If you need to set the current user, or some other value (like a querystring value) and don’t care that the dsDetails DomainDataSource will NOT be updated automatically and you will instead need to tell it to databind using something like SelectedItemChanged in the GridView1, you can use the Querying event on the DomainDataSource. In this case you would do the following.&lt;/p&gt;  &lt;p&gt;&amp;lt;asp:DomainDataSource ID=&amp;quot;dsEditor&amp;quot; runat=&amp;quot;server&amp;quot;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; onquerying=&amp;quot;dsEditor_Querying&amp;quot; &amp;gt;    &lt;br /&gt;&amp;lt;/asp:DomainDataSource&amp;gt;&lt;/p&gt;  &lt;p&gt;protected void dsDetails_Querying(object sender, Microsoft.Web.UI.WebControls.DomainDataSourceQueryingEventArgs e)   &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; e.QueryParameters.Clear();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; e.QueryParameters.Add(&amp;quot;id&amp;quot;, GridView1.SelectedValue);    &lt;br /&gt;}&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-5466929212140141089?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/5466929212140141089/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=5466929212140141089' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/5466929212140141089'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/5466929212140141089'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/05/programmatically-adding-query-parameter.html' title='Programmatically adding Query Parameter to ASP.NET DomainDataSource'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-750866560049031678</id><published>2011-05-04T17:33:00.001-07:00</published><updated>2011-05-04T17:44:45.520-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Dynamic Data'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='ADO.NET Entity Framework'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><category scheme='http://www.blogger.com/atom/ns#' term='Domain Service'/><title type='text'>Why aren’t my ForeignKeys being loaded on my Custom Dynamic Data page?</title><content type='html'>&lt;p&gt;This is one entry in a series of blog entries:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a title="Create CRUD UI using ASP.NET 4.0, FormView, Dynamic Data, DomainDataSource, Entity Framework, WC" href="http://justgeeks.blogspot.com/2011/04/create-crud-ui-using-aspnet-40-formview.html"&gt;Create CRUD UI using ASP.NET 4.0, FormView, Dynamic Data, DomainDataSource, Entity Framework, WCF Domain Service, LINQ, and custom validation - Part I&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a title="Create CRUD UI using ASP.NET 4.0, FormView, Dynamic Data, DomainDataSource, Entity Framework, WC" href="http://justgeeks.blogspot.com/2011/04/create-crud-ui-using-aspnet-40-formview_29.html"&gt;Create CRUD UI using ASP.NET 4.0, FormView, Dynamic Data, DomainDataSource, Entity Framework, WCF Domain Service, LINQ, and custom validation - Part II&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a title="Why aren’t my ForeignKeys being loaded on my Custom Dynamic Data page-" href="http://justgeeks.blogspot.com/2011/05/why-arent-my-foreignkeys-being-loaded.html"&gt;Why aren’t my ForeignKeys being loaded on my Custom Dynamic Data page?&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;If you look at Part I and Part II, you may have noticed that the Product Category is a textfield when it should be a Drop Down List of the Product Categories. If this were a page that was in the &lt;strong&gt;DynamicData\CustomPages&lt;/strong&gt; directory then you would not be having this problem. The reason we are having this problem is because we are calling &lt;strong&gt;EnableDynamicData()&lt;/strong&gt; on our &lt;strong&gt;FormView&lt;/strong&gt; which is great to get basic dynamic data functionality, but it doesn’t know how to load all the metadata for the Product entity. If you debug you will see that the &lt;strong&gt;ProductCategory DynamicControl&lt;/strong&gt; column is not of type &lt;strong&gt;MetaForeignKeyColumn&lt;/strong&gt;. After futher debugging you will see that much of the other metadata from the model is actually missing as well. Thankfully, the fix is very easy.&lt;/p&gt;  &lt;p&gt;Change from:&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;protected void Page_Init(object sender, EventArgs e)      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; FormView1.EnableDynamicData(typeof(MyDynamicDataExample.Models.Product));       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;to this:&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;protected void Page_Init(object sender, EventArgs e)      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // to get all the goodness like foreign-keys, etc we need to tell it to use our model       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; FormView1.SetMetaTable(Global.DefaultModel.GetTable(typeof(MyDynamicDataExample.Models.Product)));       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Also, from what I can tell the &lt;strong&gt;AutoLoadForeignKeys=”true”&lt;/strong&gt; attribute of the &lt;strong&gt;DynamicDataManager&lt;/strong&gt; has no bearing on whether the Drop Down List is populated or not.&lt;/p&gt;  &lt;p&gt;You may have also noticed that the &lt;strong&gt;ProductCategory&lt;/strong&gt; field when in &lt;strong&gt;ReadOnly&lt;/strong&gt; mode shows a link with an number showing instead of the nice text description of the product category.&amp;#160; Luckily, this is an easy fix as well. In the &lt;strong&gt;AWDomainService.cs&lt;/strong&gt; find we need to change the GetProducts() method to include the ProductCategory navigation property. This will cause the SQL that is generated to bring in the ProductCategory table.&lt;/p&gt;  &lt;p&gt;Change from:&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;public IQueryable&amp;lt;Product&amp;gt; GetProducts()      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; return this.ObjectContext.Products.OrderBy(o =&amp;gt; o.Name);       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;to this:&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;public IQueryable&amp;lt;Product&amp;gt; GetProducts()      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; return this.ObjectContext.Products.&lt;strong&gt;Include(&amp;quot;ProductCategory&amp;quot;)&lt;/strong&gt;.OrderBy(o =&amp;gt; o.Name);       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;The change above will do the trick. However, if you are using this Domain Service with a Silverlight Client, you should also update the AWDomainService.metadata.cs such that the ProductCategory property on the ProductMetadata class has the &lt;strong&gt;Include()&lt;/strong&gt; attribute. If you don’t have both of these Silverlight will not populate the ComboBox (assuming that is what you are using in Silverlight). &lt;/p&gt;  &lt;p&gt;Change from:&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;[Display(Name = &amp;quot;Product Category&amp;quot;)]      &lt;br /&gt;public ProductCategory ProductCategory { get; set; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;to this:&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;&lt;strong&gt;[Include()]        &lt;br /&gt;&lt;/strong&gt;[Display(Name = &amp;quot;Product Category&amp;quot;)]       &lt;br /&gt;public ProductCategory ProductCategory { get; set; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;You can download the complete source &lt;a href="https://sites.google.com/site/justgeeksextras/Home/MyDynamicDataExample-PartIII.7z?attredirects=0&amp;amp;d=1"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-750866560049031678?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/750866560049031678/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=750866560049031678' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/750866560049031678'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/750866560049031678'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/05/why-arent-my-foreignkeys-being-loaded.html' title='Why aren’t my ForeignKeys being loaded on my Custom Dynamic Data page?'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-6343058366962380129</id><published>2011-04-29T13:58:00.001-07:00</published><updated>2011-05-04T17:41:39.049-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Dynamic Data'/><category scheme='http://www.blogger.com/atom/ns#' term='RIA Services'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='ADO.NET Entity Framework'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><category scheme='http://www.blogger.com/atom/ns#' term='Domain Service'/><title type='text'>Create CRUD UI using ASP.NET 4.0, FormView, Dynamic Data, DomainDataSource, Entity Framework, WCF Domain Service, LINQ, and custom validation – Part II</title><content type='html'>&lt;p&gt;This is one entry in a series of blog entries:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a title="Create CRUD UI using ASP.NET 4.0, FormView, Dynamic Data, DomainDataSource, Entity Framework, WC" href="http://justgeeks.blogspot.com/2011/04/create-crud-ui-using-aspnet-40-formview.html"&gt;Create CRUD UI using ASP.NET 4.0, FormView, Dynamic Data, DomainDataSource, Entity Framework, WCF Domain Service, LINQ, and custom validation - Part I&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a title="Create CRUD UI using ASP.NET 4.0, FormView, Dynamic Data, DomainDataSource, Entity Framework, WC" href="http://justgeeks.blogspot.com/2011/04/create-crud-ui-using-aspnet-40-formview_29.html"&gt;Create CRUD UI using ASP.NET 4.0, FormView, Dynamic Data, DomainDataSource, Entity Framework, WCF Domain Service, LINQ, and custom validation - Part II&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a title="Why aren’t my ForeignKeys being loaded on my Custom Dynamic Data page-" href="http://justgeeks.blogspot.com/2011/05/why-arent-my-foreignkeys-being-loaded.html"&gt;Why aren’t my ForeignKeys being loaded on my Custom Dynamic Data page?&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;Adding Labels based on MetaData from Model&lt;/h2&gt;  &lt;p&gt;In Part I we did some pretty neat stuff with Dynamic Data. In this blog entry I will show how to have your labels be set to what is set in the MetaData.&lt;/p&gt;  &lt;p&gt;Let’s do some additional clean up here. Let’s remove the ProductCategoryID and ProductModelID fields since they will never be used.&lt;/p&gt;  &lt;p&gt;Next we need to replace static text labels with a Label control so that we can set it via code. For example, replace ProductID with &lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;&amp;lt;asp:Label ID=&amp;quot;lblProductID&amp;quot; runat=&amp;quot;server&amp;quot; AssociatedControlID=&amp;quot;ProductIDDynamicControl&amp;quot;&amp;#160; OnLoad=&amp;quot;LoadLabelForDynamicControl&amp;quot;&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;I recommend a consistent naming convention to make remembering control ids. Once you have replaced one template such as the &lt;strong&gt;EditItemTemplate&lt;/strong&gt; you can copy it to the &lt;strong&gt;InsertItemTemplate&lt;/strong&gt; and the &lt;strong&gt;ItemTemplate&lt;/strong&gt;, but be sure to change the Mode property to &lt;strong&gt;Insert&lt;/strong&gt; and &lt;strong&gt;ReadOnly&lt;/strong&gt; respectively.&lt;/p&gt;  &lt;p&gt;Since we will have to get the metadata for each column on the &lt;strong&gt;FromView&lt;/strong&gt; we will create a method that does this for us. Below is that method. &lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;/// &amp;lt;summary&amp;gt;      &lt;br /&gt;/// Assuming you have a Label and DynamicControl (with the AssoicatedControlID on the label control set to the DynamicControl)       &lt;br /&gt;/// on your FormView it will set the text of the label control to the DisplayName which is from the MetaColumn for the column       &lt;br /&gt;/// used by the DynamicControl.       &lt;br /&gt;/// &amp;lt;/summary&amp;gt;       &lt;br /&gt;/// &amp;lt;param name=&amp;quot;labelControl&amp;quot;&amp;gt;The label control that will have its text changed&amp;lt;/param&amp;gt;       &lt;br /&gt;private void SetLabelBasedOnMetaData(Label labelControl)       &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; string dynamicControlID = labelControl.AssociatedControlID;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if (string.IsNullOrEmpty(dynamicControlID)) throw new Exception(&amp;quot;The AssociatedControlID must be set for Label control with ID: &amp;quot; + labelControl.ID);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;&amp;#160;&amp;#160;&amp;#160; var container = labelControl.NamingContainer;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; var userControl = container.FindControl(dynamicControlID) as DynamicControl;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if (userControl == null) throw new Exception(&amp;quot;Could not find dynamic control with id: &amp;quot; + dynamicControlID);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;&amp;#160;&amp;#160;&amp;#160; labelControl.Text = userControl.Column.DisplayName;      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;This will be called from the OnLoad event for each label.&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;protected void LoadLabelForDynamicControl(object sender, EventArgs e)      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Label labelControl = sender as Label;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; SetLabelBasedOnMetaData(labelControl);       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;If you run this now you will see that there is no real difference from the user’s perspective. However, the labels are being pulled from the MetaData (the Model). Now we just need to specify the label we want to display. This is the same label that is used in generated error messages.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;To specify the labels, open the AWDomainService.metadata.cs and find the property you want to set the label for and add the following line.&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;[Display(Name=&amp;quot;Product ID&amp;quot;)]      &lt;br /&gt;public int ProductID { get; set; }       &lt;br /&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Do this for each property. Re-run and this time you will see that the labels are the values you set in the Display attribute.&lt;/p&gt;  &lt;p&gt;It is a little more work, but in the end your labels will always be in sync from screen to screen and your error messages will reflect the name as well. When you need to make a change, you just do it once in your model. It is also the same information that your scaffolded screens will use as well.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;All source for this project can be downloaded &lt;a href="https://sites.google.com/site/justgeeksextras/Home/MyDynamicDataExample-PartII.zip?attredirects=0&amp;amp;d=1" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-6343058366962380129?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/6343058366962380129/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=6343058366962380129' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/6343058366962380129'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/6343058366962380129'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/04/create-crud-ui-using-aspnet-40-formview_29.html' title='Create CRUD UI using ASP.NET 4.0, FormView, Dynamic Data, DomainDataSource, Entity Framework, WCF Domain Service, LINQ, and custom validation – Part II'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-8353652129147316660</id><published>2011-04-28T17:46:00.001-07:00</published><updated>2011-05-04T17:40:53.550-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Dynamic Data'/><category scheme='http://www.blogger.com/atom/ns#' term='RIA Services'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='ADO.NET Entity Framework'/><category scheme='http://www.blogger.com/atom/ns#' term='LINQ'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><category scheme='http://www.blogger.com/atom/ns#' term='Domain Service'/><category scheme='http://www.blogger.com/atom/ns#' term='WCF'/><title type='text'>Create CRUD UI using ASP.NET 4.0, FormView, Dynamic Data, DomainDataSource, Entity Framework, WCF Domain Service, LINQ, and custom validation – Part I</title><content type='html'>&lt;p&gt;This is one entry in a series of blog entries:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a title="Create CRUD UI using ASP.NET 4.0, FormView, Dynamic Data, DomainDataSource, Entity Framework, WC" href="http://justgeeks.blogspot.com/2011/04/create-crud-ui-using-aspnet-40-formview.html"&gt;Create CRUD UI using ASP.NET 4.0, FormView, Dynamic Data, DomainDataSource, Entity Framework, WCF Domain Service, LINQ, and custom validation - Part I&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a title="Create CRUD UI using ASP.NET 4.0, FormView, Dynamic Data, DomainDataSource, Entity Framework, WC" href="http://justgeeks.blogspot.com/2011/04/create-crud-ui-using-aspnet-40-formview_29.html"&gt;Create CRUD UI using ASP.NET 4.0, FormView, Dynamic Data, DomainDataSource, Entity Framework, WCF Domain Service, LINQ, and custom validation - Part II&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a title="Why aren’t my ForeignKeys being loaded on my Custom Dynamic Data page-" href="http://justgeeks.blogspot.com/2011/05/why-arent-my-foreignkeys-being-loaded.html"&gt;Why aren’t my ForeignKeys being loaded on my Custom Dynamic Data page?&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The title is a mouthful and thus the topic can be kind of overwhelming. With ASP.NET 4 there are so many different technology frameworks that you need to be familiar with. The problem that I have found is that most examples only use a one or two of these frameworks. In my world, I want to use them all and the examples are never as simple as the examples. In this blog entry, I will give a read world example of how to combine all these technologies. I find myself having to figure out how to do this over and over again. Hopefully, this will be of help to others.&lt;/p&gt;  &lt;p&gt;This blog entry is NOT about how to create a Dynamic Data project in VS2010 and create an admin UI or something like that. This is about creating a page from scratch that uses this technology. To better understand the different scenarios that Dynamic Data can be used in and steps on how to extend it, &lt;a href="http://msdn.microsoft.com/en-us/library/ee845452.aspx#dynamic_data_scenarios" target="_blank"&gt;see here&lt;/a&gt;.&lt;/p&gt;  &lt;h2&gt;Technology Overview&lt;/h2&gt;  &lt;p&gt;I am writing in the context of ASP.NET 4.0 and VS2010 (Visual Studio 2010). These technologies are relatively new in some cases and the api’s have changed since betas. I am only showing stuff that works in VS2010 (the final released version).&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;ASP.NET 4.0 – This is the version of ASP.NET that I am targeting. &lt;/li&gt;    &lt;li&gt;FormView – This is the control that we will be using as a basis for the CRUD UI (User Interface). &lt;/li&gt;    &lt;li&gt;Dynamic Data – This is the technology that allows you to use DynamicControl on your FormView instead of the standard ASP.NET Forms controls. BTW, you don’t have to have anything installed (not even the Dynamic Data files and templates). You get basic implementation without them, but with them you can customize and get a more full-featured set of tools. See &lt;a href="http://channel9.msdn.com/Shows/HanselminutesOn9/Hanselminutes-on-9-ASPNET-4-and-David-Ebbo-on-Dynamic-Data-for-Older-Apps" target="_blank"&gt;here&lt;/a&gt; for a GREAT video on using Dynamic Data in “old” applications that don’t have all these cool technologies. For the most up to date resources, &lt;a href="http://msdn.microsoft.com/en-us/library/cc488545.aspx" target="_blank"&gt;click here&lt;/a&gt;. &lt;/li&gt;    &lt;li&gt;Entity Framework 4.0 – The standard with VS2010 for database to object mapping. &lt;a href="http://msdn.microsoft.com/en-us/library/cc488549.aspx" target="_blank"&gt;Click here&lt;/a&gt; if you want to see how to use Dynamic Data with an ObjectDataSource and GridView. &lt;/li&gt;    &lt;li&gt;WCF Domain Service – This is your middle tier where you would put your business logic, complex validation, etc. It provides a consist way to access your perform CRUD operations on your data. Abstraction layer before the Entity Framework. &lt;/li&gt;    &lt;li&gt;LINQ – We will use LINQ to Entities in the WCF Domain Service to query database through the Entity Framework. &lt;/li&gt;    &lt;li&gt;DomainDataSource – This is a control that works much like the ObjectDataSource or LinqDataSource or EntityDataSource except that it can connect to your WCF Domain Service from ASP.NET. Please note that there is also one for Silverlight and it has the same name so when you are Googling be sure to check what the context is. &lt;a href="http://msdn.microsoft.com/en-us/library/ee807305%28v=vs.91%29.aspx" target="_blank"&gt;This&lt;/a&gt; is a good doc on using this control. &lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;Getting Started&lt;/h2&gt;  &lt;p&gt;You can select most any type of web application project in VS2010 to get started. My instructions will be for the Dynamic Data project so that I don’t have to explain how to manually move over the Dynamic Data files. If you have an existing project and need to copy over the Dynamic Data files, &lt;a href="http://msdn.microsoft.com/en-us/library/ee923692.aspx" target="_blank"&gt;click here&lt;/a&gt; for detailed instructions. Please note, I have copied some of these steps (and written others) from instructions I have read on MSDN, but have combined them together in one continuous instruction set. For example, most of the instruction are from: &lt;a title="http://msdn.microsoft.com/en-us/library/ee807305%28v=vs.91%29.aspx" href="http://msdn.microsoft.com/en-us/library/ee807305%28v=vs.91%29.aspx"&gt;here&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/cc488562.aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Open Visual Studio 2010 and create a new project of type &lt;strong&gt;ASP.NET Dynamic Data Domain Service Web Application&lt;/strong&gt;. I’m calling my project MyDynamicDataExample. &lt;/li&gt;    &lt;li&gt;Optional - Create two Directories: &lt;strong&gt;Models &lt;/strong&gt;and &lt;strong&gt;Services&lt;/strong&gt;. &lt;/li&gt;    &lt;li&gt;Optional - &lt;a href="http://msftdbprodsamples.codeplex.com/releases/view/55926" target="_blank"&gt;Download&lt;/a&gt; and install the AdventureWorksLT database if you don’t already have it. The particular database is not really that important to understand the concepts. Notice I am using the Lite version since it is a bit simpler to follow, etc. &lt;/li&gt;    &lt;li&gt;Add a &lt;strong&gt;New Item…&lt;/strong&gt; and select ADO.NET Entity Data Model. I called MyModel.edmx. We will generate from Database. Select the database you want to work with (add a new connection if it is not there). On the &lt;strong&gt;Choose Your Database Objects&lt;/strong&gt; screen, select Product and ProductCategory. Keep everything else default. &lt;/li&gt;    &lt;li&gt;You must build your project so that the next step will work. &lt;/li&gt;    &lt;li&gt;Add (to Services folder) a &lt;strong&gt;New Item… &lt;/strong&gt;and select &lt;strong&gt;Domain Service Class. &lt;/strong&gt;I called mine &lt;strong&gt;AWDomainService.cs&lt;/strong&gt;. Select the options as shown below:       &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/_n8NnKYKIakQ/TboKIDT505I/AAAAAAAAfD4/8AAO2r9guhI/s1600-h/image%5B15%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_n8NnKYKIakQ/TboKKmmSjqI/AAAAAAAAfD8/qUeBw6us83g/image_thumb%5B11%5D.png?imgmax=800" width="397" height="484" /&gt;&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Add (to Models folder) a &lt;strong&gt;New Item… &lt;/strong&gt;and select &lt;strong&gt;Web Form using Master Page&lt;/strong&gt;. Call it DDTest.aspx. Select the Site.master on the next screen. &lt;/li&gt;    &lt;li&gt;&lt;/li&gt;    &lt;li&gt;From the &lt;strong&gt;General&lt;/strong&gt; or &lt;strong&gt;Data&lt;/strong&gt; group of the &lt;strong&gt;Toolbox&lt;/strong&gt;, add a &lt;strong&gt;DomainDataSource&lt;/strong&gt; control to the page. If you have never used the DomainDataSource before you will need to add it to your toolbox. To add it to your toolbox. Click the &lt;strong&gt;Tools&lt;/strong&gt; menu, and then click &lt;strong&gt;Choose Toolbox Items&lt;/strong&gt;. In the &lt;strong&gt;Choose Toolbox Items&lt;/strong&gt; dialog box, click the &lt;strong&gt;.NET Framework Components&lt;/strong&gt; tab, select the &lt;strong&gt;DomainDataSource&lt;/strong&gt; check box, and then click &lt;strong&gt;OK&lt;/strong&gt;. &lt;/li&gt;    &lt;li&gt;Add a DomainDataSource to the page. Configure the datasource to point to GetProducts() method on the service you created. Enable Inserts, Updates and Deletes. &lt;/li&gt;    &lt;li&gt;Add a &lt;strong&gt;QueryExtender&lt;/strong&gt; to the page. Set the &lt;strong&gt;TargetControlID&lt;/strong&gt; to the id of the DomainDataSource (mine is called &lt;strong&gt;DomainDataSource1).&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;Add a &lt;strong&gt;FormView &lt;/strong&gt;(though a &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.aspx"&gt;GridView&lt;/a&gt; or &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.detailsview.aspx"&gt;DetailsView&lt;/a&gt; could also be used). Check the &lt;strong&gt;Enable Dynamic Data Support&lt;/strong&gt; checkbox. Please note it will not stay checked when you come back to it later (in some cases). Set the Data Source to the &lt;strong&gt;DomainDataSource &lt;/strong&gt;you added earlier. &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Add a &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.dynamicdata.dynamicdatamanager.aspx"&gt;DynamicDataManager&lt;/a&gt; control to the page. Chose &lt;strong&gt;Register Controls… &lt;/strong&gt;and add the &lt;strong&gt;FormView&lt;/strong&gt; as shown below.         &lt;br /&gt;&lt;a href="http://lh5.ggpht.com/_n8NnKYKIakQ/TboKOT9hw8I/AAAAAAAAfEA/LCv28wBJG2I/s1600-h/image%5B13%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_n8NnKYKIakQ/TboKQ2mOqrI/AAAAAAAAfEE/bvs7i53IL-Y/image_thumb%5B9%5D.png?imgmax=800" width="593" height="427" /&gt;&lt;/a&gt;         &lt;br /&gt;This registers the data-bound control and enables dynamic behavior for it.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Open the code-behind. Add a Page_Init method and add the following line:        &lt;br /&gt;&lt;/p&gt;      &lt;p&gt;&lt;font color="#008040"&gt;protected void Page_Init(object sender, EventArgs e)          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; FormView1.EnableDynamicData(typeof(MyDynamicDataExample.Models.Product));           &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Go to the .aspx page again and go to the &lt;strong&gt;Source &lt;/strong&gt;view. Find the QueryExtender you added earlier. Add the following line to it:         &lt;br /&gt;&lt;/p&gt;      &lt;p&gt;&amp;lt;asp:QueryExtender ID=&amp;quot;QueryExtender1&amp;quot; runat=&amp;quot;server&amp;quot; TargetControlID=&amp;quot;DomainDataSource1&amp;quot;&amp;gt;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:DynamicRouteExpression ColumnName=&amp;quot;ProductID&amp;quot; /&amp;gt;         &lt;br /&gt;&amp;lt;/asp:QueryExtender&amp;gt;         &lt;br /&gt;        &lt;br /&gt;This will allow us to pass the ID that we want to edit via the url as a query string.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Now we need to do some clean up. In each of the templates in the FormView remove the Text and Dynamic controls for: ProductCategoryReference, EntityState, and EntityKey. Also, remove the rowguid from the insert template.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Let’s test to see if this works now. You will see that you get the YSOD (Yellow Screen Of Death) when you click the Edit button and then the Update button. You will get an EntityOperationException and the last method that was called was HandleValidationErrors. This means that something in the model failed. &lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Create event handlers on the DomainDataSource for the &lt;strong&gt;Updated&lt;/strong&gt; and &lt;strong&gt;Inserted&lt;/strong&gt; events. They should look like this when you are done:         &lt;br /&gt;&lt;/p&gt;      &lt;p&gt;&lt;font color="#008040"&gt;protected void DomainDataSource1_Inserted(object sender, Microsoft.Web.UI.WebControls.DomainDataSourceStatusEventArgs e)          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if (e.ChangeSetEntry.HasError)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; foreach (var error in e.ChangeSetEntry.ValidationErrors)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; AddValidationSummaryItem(error.Message);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;      &lt;p&gt;&lt;font color="#008040"&gt;protected void DomainDataSource1_Updated(object sender, Microsoft.Web.UI.WebControls.DomainDataSourceStatusEventArgs e)          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if (e.ChangeSetEntry.HasError)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; foreach (var error in e.ChangeSetEntry.ValidationErrors)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; AddValidationSummaryItem(error.Message);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;}           &lt;br /&gt;&lt;/font&gt;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Next add this supporting method.        &lt;br /&gt;&lt;/p&gt;      &lt;p&gt;&lt;font color="#008040"&gt;public void AddValidationSummaryItem(string errorMessage)          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; var validator = new CustomValidator();           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; validator.IsValid = false;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; validator.ErrorMessage = errorMessage;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; this.Validators.Add(validator);           &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Now put a breakpoint on the Updated event handler and debug your application. Do the same test again, you’ll see there is some error about the field: ThumbnailPhoto. Note that the error does not display on the page, but it doesn’t go to the YSOD either. Like any other validation exception that is NOT column specific, we need to use the ValidationSummary control to view this error.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Drag a &lt;strong&gt;ValidationSummary &lt;/strong&gt;control to your page. Re-run and you’ll see the exception. This does give little bit of database schema information. This may be considered by some to be bad. I’ll leave that up to you. If you don’t do this then you won’t get validation exceptions that are thrown from your domain service which is how you will implement your business logic. My experience shows that nothing too serious comes out of here once you have everything wired up correctly. If you don’t like that you’ll have to come up with another solution.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Let’s quickly fix this by removing the ThumbNailPhoto field from each of the FormView templates. Re-run, and this time you won’t get any errors. We can do this because it is an optional field.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Let’s add some validation to see how to do that. Go to the AWDomainService.cs and find the UpdateProduct method. Modify it so that it looks like this:        &lt;br /&gt;&lt;/p&gt;      &lt;p&gt;       &lt;br /&gt;&lt;font color="#008040"&gt;public void UpdateProduct(Product currentProduct)          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; this.ObjectContext.Products.AttachAsModified(currentProduct, this.ChangeSet.GetOriginal(currentProduct));           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if (currentProduct.ListPrice &amp;lt; 2000)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; throw new ValidationException(&amp;quot;List Price is too low.&amp;quot;);           &lt;br /&gt;}           &lt;br /&gt;&lt;/font&gt;Re-run, change the List Price to less than 2000 and update and you’ll get the message shown in the ValidationSummary control.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;You can also use ValidationAttributes such as Required, Range, RegularExpression, etc in the Model to declaratively validate the data. To do this open your AWDomainServices.metadata.cs. Find the StandardCost property and modify it so that it looks like this:        &lt;br /&gt;&lt;/p&gt;      &lt;p&gt;&lt;font color="#008040"&gt;[Range(0, 200, ErrorMessage=&amp;quot;{0} must be between 0 and 200.&amp;quot;)]          &lt;br /&gt;public decimal StandardCost { get; set; }           &lt;br /&gt;&lt;/font&gt;        &lt;br /&gt;Re-run and and change the standard cost to something greater than 200 if it isn’t already and Update. You’ll see it says StandardCost must be between 0 and 200. Notice it filled in the name of the field for us. It is the actual property name though. &lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;To display a user-friendly version of the property name you can add Display information as shown below.        &lt;br /&gt;&lt;/p&gt;      &lt;p&gt;&lt;font color="#008040"&gt;[Display(Name=&amp;quot;Standard Cost&amp;quot;)]          &lt;br /&gt;[Range(0, 200, ErrorMessage=&amp;quot;{0} must be between 0 and 200.&amp;quot;)]           &lt;br /&gt;public decimal StandardCost { get; set; }           &lt;br /&gt;&lt;/font&gt;        &lt;br /&gt;Re-run and you’ll see the same message but with the friendly name of the property.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;To Edit a particular record such as the Product with ID = 800, just go to the same url, but with DDTest.aspx?ProductID=800. &lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;If you try to run your application without specifying the specific test page you will get an error like this “&lt;em&gt;&lt;font color="#ff0000"&gt;There are no accessible tables. Make sure that at least one data model is registered in Global.asax and scaffolding is enabled or implement custom pages&lt;/font&gt;.”           &lt;br /&gt;          &lt;br /&gt;&lt;/em&gt;To fix that you just need to go to your Global.asax.cs and uncomment the line that start with DefaultModel.RegisterContext. Change it so that it looks like this:         &lt;br /&gt;        &lt;br /&gt;&lt;font color="#008040"&gt;DefaultModel.RegisterContext(new DomainModelProvider(typeof(MyDynamicDataExample.Services.AWDomainService)), new ContextConfiguration() { ScaffoldAllTables = true});          &lt;br /&gt;          &lt;br /&gt;&lt;/font&gt;When you do this you’ll have some CRUD pages for each of the tables you included. This is separate from what we are doing here which is a custom page, but let’s fix the errors anyway. Another option would be to not have this default page and leave that line above commented. That way you won’t have all these admin page open to the world. Yes you can secure them, but they are not by default.         &lt;br /&gt;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Back on track, when you access the Default.aspx page you will get an error like this: &lt;font color="#ff0000"&gt;“&lt;/font&gt;&lt;em&gt;&lt;font color="#ff0000"&gt;The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'.&lt;/font&gt;”           &lt;br /&gt;&lt;/em&gt;        &lt;br /&gt;To fix this just go to the &lt;strong&gt;AWDomainService.cs&lt;/strong&gt; and add a sort method to the default query methods which are &lt;strong&gt;GetProducts&lt;/strong&gt; and &lt;strong&gt;GetProductCategories&lt;/strong&gt;. Just make the methods look like these:         &lt;br /&gt;        &lt;br /&gt;&lt;/p&gt;      &lt;p&gt;&lt;font color="#008040"&gt;public IQueryable&amp;lt;ProductCategory&amp;gt; GetProductCategories()          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; return this.ObjectContext.ProductCategories.OrderBy(o =&amp;gt; o.Name);           &lt;br /&gt;}           &lt;br /&gt;&lt;/font&gt;&lt;/p&gt;      &lt;p&gt;&lt;font color="#008040"&gt;public IQueryable&amp;lt;Product&amp;gt; GetProducts()          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; return this.ObjectContext.Products.OrderBy(o =&amp;gt; o.Name);           &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Re-run. This time go to the Product link. The same validation we added before is also here. This is because the validation is written at the Model, not the UI. This is AWESOME in my opinion. I love it. This is why I love Dynamic Data.&lt;/p&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;I hope this has been beneficial to all.&lt;/p&gt;  &lt;p&gt;The entire source for this example (minus the AdventureWorksLT database) can be downloaded from &lt;a href="https://sites.google.com/site/justgeeksextras/Home/MyDynamicDataExample.zip?attredirects=0&amp;amp;d=1" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-8353652129147316660?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/8353652129147316660/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=8353652129147316660' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/8353652129147316660'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/8353652129147316660'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/04/create-crud-ui-using-aspnet-40-formview.html' title='Create CRUD UI using ASP.NET 4.0, FormView, Dynamic Data, DomainDataSource, Entity Framework, WCF Domain Service, LINQ, and custom validation – Part I'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_n8NnKYKIakQ/TboKKmmSjqI/AAAAAAAAfD8/qUeBw6us83g/s72-c/image_thumb%5B11%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-493114955524594180</id><published>2011-04-26T16:05:00.001-07:00</published><updated>2011-04-26T16:05:03.148-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows Phone 7'/><category scheme='http://www.blogger.com/atom/ns#' term='CSS'/><category scheme='http://www.blogger.com/atom/ns#' term='ADO.NET Entity Framework'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='LINQ'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>AzGroups 8th Annual Scott Guthrie Event</title><content type='html'>&lt;p&gt;Things to check out: &lt;/p&gt;  &lt;h3&gt;NUGET &lt;/h3&gt;  &lt;p&gt;(pronounced NEWGET) – it is built into VS2010 (Visual Studio 2010) and makes finding, downloading, and installing libraries (open source included) into your project. It even does some configuration in the config files, etc. Pretty awesome. You can get it &lt;a href="http://nuget.codeplex.com/" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;h3&gt;elmah&lt;/h3&gt;  &lt;p&gt;It is an error logging facility that is completely pluggable that can added to a running ASP.NET web application without re-compilation or deployment. When an exception occurs it logs it, but allows you decide where to log it to such as a database, RSS, email, etc. It also records A LOT of VERY useful information for determining what happened.&amp;#160; See &lt;a href="http://code.google.com/p/elmah/" target="_blank"&gt;here&lt;/a&gt; for more details.&lt;/p&gt;  &lt;h3&gt;IIS Express&lt;/h3&gt;  &lt;p&gt;Can be used side-by-side with the built in web server (Cassini) in VS2010. It launches fast just like the web server built into VS2010, but doesn’t require you setup virtual directories, etc like you do with IIS (full version). You now get best of both worlds. It now let’s you develop using the IIS 7.x feature-set. It is now as easy to use as the web server built into VS2010. It doesn’t require admin account. You don’t have to change any code or the way you work to take advantage of it. See Scott’s blog for more &lt;a href="http://weblogs.asp.net/scottgu/archive/2010/06/28/introducing-iis-express.aspx" target="_blank"&gt;details&lt;/a&gt;.&lt;/p&gt;  &lt;h3&gt;Web Matrix&lt;/h3&gt;  &lt;p&gt;You should still continue to use Visual Studio for professional work, but Web Matrix project are great for hobby, family sites, etc. It has been totally reworked to be a task based tool. It makes publishing very easy. If the site gets more complex the project can be opened up in Visual Studio.&lt;/p&gt;  &lt;h3&gt;SQL Server Compact Edition 4&lt;/h3&gt;  &lt;p&gt;It is great for ASP.NET development. It is light weight and free. It is an embedded database (no SQL Server required) so it is in the binaries (bin directory) that you can xcopy to your server. You can use Standard SQL Server syntax so anything that supports the ADONET provider model (such as LINQ and EF) will work. You are also licensed to redistribute it. All this means you can now deploy this in a medium trust ASP.NET shared web hosting such as DiscountASP, GoDaddy, etc. This means you don’t have to pay for the SQL database. It integrates into VS2010 (coming soon). It is different from previous version because it is safe to use with multi-threaded environments (such as ASP.NET). and no longer blocked from being used with ASP.NET. The catch is that it is for light-usage production (4GB or less for datafile) usage scenarios and it does NOT support stored procedures. For high-volume usage usage, you’ll probably want to use SQL Server Express (which is still free), SQL Server, or SQL Azure. Also, since stored procs are not supported the ASP.NET Membership is not supported (though they will be shipping new providers so that they do). The only change to your code when you migrate is your configuration string. See Scott’s blog for more &lt;a href="http://weblogs.asp.net/scottgu/archive/2010/06/30/new-embedded-database-support-with-asp-net.aspx" target="_blank"&gt;details&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Portable Library Project&lt;/h3&gt;  &lt;p&gt;It is a special kind of project in VS2010 that only allows code that will work on particular targets. In particular, the targets are Silverlight and Silverlight for Window Phone 7. Intellisense only lets you see Intellisense on methods, properties, classes, namespaces, etc that are compatible with both. The most I could find on it was &lt;a href="http://www.theregister.co.uk/2010/10/29/portable_library_project_silverlight_windows_phone/" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;h3&gt;Silverlight 5&lt;/h3&gt;  &lt;p&gt;Great stuff coming with Silverlight 5. Better DataBinding support for MVVM. Improved Printing and Text. Finally there will be a 64-Bit version of Silverlight. 3D Modeling that use Hardware acceleration. 3D and 2D can be used together. Breakpoints on XAML Bindings.&lt;/p&gt;  &lt;h3&gt;MVC 3&lt;/h3&gt;  &lt;p&gt;I am really impressed with MVC3. I am very tempted to try a project with MVC3. It takes advantage of HMTL 5 including Data validation, round corners, etc. &lt;/p&gt;  &lt;h3&gt;MVC Basics&lt;/h3&gt;  &lt;p&gt;The basic idea is that a url is mapped to a controller and method on that controller. That method makes calls to the model where most of the business logic resides, and then typically returns a view which is responsible for rendering the response (page). It maps url to action methods on controller class. In general the best practice with MVC is to have skinny controllers and fat models. Default method is called Index() and is called when no action is specified. Can pass entities as parameters to methods; just need to map them. Default parameters can be used as well. (i.e. int num = 5). ASP.NET MVC forces separation, while ASP.NET Forms does not.&lt;/p&gt;  &lt;h3&gt;Routing&lt;/h3&gt;  &lt;p&gt;When determining which rule matches it starts with the one that was added first. It then proceeds down the list until one matches. Routing is used to map urls to controllers and actions, but it is also used to generate urls in the application.&lt;/p&gt;  &lt;h3&gt;Glimpse&lt;/h3&gt;  &lt;p&gt;It is a an open source tool that allows you to diagnose what is happening on the server, but from the client. It is very useful when trying to figure out what happened once your request made it to the server. For example, what route was executed. It is basically Fiddler for the server.&lt;/p&gt;  &lt;p&gt;For more information see &lt;a href="http://www.getglimpse.com/" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;h3&gt;Razor&lt;/h3&gt;  &lt;p&gt;It is a View Engine for MVC. For more &lt;a href="http://weblogs.asp.net/scottgu/archive/2010/10/22/asp-net-mvc-3-layouts.aspx" target="_blank"&gt;info&lt;/a&gt; see ScottGu’s blog. Razor files are .cshtml. Tags start with @ and it automatically figures out where code ends and content begins. Content and code can be intermingled. A layout page is basically like a master page in ASP.NET Forms. You can use traditional parameters or Named parameters. Use Custom helpers for custom rendering; refactoring in a way.&lt;/p&gt;  &lt;h3&gt;MVCScaffolding package&lt;/h3&gt;  &lt;p&gt;It is a code generator for MVC; a smart one at that. Highly recommended so you don’t have to write so much code to do CRUD UIs. Use &lt;a href="http://nuget.codeplex.com/" target="_blank"&gt;NuGet&lt;/a&gt; Package Manager to get and install it.&lt;/p&gt;  &lt;h3&gt;Entity Framework 4.1&lt;/h3&gt;  &lt;p&gt;Great code first support. You can use POCO objects, make changes and the database just updates. It is so cool. This behavior is optional, but very nice. You can setup database initialization code to populate some basic data when the database is dropped.&lt;/p&gt;  &lt;h3&gt;Modernizr&lt;/h3&gt;  &lt;p&gt;A great tool that allows you to take advantage of HTML 5 when it is available and downgrade when it is not. An example of this is round corners. Very nice tool that can be used in most any ASP.NET project. &lt;a title="http://www.modernizr.com/" href="http://www.modernizr.com/"&gt;http://www.modernizr.com/&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;Windows Phone 7&lt;/h3&gt;  &lt;p&gt;Later this year there will be a new release called Mango. It is a very exciting release as it will bring the Windows Phone 7 much closer to the competition as far as its offering. To get started with Windows Phone 7 development go &lt;a href="http://create.msdn.com" target="_blank"&gt;here&lt;/a&gt;. Everything that is developed for Windows 7 Phone falls into two categories: Silverlight or XNA. XNA is for games (also used for XBOX), and Silverlight is for everything else. You can import some XNA libraries (such as audio) into Silverlight. Tombstoning is basically storing state to appear like the application never quit when in fact it did. It basically works by providing a state bag that most anything can be written/read to when different events such as (navigate to and from are called). It works much like Viewstate does in ASP.NET except it is not automatic. So more specifically it works like adding and retrieving stuff to/from viewstate in ASP.NET. The cost is $99 per year to put your application (or as many as you want except not more than 15 free ones) in the Marketplace. You can register to developer unlock your Windows Phone 7. Visual Studio 2010 comes with an emulator, but the one that will be in the mango release is sooo much better because it simulates things like sensors. The talk was given by Jeff Wilcox.&lt;/p&gt;  &lt;h3&gt;Tips on Windows Phone 7 development&lt;/h3&gt;  &lt;p&gt;Change splashscreen (an image) to all black if you app launches immediately. That way it is perceived as faster and cleaner. If your app takes a few seconds to load then put in a custom splashscreen (change the image) to give a more professional look. Add scrollviewer or list so that scrolling will always be available if something doesn’t fit on the screen. Use the metro look and feel styles, don’t hard code styles. If things don’t align as expected, then use 12px margins. Promote your app by creating a site for it. Prompt a user for review of your app after you think they have used it for a while. Statistically most apps are only used once and never used again. Use &lt;a href="http://wmpoweruser.com/microsoft-building-dr-watson-into-windows-phone-7-also/" target="_blank"&gt;Watson&lt;/a&gt; to collect crash information, bugs, etc. Use Google Analytics to track page navigation within your app. Keep your main dll as small as possible since the entire thing is checked before loading into memory. Delay load pages / dlls on an as needed basis to help accomplish this. This also helps with startup times. Use a tombstoning helper. Use caching whenever possible.&lt;/p&gt;  &lt;h3&gt;Windows Azure – by Scott Guthrie and Mark Russinovich&lt;/h3&gt;  &lt;p&gt;Windows Azure is a great technology that needs some work with regards to deployment speed, and in general ease of use, but it is extremely well architected for scaling your application in a very elastic way. It allows you to worry about your app and not the infrastructure it is running it. It is Microsofts offering of cloud computing. The idea is that if you need 100 servers for an event you have them. Then after the event you don’t need them. With traditional models you would have to have servers ready to go at all times and pay for that much power. Since Microsoft has a giant server farm called Windows Azure and a middle tier between you and the server OS you only pay for what you use for the length of time you use it. Everything is continually monitored for 99.? uptime. &lt;/p&gt;  &lt;p&gt;Mark went into all the details or the architecture. He convinced me it is very complex and robust, but not so fun to listen to a discussion about it. way too much details for my interest level. However, here as some of the things I found interesting. SQL is actually much slower than the way Windows Azure does it. They actually have everything as read only. Once it is read the objects are de-serialized and used. If they need to update, they are written back to the cloud as serialized objects. This takes only a trillionth of a second instead thousandths of a second that SQL takes. This allows them to scale fast. Their belief is that in the next 10 years or so this will scenario will be common more so than the relational database. Currently options in Azure are SQL, Blobs, and Queries. I believe SQL Azure is part of Windows Azure. &lt;/p&gt;  &lt;p&gt;Some Barriers / solutions to get over before cloud computing will be accepted are: Trust of proprietary data being outsourced; loss of control; confidence (ISO and other certifications will help); Private clouds may be an alternative; license to run in own data center may help also.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-493114955524594180?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/493114955524594180/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=493114955524594180' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/493114955524594180'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/493114955524594180'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/04/azgroups-8th-annual-scott-guthrie-event.html' title='AzGroups 8th Annual Scott Guthrie Event'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-7911284982753161389</id><published>2011-04-23T14:59:00.001-07:00</published><updated>2011-04-23T14:59:49.707-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows Phone 7'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Zune software is not installed. Install the latest version of Zune software</title><content type='html'>&lt;p&gt;If you are using Visual Studio and opened an existing or created a new Windows Phone 7 project you may get the following build error.&lt;/p&gt;  &lt;h2&gt;&lt;font color="#ff0000"&gt;&lt;font style="font-weight: bold"&gt;Zune software is not installed. Install the latest version of Zune software&lt;/font&gt;&lt;/font&gt;&lt;/h2&gt;  &lt;p&gt;The reason it is complaining about the Zune software is that it is assuming that you want to deploy to a Windows Phone 7 DEVICE and NOT to the Windows Phone 7 EMULATOR. IF you are deploying to a REAL Windows Phone 7 DEVICE then you should install the Zune software. More likely, you want to test your project in the Windows Phone 7 EMULATOR that works with Visual Studio 2010. To target the Emulator, you just need to the target in your Drop Down List from Windows Phone 7 Device to Windows Phone 7 Emulator. After making the change, try debugging again and it should work much better. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-7911284982753161389?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/7911284982753161389/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=7911284982753161389' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/7911284982753161389'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/7911284982753161389'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/04/zune-software-is-not-installed-install.html' title='Zune software is not installed. Install the latest version of Zune software'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-1682416447679490437</id><published>2011-04-19T15:01:00.001-07:00</published><updated>2011-04-19T15:01:26.177-07:00</updated><title type='text'>300 blog entries now</title><content type='html'>&lt;p&gt;I can’t believe I have written 300 blog entries over the years. WOW! This is SO COOL! Given the large number of people that visit my blog I am so thrilled to be able to give back to the community.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-1682416447679490437?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/1682416447679490437/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=1682416447679490437' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1682416447679490437'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1682416447679490437'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/04/300-blog-entries-now.html' title='300 blog entries now'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-3841011764348950547</id><published>2011-04-19T14:49:00.001-07:00</published><updated>2011-04-19T14:49:49.963-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='RIA Services'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><category scheme='http://www.blogger.com/atom/ns#' term='Domain Service'/><category scheme='http://www.blogger.com/atom/ns#' term='WCF'/><title type='text'>How to change the display format of a field using MetaData</title><content type='html'>&lt;p&gt;Let’s assume you have a Domain Service class that you are access from your ASP.NET Dynamic Data application (should work for Silverlight client as well (I think)) and that you have a table called Person. The Person table has a field / property / column that is called BirthDate. By default it is displayed as a date AND time in the GridView and the Edit and Detail Forms. The way to change the display format is in the MetaData for the Person table. In particular the MetaData for the property BirthDate. The basic MetaData class is generated for you when you create the Domain Service class.&lt;/p&gt;  &lt;p&gt;The question is what Attribute do we use to communicate what we want. The answer is: &lt;a href="http://msdn.microsoft.com/en-us/library/cc679253.aspx" target="_blank"&gt;DataFormatAttribute&lt;/a&gt;. Use it like you would a string format in most other places in the .NET framework. In the example below only the date (not the time) will always be shown. &lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;[DisplayFormat(DataFormatString = &amp;quot;{0:d}&amp;quot;, ApplyFormatInEditMode=true)]       &lt;br /&gt;public DateTime PerformedOnDateTimeUtc { get; set; }&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;If we remove or set the ApplyFormatInEditMode parameter to false (as shown below) then insert and edit will still show the time, but the gridview will still only show the date (no time).&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;[DisplayFormat(DataFormatString = &amp;quot;{0:d}&amp;quot;, ApplyFormatInEditMode=false)]       &lt;br /&gt;public DateTime PerformedOnDateTimeUtc { get; set; }        &lt;br /&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;You can use custom date formats, use on different datatypes, etc.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-3841011764348950547?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/3841011764348950547/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=3841011764348950547' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/3841011764348950547'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/3841011764348950547'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/04/how-to-change-display-format-of-field.html' title='How to change the display format of a field using MetaData'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-5702943373821560474</id><published>2011-04-12T15:22:00.001-07:00</published><updated>2011-04-12T15:22:15.351-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='System Admin'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows 7'/><title type='text'>How to determine if your Windows 7 Firewall is blocking your connection</title><content type='html'>&lt;p&gt;If you are like me, you cannot turn off your Windows 7 Firewall for even a minute on your work computer. If you are lucky enough to have admin rights on your computer or you can add a rule to your firewall then you are in luck. It just so happens that you can add a rule that allows most anything to open a connection from your laptop to just about anywhere. &lt;/p&gt;  &lt;p&gt;To add a rule, go to the Start Menu | Administrative Tools | Windows Firewall with Advanced Security. Right-click the Inbound Rules on the left navigation area and then select New Rule… &lt;/p&gt;  &lt;p&gt;Next choose Custom rule. Click the next button.&lt;/p&gt;  &lt;p&gt;Leave all programs setting. Click the next button.&lt;/p&gt;  &lt;p&gt;Leave Protocol type to Any. Click the next button.&lt;/p&gt;  &lt;p&gt;Leave IP addresses as Any. Click the next button.&lt;/p&gt;  &lt;p&gt;Make sure Allow the Connection radio button is check. Click the next button.&lt;/p&gt;  &lt;p&gt;Choose all three (Domain, Private, Public). Click the next button.&lt;/p&gt;  &lt;p&gt;Give the rule something descriptive. &lt;/p&gt;  &lt;p&gt;You have now opened up your computer for potential attack (at least from inbound). I highly recommend you not keep this rule enabled. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-5702943373821560474?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/5702943373821560474/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=5702943373821560474' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/5702943373821560474'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/5702943373821560474'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/04/how-to-determine-if-your-windows-7.html' title='How to determine if your Windows 7 Firewall is blocking your connection'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-3816537713224479918</id><published>2011-04-11T15:59:00.001-07:00</published><updated>2011-04-11T15:59:22.618-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Security'/><category scheme='http://www.blogger.com/atom/ns#' term='Web Services'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><category scheme='http://www.blogger.com/atom/ns#' term='WCF'/><title type='text'>How to consume a SharePoint Web Service with WCF Client</title><content type='html'>&lt;p&gt;SharePoint Web Services are great because they can be called from any computer that can connect to SharePoint, not just the server that is running SharePoint. This is nice for installations of SharePoint like MOSS 2007 or 2010, but it is critical for SharePoint Online (BPOS) or SharePoint 360 where you will NOT have access to the server that SharePoint runs on. The problem is they are not nearly as easy to work with as just using the SharePoint object model, and they don’t expose everything through the web services. This is a real bummer! It is still a very useful alternative for situations where you cannot use the SharePoint Object Model.&lt;/p&gt;  &lt;p&gt;There are a few tricks for working with SharePoint Web Services. There are lots of ways you can access the web services. I prefer to use WCF to access the services so that I get cool syntax from &lt;a href="http://www.dotnetperls.com/xelement" target="_blank"&gt;XElement&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms479390%28v=office.12%29.aspx" target="_blank"&gt;Here&lt;/a&gt; is a list of web services that are available. Let’s use the &lt;a href="http://msdn.microsoft.com/en-us/library/webs.webs%28v=office.12%29.aspx" target="_blank"&gt;Webs&lt;/a&gt; web service. Below are the step by step (close anyway) to using the web service in Visual Studio 2010.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Create a console (for simplicity) or any other project type in Visual Studio 2010. NOTE: This can be on your laptop that is NOT running SharePoint.     &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Go to the &lt;a href="http://msdn.microsoft.com/en-us/library/ms479390%28v=office.12%29.aspx" target="_blank"&gt;docs&lt;/a&gt; for the Webs Web Service. Here you will see that the url is: http://&amp;lt;Site&amp;gt;/_vti_bin/Webs.asmx you need to replace &amp;lt;Site&amp;gt; with your hostname or dns name, etc.       &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Add a Service Reference to the above url (after you replaced &amp;lt;Site&amp;gt; with your site info). I am naming my MyWebs, but you can call it whatever you like, just make the appropriate changes to the code I show later.     &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;If you require all users to be authenticated (don’t accept anonymous users) then you will need to change the WCF bindings that were automatically created in your app.config such that it will pass security information to the web service. To do this, just search for the url of the web service. That will take you to a XML tag called endpoint. In that same XML tag you will see an attribute called WebsSoap. In this same app.config do a search for WebsSoap. This will take you to a binding tag. In that binding tag you will see a security tag. That security tag should have a mode=”None” attribute. Change mode=”None” to mode=”TransportCredentialOnly”. Then just below that you will see a transport tag, change the&lt;strong&gt; &lt;font color="#008040"&gt;clientCredentialType=”None”&lt;/font&gt;&lt;/strong&gt; to &lt;font color="#008040"&gt;&lt;strong&gt;clientCredentialType=”Ntlm”&lt;/strong&gt;&lt;/font&gt; and change the &lt;font color="#008040"&gt;&lt;strong&gt;proxyCredentialType=”None”&lt;/strong&gt;&lt;/font&gt; to &lt;font color="#008040"&gt;&lt;strong&gt;proxyCredentialType=”Ntlm”&lt;/strong&gt;&lt;/font&gt;.&amp;#160; &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;All SharePoint services are work on Site Collections or Sites (webs) so really the docs should say http://&amp;lt;Site&amp;gt;/&amp;lt;subsite&amp;gt;/_vti_bin/Webs.asmx because if you are dealing with a subsite you need to use that url. You don’t need to add a service reference for each site, you can change it in the code. Be sure to change the endpoint address line in the example below.     &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Since we are using WCF, we get XElement which gives us LINQ syntax and objects from XML. How cool is that! When determining what is available as attributes it is easiest to just look in the debugger (use the visualizer).     &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Now that we the results as objects we can do whatever we want with them.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;NOTE: You can also do this with the old Web Service client, but you don’t have XElement, LINQ support, but changing the URL is as easy as just changing the url and the Credentials property is all you need to change the credentials. You also don’t really have to worry about the WCF app.config stuff, but in the end I still like WCF.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#008040" size="2"&gt;private static void GetWebs()       &lt;br /&gt;{        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; using (var ws = new &lt;font color="#ff0000"&gt;MyWebs&lt;/font&gt;.WebsSoapClient())        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // pass the proper credentials. Comment/Uncomment the proper lines depending on your situation        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ws.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials; // use current security context        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; //ws.ClientCredentials.Windows.ClientCredential = new NetworkCredential(&amp;quot;&lt;font color="#ff0000"&gt;username&lt;/font&gt;&amp;quot;, &amp;quot;&lt;font color="#ff0000"&gt;password&lt;/font&gt;&amp;quot;, &amp;quot;&lt;font color="#ff0000"&gt;domain&lt;/font&gt;&amp;quot;); // use another Active Directory account        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; //ws.ClientCredentials.Windows.ClientCredential = new NetworkCredential(&amp;quot;&lt;font color="#ff0000"&gt;username&lt;/font&gt;&amp;quot;, &amp;quot;&lt;font color="#ff0000"&gt;password&lt;/font&gt;&amp;quot;); // use account that is used for BPOS&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#008040" size="2"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // change url to the site we want to work with        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ws.Endpoint.Address = new System.ServiceModel.EndpointAddress(&amp;quot;&lt;/font&gt;&lt;a href="http://myhost/sites/SomeSiteHere/_vti_bin/Webs.asmx&amp;quot;);"&gt;&lt;font color="#008040" size="2"&gt;&lt;font color="#ff0000"&gt;http://myhost/sites/SomeSiteHere&lt;/font&gt;/_vti_bin/Webs.asmx&amp;quot;);&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#008040" size="2"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // get all the webs at and below the specified site       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var results = ws.GetAllSubWebCollection();        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // use XElement and LINQ to get our results and create objects from the XML.        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var test = from r in results.Elements()        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; orderby r.Attribute(&amp;quot;Url&amp;quot;).Value        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; select new { Title = r.Attribute(&amp;quot;Title&amp;quot;).Value, Url = r.Attribute(&amp;quot;Url&amp;quot;).Value };&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#008040" size="2"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // the results are just objects now, so do whatever you want with them.       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; foreach (var item in test)        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; //Console.WriteLine(item.Url + &amp;quot; | &amp;quot; + item.Title);        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(item.Url);        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#008040" size="2"&gt;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-3816537713224479918?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/3816537713224479918/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=3816537713224479918' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/3816537713224479918'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/3816537713224479918'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/04/how-to-consume-sharepoint-web-service.html' title='How to consume a SharePoint Web Service with WCF Client'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-7800840366261926934</id><published>2011-04-08T17:20:00.001-07:00</published><updated>2011-04-11T10:24:00.177-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><title type='text'>Migrating MOSS to BPOS –Part II</title><content type='html'>&lt;p&gt;&lt;a href="http://www.microsoft.com/belux/techdays/2009/session.aspx?sid=linqsharep&amp;amp;tid=moss_preconf&amp;amp;engine=" target="_blank"&gt;This&lt;/a&gt; is a great video on how you can pull data from SharePoint using LINQ to SharePoint. I think for an Alpha it is quire stable from what I can tell. To better understand LINQ to SharePoint, the video below goes into how to use Web Services, the SharePoint Object Model, writing your own CAML by hand, how to write you own LINQ syntax and how LINQ works. Very good course on LINQ itself, lamdba expressions, etc.&lt;/p&gt;  &lt;p&gt;Highlights:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;CAML Builder Tool if you want to use Object Model and not hand write the CAML code &lt;/li&gt;    &lt;li&gt;Everything that can be done in the UI of SharePoint can be done using the Object Model (Sharepoint.dll) &lt;/li&gt;    &lt;li&gt;LINQ to SharePoint &lt;/li&gt;    &lt;li&gt;Intro into Extension Methods and Lamdba Expressions (shorter syntax for specifying delegate methods). &lt;/li&gt;    &lt;li&gt;How to write your own LINQ language such as LINQ to SharePoint which is really just mapping LINQ to CAML &lt;/li&gt;    &lt;li&gt;Can use LINQ to SharePoint in a SharePoint web part which uses the Object Model, but can ALSO do the same code but have it use the web services model by sending all the CAML to SharePoint at once and getting back result (using &lt;a href="http://linqtosharepoint.codeplex.com/" target="_blank"&gt;LINQ to SharePoint&lt;/a&gt;). &lt;/li&gt;    &lt;li&gt;&lt;a href="http://linqtosharepoint.codeplex.com/" target="_blank"&gt;Linq to SharePoint&lt;/a&gt; is not created by Microsoft, but is available on &lt;a href="http://linqtosharepoint.codeplex.com/" target="_blank"&gt;codeplex&lt;/a&gt;. &lt;/li&gt;    &lt;li&gt;Once LINQ to SharePoint is installed, there is a new type (template) that you can select in Visual Studio called &lt;em&gt;LINQ to SharePoint File&lt;/em&gt;. &lt;/li&gt;    &lt;li&gt;LINQ to SharePoint is nice syntax and easy to work with and it is also very fast like CAML. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;After watching this, I am excited to use it. I installed LINQ to SharePoint and I like it a lot. It is very nice. Be sure to use the &lt;a href="http://linqtosharepoint.codeplex.com/" target="_blank"&gt;newest example&lt;/a&gt;, don’t go to the samples page until you understand that SharePointDataSource is now a SharePointDataContext and the code is a little bit different. I did find out that it ONLY works on lists. It does NOT work on Shared Document Libraries, but it does work on Events and Tasks. Basically, I believe it works on anything that shows up under the List of a site. Also, from what I can tell, it only works on a particular web. This can be good and bad. &lt;/p&gt;  &lt;p&gt;In the end, this will NOT give me a list of users or anything like that because it is not a list. It also doesn’t appear to support any kind of updating of data. I think I am back to the SharePoint web services for updating or getting users or document libs, etc. I think LINQ to SharePoint is a great tool for querying list data in SharePoint.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-7800840366261926934?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/7800840366261926934/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=7800840366261926934' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/7800840366261926934'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/7800840366261926934'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/04/migrating-moss-to-bpos-part-ii.html' title='Migrating MOSS to BPOS –Part II'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-1105608391010482537</id><published>2011-04-08T17:17:00.001-07:00</published><updated>2011-04-11T16:02:27.584-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><title type='text'>Migrating MOSS to BPOS (Microsoft SharePoint Online) –Part I</title><content type='html'>&lt;p&gt;MOSS 2007 is also known as Microsoft Office SharePoint Server, and BPOS is also known as Business Productivity Online Suite, but more specifically Microsoft SharePoint Online since BPOS is actually more than just SharePoint. Every since the beginning Microsoft has never really known how to market / name SharePoint, and they still don’t IMHO, but that isn’t the point of this blog.&lt;/p&gt;  &lt;p&gt;When you start Googling around you will most likely come across Metalogix tools. The two most notable are BPOS Commander and SharePoint Migration Manager. I have tried to get pricing or a demo on both of these products and the company has been 100% non-responsive other than an automated email that says an account rep will contact me shortly. It has been a while now, and no response, so I tried again. Still no response. I expect the product is priced like Oracle… “how much money do you have to spend with us” is the answer you will get when you read between the lines. With that said, the tooling looks WONDERFUL and should make the task much simpler than many other ways.&lt;/p&gt;  &lt;p&gt;The big issues to consider are &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Mapping Users from current domain to BPOS users. &lt;/li&gt;    &lt;li&gt;Cleaning up users that are no longer with company &lt;/li&gt;    &lt;li&gt;Keeping Permissions &lt;/li&gt;    &lt;li&gt;Domain Groups and SharePoint groups &lt;/li&gt;    &lt;li&gt;User account activation since they are not active initially &lt;/li&gt;    &lt;li&gt;Hard coded Urls in things such as Wikis, Announcements, Tasks, HTML Content Areas, etc. &lt;/li&gt;    &lt;li&gt;Changing Site Hierarchy &lt;/li&gt;    &lt;li&gt;Identifying Owners of sites… Abandoned sites, SPS 2003 migrated sites so no Owner groups in some cases, etc &lt;/li&gt;    &lt;li&gt;Determining what sites are still used &lt;/li&gt;    &lt;li&gt;Converting custom Site Definitions that are basically the same as original Site Definitions to a standard Site Definition that BPOS will accept. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Given that I have not heard back from Metalogix and I don’t even know if we will have a budget for such a tool, I decided to start looking elsewhere. This brought me to the &lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyId=05E0DD12-8394-402B-8936-A07FE8AFAFFD&amp;amp;displaylang=en" target="_blank"&gt;SharePoint Web Services 3.0 SDK&lt;/a&gt; which is a Windows Help file. It is much easier to use than the &lt;a href="http://msdn.microsoft.com/en-us/library/ms472057%28v=office.12%29.aspx" target="_blank"&gt;online version&lt;/a&gt; in my opinion. Though if you want just the &lt;a href="http://msdn.microsoft.com/en-us/library/dd878586%28v=office.12%29.aspx" target="_blank"&gt;docs&lt;/a&gt; for each of the web services, it is pretty good. Though, the downloaded versions has code samples for each web service, I find that VERY useful to get started. It does a good job of getting you started. There are two section of interest. &lt;em&gt;Programming Tasks –&amp;gt; Programming Web Services for Windows SharePoint Services&lt;/em&gt; and &lt;em&gt;Reference –&amp;gt; Web Services&lt;/em&gt;.&lt;/p&gt;  &lt;p&gt;Two other good places to start are below. They do a good job of explaining what is available and how to start coding:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.codeguru.com/csharp/csharp/cs_webservices/tutorials/article.php/c8805" target="_blank"&gt;Talk to SharePoint Through Its Web Services&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.infoq.com/articles/swanson-moss-web-services" target="_blank"&gt;Getting Started With SharePoint Web Services&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;I wrote up an Example of how to use the SharePoint Web Services &lt;/strong&gt;&lt;a href="http://justgeeks.blogspot.com/2011/04/how-to-consume-sharepoint-web-service.html" target="_blank"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;In the past I used the SharePoint Object Model and .NET to develop migration scripts. I also did some direct database updates. The problem with these is that they require console (Server) access and I won’t have that with BPOS. So, the only option if I want to use the SP Object Model is to do the change before hand, then export the data to BPOS and hope for the best. &lt;/p&gt;  &lt;p&gt;Since I won’t have console access, I think it makes sense to look at the web services route. The best part about this is that I can do the development (including debugging) on my laptop instead of the SharePoint server itself. The big downside is that the web services seem to be much more complicated to use. Everything seems to be XML based and a special schema just for querying. I would much prefer working with strongly typed objects and being able to use Intellisense. &lt;/p&gt;  &lt;p&gt;One helpful thing is that InfoPath can be used. It appears dealing with the namespaces can be a bit tricky, but can be done and hopefully abstracted away. &lt;a href="http://blogs.msdn.com/b/mjeelani/archive/2005/02/26/380965.aspx" target="_blank"&gt;Here&lt;/a&gt; and &lt;a href="http://www.codeguru.com/csharp/csharp/cs_webservices/tutorials/article.php/c8805__2/Talk-to-SharePoint-Through-Its-Web-Services.htm" target="_blank"&gt;here&lt;/a&gt; are posts on how to use XPath and SharePoint Web Services. &lt;/p&gt;  &lt;p&gt;In the quest for being able to use strongly-typed objected I thought maybe someone created a LINQ to SharePoint provider. That would be great! As it turns out, someone did. It can be seen &lt;a href="http://www.google.com/url?sa=t&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCAQFjAA&amp;amp;url=http%3A%2F%2Flinqtosharepoint.codeplex.com%2F&amp;amp;rct=j&amp;amp;q=linq%20to%20sharepoint&amp;amp;ei=KYCfTZDbFI2LhQe65oWLBQ&amp;amp;usg=AFQjCNG59-ccHhZvvY6Zl6CoryEZ3X26Uw&amp;amp;sig2=_A7KdNk9LwdD23Gv9ggNDQ&amp;amp;cad=rja" target="_blank"&gt;here&lt;/a&gt;. The problem is that it is ALPHA and appears to have died quite a while ago. The good news is that SharePoint 2010 has been released and it appears that they have included the LINQ to SharePoint Provider. &lt;a href="http://msdn.microsoft.com/en-us/library/ee535491.aspx" target="_blank"&gt;Click here&lt;/a&gt; to see it. It looks similar, but I’m not sure if it is the same as the ALPHA one or not.&lt;/p&gt;  &lt;p&gt;If you are not working with lists specifically then SharePoint Web Services are a good option.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-1105608391010482537?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/1105608391010482537/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=1105608391010482537' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1105608391010482537'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1105608391010482537'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/04/migrating-moss-to-bpos-microsoft.html' title='Migrating MOSS to BPOS (Microsoft SharePoint Online) –Part I'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-4610213528420810727</id><published>2011-04-07T11:15:00.001-07:00</published><updated>2011-04-13T11:56:04.936-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Network'/><category scheme='http://www.blogger.com/atom/ns#' term='System Admin'/><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows 7'/><title type='text'>Can’t access SQL Server Cluster or non-standard port or named instance after upgrading to Windows 7</title><content type='html'>&lt;p&gt;After I migrated to Windows 7 we were not able to connect to the SQL Cluster using MS SQL Management Studio, Linqpad,Visual Studio, my apps, odbc, etc. The reason is that Windows firewall blocks non-default ports for SQL Server. &lt;/p&gt;  &lt;h2&gt;Determine if the Windows Firewall is the cause&lt;/h2&gt;  &lt;p&gt;The first thing you probably want to do is confirm that it is actually a Firewall issue. The easiest way (if you are lucky) is to just turn off the Windows Firewall. If you are not lucky enough to be able to turn off your firewall due to corporate policies then there is still hope. To help troubleshoot this, I created a rule in the Firewall that opened up all ports for all programs. &lt;a href="http://justgeeks.blogspot.com/2011/04/how-to-determine-if-your-windows-7.html" target="_blank"&gt;Click here&lt;/a&gt; to see the details of how to do this. &lt;/p&gt;  &lt;p&gt;Once you have determined that the firewall is the issue, you may want to open the port instead of opening it for individual programs or open all ports between your computer and the server you are trying to access.&lt;/p&gt;  &lt;h2&gt;Option 1: Open Firewall for server&lt;/h2&gt;  &lt;p&gt;This seems to be the easiest by far since you only have to do it once unless you change server ip addresses or ports. &lt;/p&gt;  &lt;p&gt;To add a rule, go to the Start Menu | Administrative Tools | Windows Firewall with Advanced Security. Right-click the Inbound Rules on the left navigation area and then select New Rule… &lt;/p&gt;  &lt;p&gt;Next choose Custom rule. Click the next button.&lt;/p&gt;  &lt;p&gt;Leave all programs setting. Click the next button.&lt;/p&gt;  &lt;p&gt;Leave Protocol type to Any. Click the next button.&lt;/p&gt;  &lt;p&gt;Leave local IP addresses as Any. Add ALL IP addresses that you server has to the list of remote IP Addresses. I was surprised that I needed all the ip addresses for the server (use ipconfig from the command line if you don’t know them) and not just one, so to be safe add them all. Click the next button.&lt;/p&gt;  &lt;p&gt;Make sure Allow the Connection radio button is check. Click the next button.&lt;/p&gt;  &lt;p&gt;Choose only Domain (you may need to add private if you run into issues with vpn, etc). Click the next button.&lt;/p&gt;  &lt;p&gt;Give the rule something descriptive. &lt;/p&gt;  &lt;p&gt;NOTE: A slightly more secure version of this would be to specify TCP as the Protocol instead of Any. Copy the rule and edit it such that you change TCP to UDP. Then you’ll have one rule for TCP and one for UDP. This is the method I personally chose.&lt;/p&gt;  &lt;p&gt;NOTE: You could do the same, but do it for you subnet, but that is a bit riskier from a security standpoint, though not bad on a corporate network. Just be certain to select domain (no public or private).&lt;/p&gt;  &lt;h2&gt;Option 2: Open Firewall for each program&lt;/h2&gt;  &lt;p&gt;To fix the issue, go to your Start menu | Control Panel | Windows Firewall | Allow a program or feature through Windows Firewall | Change Settings | Allow another program… &lt;/p&gt;  &lt;p&gt;Next choose your program such as MS SQL Management Studio, Linq pad, Visual Studio, odbc, etc. Be sure to click the Network location types… button and select Home Network if you connect from home (and have selected that connection to be a home connection). FYI, to create an odbc connection using a non-standard port you will need to add the C:\Windows\System32\odbcad32.exe program.&lt;/p&gt;  &lt;p&gt;Side note on MS Access: If you are trying to have your MS Access application access a linked server that uses ODBC to connect to the SQL Server you will need to create a new ODBC Data Source, but be sure NOT to make it a System DSN. You want to select User DSN otherwise MS Access will not be able to access it. Though, I imagine if you ran MS Access as administrator you could make it work that way with a System DSN.&lt;/p&gt;  &lt;p&gt;I still had trouble when running in Visual Studio 2010 when debugging (worked fine if just ran without debugging). I never did figure out how to get past this. If anyone knows, please let me know.&lt;/p&gt;  &lt;h2&gt;Option 3: Hardcode server ip address&lt;/h2&gt;  &lt;p&gt;Workaround, if you can’t change your Firewall, you need admin rights on your machine I think. If you can’t do that, then you can always access the server using the ip address and port number separated by a comma. I don’t know why it works, but it does (at least on my machine).&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Legal like warning: I am by no means a security or firewall guru. Please don’t take these as security recommendations. I simply figured out how to solve the problem while taking the security issues into consideration the best way I know how (I’m a programmer not a security expert). So, please don’t make these changes unless you understand the risks as you are messing with firewall rules that are meant to protect your computer from attack. You assume all responsibility for your changes.&lt;/em&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-4610213528420810727?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/4610213528420810727/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=4610213528420810727' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/4610213528420810727'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/4610213528420810727'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/04/cant-access-sql-server-cluster-after.html' title='Can’t access SQL Server Cluster or non-standard port or named instance after upgrading to Windows 7'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-7805462183518756806</id><published>2011-04-07T10:16:00.001-07:00</published><updated>2011-04-07T10:16:22.893-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='System Admin'/><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><category scheme='http://www.blogger.com/atom/ns#' term='MS SQL Server'/><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>Tips on How to install SQL Server 2008 R2</title><content type='html'>&lt;p&gt;First this is NOT a step by step installation. I assume you can find the setup.exe and run it. I do address some of the less obvious issues that you may encounter.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;BEFORE you run setup.exe: &lt;/strong&gt;If you have Visual Studio 2008 installed be sure that you also have Service Pack 1 installed for VS2008 (Visual Studio 2008). Otherwise, you will have to stop the SQL Server 2008 R2 installation, go install SP1 for VS2008, then run the SQL Server 2008 R2 installer again. &lt;/p&gt;  &lt;p&gt;Once you launch the setup.exe you will see the SQL Server Installation Center. Click the Installation navigation link on the left, and then select &lt;em&gt;New installation or add features to an existing installation&lt;/em&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_n8NnKYKIakQ/TZ3xTiXgxVI/AAAAAAAAfA4/m-HERhhfZRY/s1600-h/image%5B13%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_n8NnKYKIakQ/TZ3xU_MZgSI/AAAAAAAAfA8/HkjZ98_f6H4/image_thumb%5B7%5D.png?imgmax=800" width="644" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;After a number of straight-forward screens you’ll come to this screen. This is the screen were you determine what you want to install. Basically the first 5 checkboxes (the ones under &lt;em&gt;Instance Features&lt;/em&gt;) are for the server and the rest are for the most part for client, though they are “shared” so some of them are for server I assume also.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_n8NnKYKIakQ/TZ3xV_98b2I/AAAAAAAAfBA/awZwgKMSYWU/s1600-h/image%5B5%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_n8NnKYKIakQ/TZ3xXLtyYPI/AAAAAAAAfBI/lG1ij1Fn-kM/image_thumb%5B3%5D.png?imgmax=800" width="644" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Check the items you want. I suggest the following.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_n8NnKYKIakQ/TZ3xYHmGNpI/AAAAAAAAfBM/g5uG5bjTLVY/s1600-h/image%5B9%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_n8NnKYKIakQ/TZ3xZb9yIpI/AAAAAAAAfBU/cl_erR5h_oA/image_thumb%5B5%5D.png?imgmax=800" width="644" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;NOTE: In the installation it will create a Integration Services (service). I guess it is needed even though I am not hosting it.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-7805462183518756806?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/7805462183518756806/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=7805462183518756806' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/7805462183518756806'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/7805462183518756806'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/04/tips-on-how-to-install-sql-server-2008.html' title='Tips on How to install SQL Server 2008 R2'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_n8NnKYKIakQ/TZ3xU_MZgSI/AAAAAAAAfA8/HkjZ98_f6H4/s72-c/image_thumb%5B7%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-1151453622895710510</id><published>2011-04-06T15:40:00.001-07:00</published><updated>2011-04-06T15:40:48.841-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows 7'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Visual Studio 2010 won’t debug under Windows 7</title><content type='html'>&lt;p&gt;I found out that Visual Studio 2010 won’t let the debugger started until I run Visual Studio 2010 with Run as Administrator. I think I figured out why. Here is an account of what I was seeing and how I fixed it.&lt;/p&gt;  &lt;p&gt;I could open my C# ASP.NET web application just fine using Run (Control-F5). Then I tried to do it with Debug (F5) and I got the following message:&lt;/p&gt;  &lt;h3&gt;&lt;font color="#ff0000"&gt;&lt;font style="font-weight: bold"&gt;Unable to launch the ASP.NET Development Server.Uncaught&amp;#160; exception thrown by method called through Reflection.&lt;/font&gt;&lt;/font&gt;&lt;/h3&gt;  &lt;p&gt;I then Googled that error message. I found &lt;a href="http://www.google.com/url?sa=t&amp;amp;source=web&amp;amp;cd=2&amp;amp;ved=0CB0QFjAB&amp;amp;url=http%3A%2F%2Fdownload.microsoft.com%2Fdownload%2F8%2FC%2FE%2F8CE18AE7-CAA8-4A4C-87CF-0C3DF772322D%2FVS2010RTM.htm&amp;amp;rct=j&amp;amp;q=Unable%20to%20launch%20the%20ASP%3ENET%20Development%20Server.Uncaught%20%20exception%20thrown%20by%20method%20called%20through%20Relection.&amp;amp;ei=nuacTYXvJdOatwektIXFBw&amp;amp;usg=AFQjCNHTT-UCoQPZTypepZNJBHJTjl0Udw&amp;amp;sig2=oMXlFrbSfa-C3-9PqY0ALg&amp;amp;cad=rja" target="_blank"&gt;this link&lt;/a&gt;. I go to the section 2.4.11.2 (shown below).&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#008040"&gt;2.4.11.2 Debugger start fails if the IntelliTrace recordings directory is Read-Only &lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#008040"&gt;By default, IntelliTrace files are located in the &amp;quot;%ProgramData%\Microsoft Visual Studio\10.0\TraceDebugging\&amp;quot; directory.&amp;#160; If this directory is made read-only, or the directory is changed to a read-only location, an uncaught exception gets raised to the user.&amp;#160; &amp;quot;Error while trying to run project: Uncaught exception thrown by method called through Reflection.&amp;quot;&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#008040"&gt;To resolve this issue:&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#008040"&gt;Option 1: Modify the permissions of the directory to be writable. &lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#008040"&gt;Option 2: Change the directory where IntelliTrace recordings are stored. &lt;/font&gt;&lt;/p&gt;    &lt;ul&gt;     &lt;li&gt;&lt;font color="#008040"&gt;○ In Visual Studio, open the Options dialog box. &lt;/font&gt;&lt;/li&gt;      &lt;li&gt;&lt;font color="#008040"&gt;○ Expand the IntelliTrace item in the left pane of the dialog box. &lt;/font&gt;&lt;/li&gt;      &lt;li&gt;&lt;font color="#008040"&gt;○ Click the Advanced item under IntelliTrace. &lt;/font&gt;&lt;/li&gt;      &lt;li&gt;&lt;font color="#008040"&gt;○ Change the IntelliTrace recordings directory to one that is not read-only. &lt;/font&gt;&lt;/li&gt;      &lt;li&gt;&lt;font color="#008040"&gt;○ Click OK.&lt;/font&gt;&lt;/li&gt;   &lt;/ul&gt; &lt;/blockquote&gt;  &lt;p&gt;I tried both option 1 and Option 2. The problem is that when I tried Option 1 and went to the directory suggested, it was not there. When I tried Option 2 I got the following message where I was expecting to see some kind of useful UI: &lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;&lt;strong&gt;An error occurred loading this property page.&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Then I got the idea, what if Visual Studio 2010 needs to be run as administrator even though I am an admin under. I am knew to Windows 7, but I am quickly learning that most techie tasks require the programs to be Run As Administrator; Visual Studio is no exception to this. It seems that I am not the only one to come to this conclusion. &lt;a href="http://msdn.microsoft.com/en-us/library/ms734712.aspx" target="_blank"&gt;Here&lt;/a&gt; Microsoft suggests changing Visual Studio 2010 to run as Administrator and I have shown instructions below:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#008040"&gt;If you are running Windows Vista, you must start Visual Studio by going to the Start menu and right clicking Visual Studio 2010 and selecting &lt;strong&gt;Run as Administrator&lt;/strong&gt;. To always launch Visual Studio 2010 as an administrator you can create a short cut, right click the short cut, select properties, select the Compatibility tab, and check the &lt;strong&gt;Run this program as an administrator&lt;/strong&gt; checkbox. When you start Visual Studio 2010 with this shortcut, it will always run as administrator.&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The good news is that after to run VS2010 (Visual Studio 2010) as Administrator the proper directory structure will be created and the if you happen to run VS2010 without running it as Administrator you can now run as Debug (F5) and you can also go to the Options | IntelliTrace | Advanced and see a useful UI with no errors. &lt;/p&gt;  &lt;p&gt;I think to keep things simple I will run VS2010 as administrator at all times.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-1151453622895710510?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/1151453622895710510/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=1151453622895710510' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1151453622895710510'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1151453622895710510'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/04/visual-studio-2010-wont-debug-under.html' title='Visual Studio 2010 won’t debug under Windows 7'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-7838607746385386849</id><published>2011-03-25T16:30:00.001-07:00</published><updated>2011-06-03T19:01:59.344-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Dynamic Data'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='LINQ'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><category scheme='http://www.blogger.com/atom/ns#' term='Domain Service'/><title type='text'>Export to Excel using Dynamic Data</title><content type='html'>&lt;p&gt;If you are using Dynamic Data ASP.NET web application you are likely using the Entity Framework and a Domain Service. With these key technologies it is easy to add an “Export to Excel” link to all your List pages in your project. The best part is that once you add this, you don’t have to write it again for each table. This is a write once use for everything solution.&lt;/p&gt;  &lt;p&gt;To implement the writing of data to Excel I don’t want to use anything that requires Microsoft Excel to be installed (except by the people that are downloading the file). I chose a free solution from &lt;a href="http://www.carlosag.net" target="_blank"&gt;CarlosAg.net&lt;/a&gt; called Excel Xml Writer. &lt;a href="http://www.carlosag.net/Tools/ExcelXmlWriter/" target="_blank"&gt;Click here&lt;/a&gt; to go to the product page and download it. It is implemented using C# and is a managed solution (no COM, interops, etc). The file that is generated is a xml version of the Excel file format so it is easy to debug and tweak if needed. Best of all the installation is simple: just add a reference to the single .dll. There should be no other dependencies.&lt;/p&gt;  &lt;p&gt;I wanted to use the same column names that are in List page that I am exporting and I didn’t want to have to hard code them. I wanted them to be read from the MyDomainService.metadata.cs. If you use the DisplayAttribute to specify user friendly names, my code uses them instead of the column names. Also, not every property in the table are shown. It depends on what the MetaTable.GetScaffoldColumns() returns which is what the DefaultAutoFieldGenerator() for the List.aspx.cs page uses. &lt;/p&gt;  &lt;p&gt;To encapsulate this logic, I created a class called &lt;a href="https://sites.google.com/site/justgeeksextras/Home/PopulateExcelWorksheetForDynamicData.cs?attredirects=0&amp;amp;d=1" target="_blank"&gt;PopulateExcelWorksheetForDynamicData.cs&lt;/a&gt;.&amp;#160; To download the source for the file click the filename. I’m not going to go through all the code step by step. However, the basic idea is that the Populate() method is called. You pass it an IQueryable object and the MetaTable information. Based on that the MetaTAble.GetScaffoldColumns() is called to determine what columns should be shown. For any foreign key columns I resolve to the related (called the parent table) and display the appropriate column based on the DisplayColumnAttribute or default DisplayColumn if one is not specified via the attribute.&lt;/p&gt;  &lt;p&gt;The datatypes that are specified in the MetaTable are converted to Excel types. Special formatting such as DateTimes require a special format in order for Excel to know how to show them as dates. I make some assumptions about the format the user will want to see. This is hardcoded, but could be extended or changed. &lt;/p&gt;  &lt;p&gt;You can tweak the formatting of the file as well. There are two formats I use. See: SetCannedStyle1(), SetDefaultStyle(). I haven’t used SetCannedStyle1() in a while, but I think it should still work.&lt;/p&gt;  &lt;p&gt;That is the guts of the logic. Now it is just a matter of creating a button or a link on the List.aspx.cs page and executing code similar to the following.    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0080ff"&gt;protected void btnExportToExcel_Click(object sender, EventArgs e)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IQueryable queryResults = null;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; using (var service = new DistiPromoDomainService())       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // execute the query that was used to populate the GridView.       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var selectMethodInfo = service.GetType().GetMethod(GridDataSource.QueryName);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; queryResults = selectMethodInfo.Invoke(service, null) as IQueryable; &lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#0080ff"&gt;&amp;#160; // add in any filters that are applied via the QueryExtender as well       &lt;br /&gt;&amp;#160;&amp;#160; var queryExtenderExpressions = queryExtender.Expressions;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;font color="#0080ff"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; foreach (DataSourceExpression expr in queryExtenderExpressions)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; queryResults = expr.GetQueryable(queryResults);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0080ff"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var workbook = new Workbook();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var sheet = workbook.Worksheets.Add(&amp;quot;Sheet 1&amp;quot;);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var excel = new PopulateExcelWorksheetForDynamicData(sheet);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; excel.Populate(queryResults, table);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; PopulateExcelWorksheetForDynamicData.SetDefaultStyle(workbook);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // don't use spaces as this will cause issues. You can also try .xls, but you will get an corruption warning in IE.       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string filename = Title.Replace(&amp;quot; &amp;quot;, &amp;quot;-&amp;quot;) + &amp;quot;-Export.xml&amp;quot;;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; PopulateExcelWorksheetForDynamicData.SendToBrowserForDownload(workbook, filename, Context.Response);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&lt;/font&gt;You may want to tweak the filename. That should do it.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-7838607746385386849?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/7838607746385386849/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=7838607746385386849' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/7838607746385386849'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/7838607746385386849'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/03/export-to-excel-using-dynamic-data.html' title='Export to Excel using Dynamic Data'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-6842074092885163767</id><published>2011-03-03T14:00:00.001-07:00</published><updated>2011-03-03T14:43:23.240-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><category scheme='http://www.blogger.com/atom/ns#' term='ADO.NET Entity Framework'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><category scheme='http://www.blogger.com/atom/ns#' term='Domain Service'/><title type='text'>Automatic Auditing of Changes using Domain Service and Entity Framework</title><content type='html'>&lt;p&gt;A special thanks to Fredrik Normen for providing the basis for my code. His great article is &lt;a href="http://weblogs.asp.net/fredriknormen/archive/2010/02/27/wcf-ria-services-and-audit-historical-changes.aspx" target="_blank"&gt;here&lt;/a&gt;. For a better understanding of the basic code, please read Fredrik’s implementation first. He does a good job of walking you through his code. &lt;/p&gt;  &lt;p&gt;With that said I have changed most of his code and added logging to a database table using another Entity Framework (EF) model. You can download my updates to his code under the Source Code section.&lt;/p&gt;  &lt;p&gt;Please note that only changes made through the Domain Service will be logged. If you don’t use a Domain Service to modify all your data that you want logged this solution is probably not for you. However, if you use a Domain Service and Entity Framework this is a pretty robust solution for adding auditing to your ASP.NET web application in minutes. I am using this with my Dynamic Data web application and it works great!&lt;/p&gt;  &lt;p&gt;The code works because the Domain Service has a concept of a ChangeSet. When you save (update or insert or delete) a ChangeSet is created that basically shows what the original entities look like and what the current entities look like. This is all standard Domain Service stuff. Nothing I did. However, what I do is look at the original and current values and create EntityChangeInfo objects and PropertyChangeInfo objects. These then get written to the database where there is a record in the database for each field. This is very verbose for Inserts and for Deletes, but just write for Update. If you don’t need insert and delete auditing, you can easily comment them out.&lt;/p&gt;  &lt;p&gt;To implement my solution, here are the basic steps (from my memory) to add auditing to you application. &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Download and use the &lt;a title="https://sites.google.com/site/justgeeksextras/Home/AuditLog-Create.sql?attredirects=0&amp;amp;d=1" href="https://sites.google.com/site/justgeeksextras/Home/AuditLog-Create.sql?attredirects=0&amp;amp;d=1" target="_blank"&gt;AuditLog-Create.sql&lt;/a&gt; to create an AuditLog table in a database.&lt;/li&gt;    &lt;li&gt;Create an &lt;strong&gt;Auditing&lt;/strong&gt; directory in your &lt;strong&gt;Services&lt;/strong&gt; directory (if you have one). &lt;/li&gt;    &lt;li&gt;Download and copy the &lt;a title="https://sites.google.com/site/justgeeksextras/Home/AuditLogger.cs?attredirects=0&amp;amp;d=1" href="https://sites.google.com/site/justgeeksextras/Home/AuditLogger.cs?attredirects=0&amp;amp;d=1" target="_blank"&gt;AuditLogger.cs&lt;/a&gt;, &lt;a title="https://sites.google.com/site/justgeeksextras/Home/ChangeSetHelper.cs?attredirects=0&amp;amp;d=1" href="https://sites.google.com/site/justgeeksextras/Home/ChangeSetHelper.cs?attredirects=0&amp;amp;d=1" target="_blank"&gt;ChangeSetHelper.cs&lt;/a&gt;, &lt;a href="https://sites.google.com/site/justgeeksextras/Home/EntityChangeInfo.cs?attredirects=0&amp;amp;d=1" target="_blank"&gt;EntityChangeInfo.cs&lt;/a&gt;, &lt;a title="https://sites.google.com/site/justgeeksextras/Home/PropertyChangeInfo.cs?attredirects=0&amp;amp;d=1" href="https://sites.google.com/site/justgeeksextras/Home/PropertyChangeInfo.cs?attredirects=0&amp;amp;d=1" target="_blank"&gt;PropertyChangeInfo.cs&lt;/a&gt; to the Auditing directory you just created.&lt;/li&gt;    &lt;li&gt;In your &lt;strong&gt;Models&lt;/strong&gt; directory (if you have one) create a new &lt;em&gt;ADO.NET Entity Framework Data Model&lt;/em&gt; that points to the database where you created the AuditLog table. Call the model AuditModel. The only table you want to add to it is the AuditLog table. You don’t need a Domain Services or anything else for this. We will reference it directly.&lt;/li&gt;    &lt;li&gt;Download and copy the snippet from the &lt;a href="https://sites.google.com/site/justgeeksextras/Home/DomainService-PersistChangeSetSnippet.cs?attredirects=0&amp;amp;d=1" target="_blank"&gt;DomainService-PersistChangeSetSnippet.cs&lt;/a&gt; and paste it in your domain service file that you already should have in your project. This is the file for the domain service that you want to audit. If you don’t want INSERT or DELETE auditing you can comment out the appropriate line in this snippet.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;That is it. You should now be able to run your application, make some changes and see the changes show up in the AuditLog table.&lt;/p&gt;  &lt;p&gt;You can then execute a query something like this to see the history of a particular record in a table.&lt;/p&gt;  &lt;p&gt;select * from auditlog where EntityName = 'Activity' and EntityPKValues = '46' and operation = 'Insert' &lt;/p&gt;  &lt;p&gt;select * from auditlog where EntityName = 'Activity' and EntityPKValues = '46' and operation = 'Update' &lt;/p&gt;  &lt;p&gt;select * from auditlog where EntityName = 'Activity' and EntityPKValues = '46' and operation = 'Delete'&lt;/p&gt;  &lt;h3&gt;My Comments&lt;/h3&gt;  &lt;p&gt;You may notice that I log my times in UTC and that the date/time is the same for a given update, insert, or delete. In other words, when an update is written to the database, multiple records are created (one for each column that changes), but the CreatedDateTimeUTC field is stamped with a ONE datetime.&lt;/p&gt;  &lt;p&gt;When values are inserted, the OriginalValue column will ALWAYS blanks. When a record is deleted, the CurrentValue column will ALWAYS be blank.&lt;/p&gt;  &lt;p&gt;If you have a properties that you have added to an entity they will have an initial value and the computed value in some cases. If this is the case for you, you may want to hard code these property names the ChagneSetHelper.GetPropertiesChangeInfo method as properties to not log. Just like I have done for the EntityState property. Up to you.&lt;/p&gt;  &lt;h3&gt;Source Code&lt;/h3&gt;  &lt;p&gt;&lt;a title="https://sites.google.com/site/justgeeksextras/Home/AuditLog-Create.sql?attredirects=0&amp;amp;d=1" href="https://sites.google.com/site/justgeeksextras/Home/AuditLog-Create.sql?attredirects=0&amp;amp;d=1" target="_blank"&gt;AuditLog-Create.sql&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="https://sites.google.com/site/justgeeksextras/Home/AuditLogger.cs?attredirects=0&amp;amp;d=1" href="https://sites.google.com/site/justgeeksextras/Home/AuditLogger.cs?attredirects=0&amp;amp;d=1" target="_blank"&gt;AuditLogger.cs&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="https://sites.google.com/site/justgeeksextras/Home/ChangeSetHelper.cs?attredirects=0&amp;amp;d=1" href="https://sites.google.com/site/justgeeksextras/Home/ChangeSetHelper.cs?attredirects=0&amp;amp;d=1" target="_blank"&gt;ChangeSetHelper.cs&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="https://sites.google.com/site/justgeeksextras/Home/EntityChangeInfo.cs?attredirects=0&amp;amp;d=1" target="_blank"&gt;EntityChangeInfo.cs&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="https://sites.google.com/site/justgeeksextras/Home/PropertyChangeInfo.cs?attredirects=0&amp;amp;d=1" href="https://sites.google.com/site/justgeeksextras/Home/PropertyChangeInfo.cs?attredirects=0&amp;amp;d=1" target="_blank"&gt;PropertyChangeInfo.cs&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="https://sites.google.com/site/justgeeksextras/Home/DomainService-PersistChangeSetSnippet.cs?attredirects=0&amp;amp;d=1" target="_blank"&gt;DomainService-PersistChangeSetSnippet.cs&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-6842074092885163767?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/6842074092885163767/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=6842074092885163767' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/6842074092885163767'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/6842074092885163767'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/03/automatic-auditing-of-changes-using.html' title='Automatic Auditing of Changes using Domain Service and Entity Framework'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-1859446762069694421</id><published>2011-03-01T14:57:00.001-07:00</published><updated>2011-03-01T14:57:08.674-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='MS SQL Server'/><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>The EXECUTE permission was denied on the object 'sp_send_dbmail', database 'msdb', schema 'dbo'</title><content type='html'>&lt;p&gt;You will get this error when you try to use the msdb.dbo.sp_send_dbmail stored proc and the user that you are using does not have permissions to execute the stored proc.&lt;/p&gt;  &lt;p&gt;The user must be a member of the DatabaseMailUserRole in the msdb database. To give the user permission to do so, execute the following:&lt;/p&gt;  &lt;pre&gt;&lt;font color="#0000ff"&gt;EXEC msdb.dbo.sp_addrolemember 'DatabaseMailUserRole', 'username here'&lt;br /&gt;&lt;/font&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;NOTE: If the user has not be added to the msdb database, then you will get an error like the following:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;font color="#ff0000"&gt;Msg 15410, Level 11, State 1, Procedure sp_addrolemember, Line 75&lt;br /&gt;    &lt;br /&gt;User or role 'username here' does not exist in this database.&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;To fix this, you can execute the following &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;use msdb&lt;br /&gt;    &lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;CREATE USER [username here] FOR LOGIN [username here]&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;You can also use MS SQL Management Studio to add the user to msdb and to the DatabaseMailUserRole in one step if you like the UI. :)&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-1859446762069694421?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/1859446762069694421/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=1859446762069694421' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1859446762069694421'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1859446762069694421'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/03/execute-permission-was-denied-on-object.html' title='The EXECUTE permission was denied on the object &amp;#39;sp_send_dbmail&amp;#39;, database &amp;#39;msdb&amp;#39;, schema &amp;#39;dbo&amp;#39;'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-5474663741544805258</id><published>2011-02-25T12:26:00.001-07:00</published><updated>2011-02-25T12:26:07.300-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><category scheme='http://www.blogger.com/atom/ns#' term='Dynamic Data'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>The resource cannot be found error when using Dynamic Data.</title><content type='html'>&lt;p&gt;&lt;/p&gt;  &lt;p&gt;Have you seen the error page shown below when you are developing a ASP.NET Dynamic Data application? &lt;/p&gt;  &lt;h3&gt;Server Error in '/' Application.    &lt;hr width="100%" size="1" /&gt;&lt;/h3&gt;  &lt;h4&gt;&lt;i&gt;The resource cannot be found.&lt;/i&gt;&lt;/h4&gt;  &lt;p&gt;&lt;b&gt;Description: &lt;/b&gt;HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.&amp;#160; Please review the following URL and make sure that it is spelled correctly.     &lt;br /&gt;&lt;b&gt;Requested URL: &lt;/b&gt;/DynamicData/PageTemplates/Edit.aspx    &lt;hr width="100%" size="1" /&gt; &lt;b&gt;Version Information:&lt;/b&gt; Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1 &lt;/p&gt;  &lt;p&gt;I thought my application was broken. In the end, it had nothing to do with my application. It has everything to do with how a &lt;em&gt;ASP.NET Dynamic Data Domain Service Web Application&lt;/em&gt; is setup by default when press F5. By default the project is setup to open the &lt;em&gt;Current Page&lt;/em&gt; as the start action. I noticed that if I have the Edit.aspx page selected in my &lt;em&gt;Solution Explorer&lt;/em&gt; and then hit F5 I get the error above. Notice the url in your browser, it is something like this: &lt;/p&gt;  &lt;p&gt;&lt;em&gt;http://localhost:1440/DynamicData/PageTemplates/Edit.aspx&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;What I wanted and expected to happen was open the default page when I hit F5. The error is 100% correct. That page is not directly available since I am using Dynamic Data. &lt;/p&gt;  &lt;p&gt;If I select my project instead and hit F5 I get the default page as expected and desired. &lt;/p&gt;  &lt;p&gt;So, really all this is just because I didn’t realize what the default behavior was. The remedy is very simple. Right click on Default.aspx in the &lt;em&gt;Solution Explorer&lt;/em&gt; and select &lt;em&gt;Set as Start Page&lt;/em&gt;. This will change the Start Action to use a &lt;em&gt;Specific Page &lt;/em&gt;(the Default.aspx in this case) instead of the &lt;em&gt;Current Page&lt;/em&gt;.&lt;/p&gt;  &lt;p&gt;If you are not sure what your project is set to you can right-click on your project in &lt;em&gt;Solution Explorer&lt;/em&gt; and go to the &lt;em&gt;Web&lt;/em&gt; tab. Here you will see &lt;em&gt;Start Action.&lt;/em&gt; To have F5 always start the Default.aspx page make sure Default.aspx is in the &lt;em&gt;Specific Page &lt;/em&gt;textbox.&lt;/p&gt;  &lt;p&gt;Here is what it should look like:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_n8NnKYKIakQ/TWgCSMI0FgI/AAAAAAAAdzc/qdLNZ8cgS8s/s1600-h/image%5B7%5D.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="275" alt="image" src="http://lh6.ggpht.com/_n8NnKYKIakQ/TWgCTfF46gI/AAAAAAAAdzg/zoajjY3iAD0/image_thumb%5B5%5D.png?imgmax=800" width="565" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-5474663741544805258?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/5474663741544805258/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=5474663741544805258' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/5474663741544805258'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/5474663741544805258'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/02/resource-cannot-be-found-error-when.html' title='The resource cannot be found error when using Dynamic Data.'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_n8NnKYKIakQ/TWgCTfF46gI/AAAAAAAAdzg/zoajjY3iAD0/s72-c/image_thumb%5B5%5D.png?imgmax=800' height='72' width='72'/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-1692612062692007622</id><published>2011-02-09T15:35:00.001-07:00</published><updated>2011-02-09T15:35:11.574-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='RIA Services'/><category scheme='http://www.blogger.com/atom/ns#' term='ADO.NET Entity Framework'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Setting default values in Entity Framework when using Silverlight</title><content type='html'>&lt;p&gt;I found myself amazed at how difficult it is to set default values for a property in the Entity Framework (even version 4) when used with Silverlight. Ideally I could use the DefaultValue attribute in the metadata class for my model. The problem is that Silverlight doesn’t use it. It seems to work ok in my tests that don’t use Silverlight if I remember correctly. But that only partially helps. I explored putting the value in the constructor for the entity that has the property I want to set the default value on, but that fires every time the object is created. This means that it was created even when displaying the results of a query, which is not the event I was hoping for. I want the default value to be used when a new entity is created, but just the object instantiated. &lt;/p&gt;  &lt;p&gt;Then I ran across &lt;a href="http://forums.silverlight.net/forums/p/170134/385224.aspx" target="_blank"&gt;this post&lt;/a&gt;. It talks about creating a partial class on the client-side (Silverlight) and using the partial method called OnCreated(). The forum seems to say that you can define the OnCreated() partial method in the partial entity class that is on the server-side, but that method is not defined on the server-side that I can tell. So, the partial keyword doesn’t work in that context. The server-side object has a .shared.cs instead of just .cs extension so the file will be copied to the client-side. The problem is that the code has to work on the client and the server side. As noted before, the OnCreated method only exists on the client-side.&lt;/p&gt;  &lt;p&gt;The solution is actually quite simple. I just had to explicitly define a partial class on the client-side even though I already have one on the server-side and is shared. This allows me to leverage the OnCreated partial method on the client that will fire when the entity is created, not just instantiated, and still keep my shared partial class that is on the server and client side.&lt;/p&gt;  &lt;p&gt;I haven’t tried it, but by doing like Kyle recommends I should be able to use the DefaultValue attribute in the metadata and have it carry over to the client-side by calling the utility method that reads the DefaultValue attribute from the model when the OnCreated method is called.&lt;/p&gt;  &lt;p&gt;So, here is an example, of what I am trying to explain.&lt;/p&gt;  &lt;p&gt;In this example (to keep with the example on the forum) my entity is called Entity1&lt;/p&gt;  &lt;p&gt;In my Silverlight project, I define a file called Entity1.cs. It would contain:&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;&lt;font color="#0080ff"&gt;public partial class Entity1&lt;br /&gt;    {&lt;br /&gt;        partial void OnCreated()&lt;br /&gt;        {&lt;br /&gt;            DefaultValueUtility.InitializeDefaultValues(this);&lt;br /&gt;        }&lt;br /&gt;    }&lt;/font&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;NOTE: I could also just set the property directly instead of pulling the data from the model. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;I can, but don’t have to have a file called Entity1.shared.cs on my server-side that will can contain whatever I want it to. It will be copied to the client-side as well. Then it will be merged with the Entity1.cs and the generated Entity1 file from the model itself on the client side because they are all partial classes.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Here is the code for the DefaultValueUtility call above. You will want to put this code somewhere in your Silverlight project.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;font color="#0080ff"&gt;using System;&lt;br /&gt;using System.ComponentModel;&lt;br /&gt;using System.Globalization;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Reflection;&lt;br /&gt;&lt;br /&gt;namespace DefaultSetter&lt;br /&gt;{&lt;br /&gt;    public static class DefaultValueUtility&lt;br /&gt;    {&lt;br /&gt;        public static void InitializeDefaultValues(object entity)&lt;br /&gt;        {&lt;br /&gt;            PropertyInfo[] properties = entity.GetType().GetProperties();&lt;br /&gt;            foreach (PropertyInfo property in properties)&lt;br /&gt;            {&lt;br /&gt;                MethodInfo propertySetter = property.GetSetMethod();&lt;br /&gt;                if (propertySetter != null)&lt;br /&gt;                {&lt;br /&gt;                    DefaultValueAttribute defaultValueAttribute = (DefaultValueAttribute)&lt;br /&gt;                        property.GetCustomAttributes(typeof(DefaultValueAttribute), true).FirstOrDefault();&lt;br /&gt;&lt;br /&gt;                    if (defaultValueAttribute != null)&lt;br /&gt;                    {&lt;br /&gt;                        object defaultValue = &lt;br /&gt;                            Convert.ChangeType(defaultValueAttribute.Value, property.PropertyType, CultureInfo.InvariantCulture);&lt;br /&gt;&lt;br /&gt;                        propertySetter.Invoke(entity, new object[] { defaultValue });&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/font&gt;&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-1692612062692007622?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/1692612062692007622/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=1692612062692007622' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1692612062692007622'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1692612062692007622'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/02/setting-default-values-in-entity.html' title='Setting default values in Entity Framework when using Silverlight'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-1554838749826728484</id><published>2011-02-03T11:19:00.001-07:00</published><updated>2011-02-03T11:19:43.117-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Plug-ins'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Hints on how to start writing an Internet Explorer Add-on</title><content type='html'>&lt;p&gt;Most of the info here are for how to write a Browser Helper Object or (BHO). A BHO is a faceless piece of code that is executes when iexplore.exe (Internet Explorer) and explore.exe (Windows Explorer) launch. Yes, believe it or not by default when you add to one, you are adding to the other. I’ll tell you how to avoid that later. You can also write toolbars, etc, but I don’t really cover that here other than some of the links at the bottom of the page do.&lt;/p&gt;  &lt;p&gt;A BHO is the simplest plug-in you can write for IE because there is no UI, it is just sitting there allowing you to hook into IE’s events. The two most common are fired when a page has completed its loading (OnDocumentComplete), and also when navigating (OnBeforeNavigate2)&amp;#160; like when a user clicks the link on a page. You may also want to look at NavigateError which is called when there is an error during navigation.&lt;/p&gt;  &lt;p&gt;There is also a RegisterBHO method that gets called when you register your BHO which is just a .dll. It is called RegisterBHO, and has a similar method called UnregisterBHO that gets called when you unregister your BHO. When I say register, I am talking about the days of COM. So, you will need to use regasm to register and unregister your BHO. regasm is included with all (I think) the Visual Studio versions. However, you will need to go to the start menu and then go to the Visual Studio 2XXX item and choose something called something like: Visual Studio Tools then Visual Studio Command Prompt (2010). This will bring regasm into the execution path. The two commands you will need are:   &lt;br /&gt;    &lt;br /&gt;&lt;font color="#0080ff"&gt;regasm /codebase &amp;quot;BHOHelloWorld.dll&amp;quot;     &lt;br /&gt;      &lt;br /&gt;regasm /unregister /codebase &amp;quot;BHOHelloWorld.dll&amp;quot;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;You would use these (or similar) to install and uninstall your BHO. &lt;/p&gt;  &lt;p&gt;There is some code you will want to put in your RegisterBHO so that IE will see it and load it on startup. Basically, your code will need to get the GUID that you assigned to your BHO class using the Guid attribute, and then add a new SubKey to    &lt;br /&gt;    &lt;br /&gt;&lt;font color="#0080ff"&gt;HKLM\Software\\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects     &lt;br /&gt;&lt;/font&gt;    &lt;br /&gt;If you don’t want the BHO to be used by Windows Explorer and thus only by Internet Explorer, you need to Add a NoExplorer Key at the following path where &amp;lt;GUID&amp;gt; where &amp;lt;GUID&amp;gt; is the GUID for you BHO and also the SubKey your code should have added to the above path in the registry.&lt;/p&gt;  &lt;p&gt;&lt;font color="#0080ff"&gt;HKLM\Software\\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects\&amp;lt;GUID&amp;gt;\NoExplorer&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Set that value to the number 1. If you don’t do this before you register your BHO, you will need to re-register it so that the code will be executed when it registers or just add it manually. Regardless, you may find that after a reboot (or sooner) that Windows Explorer has loaded your BHO and won’t let you build (if you registered the .dll in your bin directory that you are building to). In that case, un-register the .dll, and logout and log back into Windows. Now you should be able to build again. You will always need to have IE closed when you are building also.&lt;/p&gt;  &lt;p&gt;I would recommend going to &lt;a href="http://www.codeproject.com/KB/cs/Attach_BHO_with_C_.aspx" target="_blank"&gt;here&lt;/a&gt; and downloading this project and opening it. Before you run it, change the RegisterBHO to what I have below.&lt;/p&gt;  &lt;blockquote&gt;   &lt;h6&gt;&lt;/h6&gt;    &lt;p&gt;&lt;font color="#0080ff"&gt;[ComRegisterFunction]       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static void RegisterBHO(Type type)        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // if the path doesn't exist then create it        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(BHOKEYNAME, true); &lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#0080ff"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (registryKey == null)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; registryKey = Registry.LocalMachine.CreateSubKey(BHOKEYNAME); &lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#0080ff"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // if the Key for this BHO doesn't exist then create it       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // NOTE: The guid comes from the Guid attribute for this class (not the one in the AssemblyInfo.cs)        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string guid = type.GUID.ToString(&amp;quot;B&amp;quot;);        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; RegistryKey ourKey = registryKey.OpenSubKey(guid); &lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#0080ff"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (ourKey == null)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ourKey = registryKey.CreateSubKey(guid); &lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#0080ff"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // We only use this BHO in iexplore.exe, not explore.exe, so tell it not to load in explore.exe with the special flag (the name should not be changed)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ourKey.SetValue(&amp;quot;NoExplorer&amp;quot;, 1); &lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#0080ff"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // clean up       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; registryKey.Close();        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ourKey.Close();        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;This will prevent Windows Explorer from loading it (assuming that is what you want as well). Register the .dll using regasm.exe and then open IE. There you have it.&lt;/p&gt;  &lt;p&gt;Remember, you can also use Visual Studios debugging facilities. You just have to set your breakpoints, build, open IE, attach to the process (VS | Debug menu | Attach to Process…| look for iexplore.exe in list and click the Attach button. Now navigate or refresh in IE. The debugger should hit your breakpoint if you put it in the BeforeNavigate2 or DocumentComplete event.&lt;/p&gt;  &lt;p&gt;If you want to find more info on this stuff I suggest searching for DWebBrowserEvents2 or BeforeNavigate2 or DocumentComplete or better yet start by checking out the links below.   &lt;br /&gt;&lt;/p&gt;  &lt;h3&gt;Useful Links&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://www.codeproject.com/KB/cs/Attach_BHO_with_C_.aspx" target="_blank"&gt;How to attach to Browser Helper Object (BHO) with C# in two minutes&lt;/a&gt;    &lt;br /&gt;This is where I started from since it is in C#, converts to VS 2010 with no errors, and is easy to follow. I built my first BHO based on this.    &lt;br /&gt;    &lt;br /&gt;&lt;a title="http://msdn.microsoft.com/en-us/library/bb776819.aspx" href="http://msdn.microsoft.com/en-us/library/bb776819.aspx" target="_blank"&gt;Creating Custom Explorer Bars, Tool Bands, and Desk Bands&lt;/a&gt;    &lt;br /&gt;Explains the different type of add-ons    &lt;br /&gt;    &lt;br /&gt;&lt;a title="http://www.enhanceie.com/ie/dev.asp" href="http://www.enhanceie.com/ie/dev.asp" target="_blank"&gt;Developing IE Add-ons&lt;/a&gt;    &lt;br /&gt;Has links to lots of useful articles, sites, etc. Links to IE Protected Mode considerations. Links to how to write Browser Helper Objects (BHO).     &lt;br /&gt;    &lt;br /&gt;&lt;a title="http://msdn.microsoft.com/en-us/library/bb250489.aspx" href="http://msdn.microsoft.com/en-us/library/bb250489.aspx" target="_blank"&gt;Building Browser Helper Objects with Visual Studio 2005&lt;/a&gt;    &lt;br /&gt;Good article that seems to apply to VS 2010 as well. Good intro.    &lt;br /&gt;    &lt;br /&gt;&lt;a href="http://www.15seconds.com/issue/040331.htm" target="_blank"&gt;15 Seconds: Build a Managed BHO and Plug into the Browser&lt;/a&gt;    &lt;br /&gt;Good tutorial on Browser Helper Objects (BHO).    &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-1554838749826728484?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/1554838749826728484/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=1554838749826728484' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1554838749826728484'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1554838749826728484'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/02/hints-on-how-to-start-writing-internet.html' title='Hints on how to start writing an Internet Explorer Add-on'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-1177937825581980617</id><published>2011-02-01T15:07:00.001-07:00</published><updated>2011-02-01T15:07:28.694-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='System Admin'/><category scheme='http://www.blogger.com/atom/ns#' term='Registry'/><title type='text'>Solution for Can’t disable/enable add-on in Internet Explorer</title><content type='html'>&lt;p&gt;If you can’t enable or disable any add-ons in Internet Explorer then it is likely that there is a group policy that is preventing you from doing it. Like most group policies they can be temporarily overwritten by modifying the registry key. You can copy and paste the text in blue into a text file and give it the .reg exension. Now when you open it, it will modify the registry for you. Below the setting is set to 0 which means that you CAN enable or disable add-ons in Internet Explorer. Set it to 1 to prevent yourself from doing it. NOTE: HKLM is for all users, however if you go to the same path, but for HKCU the change will only affect you unless there is a value in HKLM which will then override the user value (I think).&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#0000ff" size="3"&gt;Windows Registry Editor Version 5.00&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#0000ff" size="3"&gt;[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Internet Explorer\Restrictions]     &lt;br /&gt;&amp;quot;NoExtensionManagement&amp;quot;=dword:00000000&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-1177937825581980617?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/1177937825581980617/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=1177937825581980617' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1177937825581980617'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1177937825581980617'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/02/solution-for-cant-disableenable-add-on.html' title='Solution for Can’t disable/enable add-on in Internet Explorer'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-5357128406734217789</id><published>2011-01-27T11:33:00.001-07:00</published><updated>2011-01-27T11:33:45.145-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><category scheme='http://www.blogger.com/atom/ns#' term='Methodology'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Behavior Driven Development</title><content type='html'>&lt;p&gt;No this isn’t a new program from HR, it is a theoretically nice way to ensure that your requirements, documentation, test cases, and code are all in sync. The difficulty with anything like this is that you have to actually use it. &lt;/p&gt;  &lt;p&gt;Below is a link to a 30 minute video on how this can be done using a free tool that integrates with Visual Studio and NUnit.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://specflow.org/specflow/screencast.aspx"&gt;http://specflow.org/specflow/screencast.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Check it out. Remember, you can give it a try on a new module or feature for an existing application or even apply it an existing project just to test it and also document it.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-5357128406734217789?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/5357128406734217789/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=5357128406734217789' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/5357128406734217789'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/5357128406734217789'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/01/behavior-driven-development.html' title='Behavior Driven Development'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-1980425166050717506</id><published>2011-01-25T12:54:00.001-07:00</published><updated>2011-01-25T12:54:51.909-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MS SQL Server'/><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>Why is my MS SQL Database so slow now?</title><content type='html'>&lt;p&gt;&lt;/p&gt;  &lt;p&gt;If your database worked great when you developed and is now slow, here are some things to consider. If you didn’t create indexes initially, you data may have grown since you started, and need some indexes. If your data changes a lot, the database can become fragmented. Fragmentation can come at the disk level and can be remedied by something like Windows disk defragger tool. Fragmentation can also come at the database level which could mean even certain tables or partitions are fragmented.&lt;/p&gt;  &lt;h2&gt;Checking for Index Fragmentation&lt;/h2&gt;  &lt;p&gt;Use &lt;em&gt;DBCC SHOWCONTIG&lt;/em&gt; to determine how fragmented your tables are. You can use different parameters, if you just execute with no parameters it will be run for all tables in the database. I recommend using the following parameters so that it can be shown in table for all tables in the database.&lt;/p&gt;  &lt;pre&gt;&lt;font color="#0000ff"&gt;&lt;font color="#008000"&gt;DBCC SHOWCONTIG WITH TABLERESULTS;&lt;/font&gt;&lt;br /&gt;&lt;/font&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;NOTE: You will see an column called &lt;em&gt;IndexName&lt;/em&gt;, but know that this is just the name of the primary key index, not all the indexes on the table.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;In particular, the first thing to look at is the &lt;em&gt;Local Scan Fragmentation&lt;/em&gt;. This is the percent that is fragmented. For a very healthy table 0% is what you want. Secondly, look at the &lt;em&gt;Scan Density&lt;/em&gt; line. For a really healthy table you want 100% which is the ratio or &lt;em&gt;Best Count&lt;/em&gt; to &lt;em&gt;Actual Count&lt;/em&gt;. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;You should eventually move to &lt;em&gt;sys.dm_db_index_physical_stats &lt;/em&gt;instead since &lt;em&gt;DBCC SHOWCONTIG&lt;/em&gt; will be removed after SQL Server 2008. I don’t know how to get the &lt;em&gt;Scan Density&lt;/em&gt; though. So, I show both here. However, some one at Microsoft &lt;a href="http://connect.microsoft.com/SQLServer/feedback/details/331981/scan-density-not-shown-in-sys-dm-db-index-physical-stats"&gt;posted&lt;/a&gt; that you don’t need the Scan Density and should instead use the contiguous extent allocation which is provided by &lt;em&gt;sys.dm_db_index_physical_stats&lt;/em&gt;, but I don’t know which column they are referring to. Does anyone else know? I suspect it has something to do with fragment size.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;h5&gt;Evaluating Index Fragments&lt;/h5&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;A fragment is made up of physically consecutive leaf pages in the same file for an allocation unit. An index has at least one fragment. The maximum fragments an index can have are equal to the number of pages in the leaf level of the index. Larger fragments mean that less disk I/O is required to read the same number of pages. Therefore, the larger the avg_fragment_size_in_pages value, the better the range scan performance. The avg_fragment_size_in_pages and avg_fragmentation_in_percent values are inversely proportional to each other. Therefore, rebuilding or reorganizing an index should reduce the amount of fragmentation and increase the fragment size. For more info &lt;a href="http://technet.microsoft.com/en-us/library/ms188917.aspx"&gt;click here.&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;If you want to go off of just the average logical fragmentation percent and you have SQL 2005 or greater you can use the following statement which is very fast if you just want to see the fragmentation of the index on the table MyTable in this example&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;font color="#008040"&gt;SELECT a.index_id, name, avg_fragmentation_in_percent &lt;br /&gt;    &lt;br /&gt;FROM sys.dm_db_index_physical_stats (DB_ID(), OBJECT_ID(N'MyTable'), &lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; NULL, NULL, NULL) AS a &lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; JOIN sys.indexes AS b ON a.object_id = b.object_id AND a.index_id = b.index_id;&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Alternatively, if you want to see it for all the tables, you can do this one.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;font color="#008040"&gt;SELECT a.index_id, name, avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats (DB_ID(), null, &lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; NULL, NULL, NULL) AS a &lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; JOIN sys.indexes AS b ON a.object_id = b.object_id AND a.index_id = b.index_id;&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Possible Solutions&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;If you have index fragmentation you have three options noted in &lt;a href="http://msdn.microsoft.com/en-us/library/ms175008.aspx" target="_blank"&gt;docs on DBCC SHOWCONTIG&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;  &lt;li&gt;&lt;br /&gt;    &lt;h4&gt;Drop and re-create a clustered index. &lt;/h4&gt;&lt;br /&gt;Re-creating a clustered index reorganizes the data, and causes full data pages. The level of fullness can be configured by using the &lt;em&gt;FILLFACTOR&lt;/em&gt; option in &lt;em&gt;CREATE INDEX&lt;/em&gt;. The drawbacks of this method are that the index is offline during the drop or re-create cycle, and that the operation is atomic. If the index creation is interrupted, the index is not re-created. &lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;Example: &lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt;font color="#008040"&gt;CREATE CLUSTERED INDEX IX_WorkOrder_ID ON WorkOrder(ID) &lt;br /&gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; WITH (FILLFACTOR = 80, &lt;br /&gt;&lt;br /&gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; PAD_INDEX = ON, &lt;br /&gt;&lt;br /&gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DROP_EXISTING = ON)&lt;/font&gt;; &lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;or &lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt;font color="#008040"&gt;DROP INDEX&lt;/font&gt; followed by &lt;font color="#008040"&gt;CREATE INDEX &lt;br /&gt;      &lt;br /&gt;&lt;/font&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;&lt;br /&gt;    &lt;h4&gt;Reogranize / Defrag&lt;/h4&gt;&lt;br /&gt;Reorder the leaf-level pages of the index in a logical order. &lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;Use &lt;em&gt;ALTER INDEX…REORGANIZE&lt;/em&gt; to reorder the leaf-level pages of the index in a logical order. Because this operation is an online operation, the index is available when the statement is running. The operation is also interruptible without loss of completed work. The drawback of this method is that the method does not do as good a job of reorganizing the data as a clustered index drop or re-create operation. &lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;Note: You can also use &lt;font color="#008040"&gt;DBCC INDEXDEFRAG&lt;/font&gt; since it is old SQL Server 2000 equivalent. &lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;Example: &lt;font color="#008040"&gt;ALTER INDEX PK_Employee_ID ON Employee REORGANIZE; &lt;br /&gt;      &lt;br /&gt;&lt;/font&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;&lt;br /&gt;    &lt;h4&gt;Rebuild the index.&lt;/h4&gt;&lt;br /&gt;Use ALTER INDEX with REBUILD to rebuild the index. For more information, see &lt;a href="http://msdn.microsoft.com/en-us/library/ms188388.aspx"&gt;ALTER INDEX (Transact-SQL)&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;Note: You can also use &lt;font color="#008040"&gt;DBREINDEX&lt;/font&gt; since it is the old SQL Server 2000 equivalent. &lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;Example: &lt;font color="#008040"&gt;ALTER INDEX PK_Employee_ID ON.Employee REBUILD;&lt;/font&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Choosing the right solution&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The rule of thumb that &lt;a href="http://technet.microsoft.com/en-us/library/ms189858.aspx" target="_blank"&gt;Microsoft recommends&lt;/a&gt; is the following:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;table cellspacing="0" cellpadding="2" width="400" border="1"&gt;&lt;tbody&gt;&lt;br /&gt;    &lt;tr&gt;&lt;br /&gt;      &lt;td valign="top" width="200"&gt;% Logical Fragmentation&lt;/td&gt;&lt;br /&gt;&lt;br /&gt;      &lt;td valign="top" width="200"&gt;Corrective Statement&lt;/td&gt;&lt;br /&gt;    &lt;/tr&gt;&lt;br /&gt;&lt;br /&gt;    &lt;tr&gt;&lt;br /&gt;      &lt;td valign="top" width="200"&gt;&amp;lt; 5%&lt;/td&gt;&lt;br /&gt;&lt;br /&gt;      &lt;td valign="top" width="200"&gt;No action should be taken&lt;/td&gt;&lt;br /&gt;    &lt;/tr&gt;&lt;br /&gt;&lt;br /&gt;    &lt;tr&gt;&lt;br /&gt;      &lt;td valign="top" width="200"&gt;&amp;gt; 5% and &amp;lt;= 30%&lt;/td&gt;&lt;br /&gt;&lt;br /&gt;      &lt;td valign="top" width="200"&gt;ALTER INDEX REORGANIZE&lt;/td&gt;&lt;br /&gt;    &lt;/tr&gt;&lt;br /&gt;&lt;br /&gt;    &lt;tr&gt;&lt;br /&gt;      &lt;td valign="top" width="200"&gt;&amp;gt; 30%&lt;/td&gt;&lt;br /&gt;&lt;br /&gt;      &lt;td valign="top" width="200"&gt;ALTER INDEX REBUILD WITH (ONLINE = ON)*&lt;/td&gt;&lt;br /&gt;    &lt;/tr&gt;&lt;br /&gt;  &lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;* Use the ONLINE = ON to keep the index usable and data available to users. ONLINE = OFF can also be used if availability is not a concern&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Automation&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms175008.aspx" target="_blank"&gt;Example E in the docs&lt;/a&gt; has a great script for defragging any index that has more than a specified threshold of fragmentation.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The easy way is to Rebuild indexes in the Maintenance Plan for the database. Though this requires the indexes be taken offline, so if you run it weekly and load data daily, it may not be often enough. Then you may want to use the script below.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://labs.episerver.com/en/Blogs/Per/Archive/2008/7/Automatic-index-rebuild-script/"&gt;This script&lt;/a&gt; actually follows the recommendations above, except puts changes the 5% boundary to 10%. The problem with the script is that it does NOT support anything except the default schema, uses 10% instead 5%, and includes indexes that don’t have names such as when there is no primary key on the table. If you want to use the same script I use that I have modified to support these issues, click the link below.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="wlWriterEditableSmartContent" id="scid:8eb9d37f-1541-4f29-b6f4-1eea890d4876:7819bc34-296c-4666-a6f6-1b6534e91eb1" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;div class="wlWriterSmartContent" id="scid:8eb9d37f-1541-4f29-b6f4-1eea890d4876:7819bc34-296c-4666-a6f6-1b6534e91eb1" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-1980425166050717506?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/1980425166050717506/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=1980425166050717506' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1980425166050717506'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1980425166050717506'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/01/why-is-my-ms-sql-database-so-slow-now.html' title='Why is my MS SQL Database so slow now?'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-1064213656582624000</id><published>2011-01-21T09:11:00.001-07:00</published><updated>2011-01-21T09:11:30.413-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Network'/><category scheme='http://www.blogger.com/atom/ns#' term='System Admin'/><category scheme='http://www.blogger.com/atom/ns#' term='Security'/><title type='text'>FireFox supports Integrated Windows Authentication</title><content type='html'>&lt;p&gt;Most people (including me until recently) don’t know that FireFox support Integrated Windows Authentication (NTLM). The behavior that most people are accustomed to is when you go to a web site on a corporate intranet that often requires Windows Authentication using Firefox you get a prompt for your username and password and for Internet Explorer you are logged in automatically. So, the assumption that many people (me included) make is that Firefox doesn’t support Integrated Windows Authentication. Fortunately, this is a wrong assumption.&lt;/p&gt;  &lt;p&gt;Internet explorer determines what sites are ok to use Integrated Windows Authentication on by looking to see if the site is in the Intranet Zone which can be done by looking the url, etc. Well Firefox doesn’t use that criteria. Firefox instead uses a white list or in others you have to explicitly tell it which sites to trust and that will then use Integrated Windows Authentication. Since the list is empty by default every site that has Integrated Windows Authentication enabled still gets a prompt. The simple solution is to add the sites that are on your intranet that use Integrated Windows Authentication to this list. &lt;/p&gt;  &lt;h3&gt;The Easy Way&lt;/h3&gt;  &lt;p&gt;The good news is that someone created a nice and easy to use Add-on for Firefox. So you can open up Firefox and go to Tools menu | Add-ons | Get Add-ons tab and type in the search box: NTLMAuth. You will likely get one result and it is for an add-on called NTLMAuth For Firefox. Click the Add to Firfox… button, install, and restart Firefox.&lt;/p&gt;  &lt;p&gt;Open up Firefox again and go to Tools menu | NTLM-Enabled Sites &lt;/p&gt;  &lt;p&gt;You will get a screen that looks like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_n8NnKYKIakQ/TTmwFI_JF7I/AAAAAAAAdvM/G2RMO6OVHJE/s1600-h/image%5B4%5D.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="294" alt="image" src="http://lh5.ggpht.com/_n8NnKYKIakQ/TTmwHrA9S6I/AAAAAAAAdvU/4W_x6Z69hio/image_thumb%5B2%5D.png?imgmax=800" width="304" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;All you have to do is add the sites you want to have Integrated Windows Authentication enabled for. No more prompt will be shown for these sites. Please note that you do NOT want to use http:// or anything after the domain name except a colon then port number if it is not port 80.&lt;/p&gt;  &lt;p&gt;For example, you could put www.apple.com or myapp.mycompany.com:1234.&lt;/p&gt;  &lt;h3&gt;For Geeks&lt;/h3&gt;  &lt;p&gt;The truth be told you don’t need the add-on at all. You can do this with just Firefox itself. The add-on just saves you from changing some configuration items in Firefox.&lt;/p&gt;  &lt;p&gt;If you want to do it yourself, here is what you need to do.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Open FireFox&lt;/li&gt;    &lt;li&gt;Type about:config in the address bar. (Tip: Don’t let Google try to search on this item if that feature is enabled by hitting escape after you type it). Hit enter of course to go to it.&lt;/li&gt;    &lt;li&gt;If you are using FireFox 3.x or later you will be warned. Agree if you want to continue. If you have already told it to not bother you in the past you won’t get this prompt.&lt;/li&gt;    &lt;li&gt;You can look through the list or simply type &lt;em&gt;network.automatic&lt;/em&gt; in the Filter at the top of the the screen. Look for a line that is called &lt;em&gt;network.automatic-ntlm-auth.trusted-uris&lt;/em&gt;. Double-click that like to bring up the tiny little editor. It’ll look like this.      &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://lh5.ggpht.com/_n8NnKYKIakQ/TTmwJVai2mI/AAAAAAAAdvc/pCRR3HZK1JM/s1600-h/image%5B9%5D.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="245" alt="image" src="http://lh4.ggpht.com/_n8NnKYKIakQ/TTmwL1A3KJI/AAAAAAAAdvk/bqNXrNtFzqU/image_thumb%5B5%5D.png?imgmax=800" width="504" border="0" /&gt;&lt;/a&gt;&amp;#160;&lt;/li&gt;    &lt;li&gt;You can now type in your sites separated by commas. It worked for me without spaces, but I read that you can use spaces also.      &lt;br /&gt;      &lt;br /&gt;TIP: I recommend just typing them all into notepad or some text editor, then copy and paste the big line into this little textfield.&lt;/li&gt;    &lt;li&gt;Click OK and that is it.&lt;/li&gt; &lt;/ol&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-1064213656582624000?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/1064213656582624000/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=1064213656582624000' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1064213656582624000'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1064213656582624000'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/01/firefox-supports-integrated-windows.html' title='FireFox supports Integrated Windows Authentication'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_n8NnKYKIakQ/TTmwHrA9S6I/AAAAAAAAdvU/4W_x6Z69hio/s72-c/image_thumb%5B2%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-8213004867164138127</id><published>2011-01-20T11:09:00.001-07:00</published><updated>2011-01-20T11:09:09.262-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='System Admin'/><title type='text'>Figuring out what your proxy is</title><content type='html'>&lt;p&gt;If you work in corporate America chances are you are going through a proxy when you are surfing the web. Sometimes the proxy server is specified, sometimes you have a url that then determines what proxy to go to. If the server is directly specified as shown in the Proxy Server address below (the lower yellow area), then it is easy to tell. What is there is your proxy server. &lt;/p&gt;  &lt;p&gt;On the other hand, if you have a .pac file or out configuration script that is being used then it is hard to tell from here because the rules are in the .pac file. This would be specified in the first yellow area shown below. You can use FireFox or sometimes Internet Explorer to save the .pac if you go to it in the browser. It can be saved and opened in any text editor. You can’t change it, but you can at least see what it is doing. But the question I had was how do I confirm what proxy server the .pac file has directed me to? &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_n8NnKYKIakQ/TTh6MnQ9rdI/AAAAAAAAduo/0nBOm1voZGA/s1600-h/image%5B3%5D.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="484" alt="image" src="http://lh4.ggpht.com/_n8NnKYKIakQ/TTh6OUM6Q-I/AAAAAAAAduw/3qlL7FwGE_E/image_thumb%5B1%5D.png?imgmax=800" width="386" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;No matter what these settings are you can tell for sure what you proxy server you are actually connecting to by using the command line. First make sure you have Internet Explorer open and on the page in question. Open a command prompt (Start menu | Run… | cmd.exe) and then type the following:&lt;/p&gt;  &lt;p&gt;netstat –b –n –p tcp&lt;/p&gt;  &lt;p&gt;Now look for iexplore.exe. You will see something like&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_n8NnKYKIakQ/TTh6PrEtMyI/AAAAAAAAdu4/Lj2fojoIqxI/s1600-h/image%5B16%5D.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="46" alt="image" src="http://lh6.ggpht.com/_n8NnKYKIakQ/TTh6Qg3TxhI/AAAAAAAAdvA/oktw01wS4FM/image_thumb%5B10%5D.png?imgmax=800" width="644" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Notice I have highlighted the proxy server and port in yellow. &lt;/p&gt;  &lt;p&gt;If you want to know what that is from a dns name perspective, you can use nslookup to look it up.&lt;/p&gt;  &lt;p&gt;In this example, you would type:&lt;/p&gt;  &lt;p&gt;nslookup 134.27.74.36 &lt;/p&gt;  &lt;p&gt;This will return some name of the server if you are lucky.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-8213004867164138127?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/8213004867164138127/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=8213004867164138127' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/8213004867164138127'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/8213004867164138127'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/01/figuring-out-what-your-proxy-is.html' title='Figuring out what your proxy is'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_n8NnKYKIakQ/TTh6OUM6Q-I/AAAAAAAAduw/3qlL7FwGE_E/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-5219401904194600873</id><published>2011-01-18T16:25:00.001-07:00</published><updated>2011-01-18T16:26:05.227-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='MS SQL Server'/><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>How to pass a list of ids to a stored procedure and iterate over them using a cursor</title><content type='html'>&lt;p&gt;As you probably know there is no array type in T-SQL. Let’s say the end user selects some records and you want to pass the ids of each of these records to a stored procedure. You can just use Dynamic SQL to handle this, but what if you actually want to use a cursor to iterate over each one and do something for each item. There are many reasons such as calling a stored proc for each item or maybe sending mail, etc. In general I don’t like cursors because they are slow, but I think there are cases. I had one of those cases, and the number of records I needed to loop through was small so I have no problem doing so.&lt;/p&gt;  &lt;p&gt;The idea is to just pass the list of ids as comma separated values as a string as a parameter to a stored procedure. Be careful how this list is generated. You never want to leave this data unchecked for SQL Injection attacks. In particular, I recommend building an array of integers (not strings) in .NET and then converting the array to a comma separated list of ids. I got the idea from &lt;a href="http://vyaskn.tripod.com/passing_arrays_to_stored_procedures.htm" target="_blank"&gt;here&lt;/a&gt;. I also has a wealth of other techniques for simulating arrays in T-SQL.&lt;/p&gt;  &lt;p&gt;The problem you will soon run into is that you can’t use standard Cursor syntax when you use Dynamic SQL. The code below shows you how you can do so using a Cursor Variable. You can also do it using a Global Cursor. If you want to go the Global Cursor route, check out the code &lt;a href="http://www.sommarskog.se/dynamic_sql.html#cursor0" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt; The code below basically is called something like this:&lt;/p&gt;  &lt;p&gt;IterateThroughItems ‘1234,456,789’&lt;/p&gt;  &lt;p&gt;This would select three records with ids 1234, 456, 789 and then print out the ID. Instead of printing out the ID, you could print the FName, LName, sendmail, update other tables, whatever you like.&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span style="color: #008000"&gt;-- WARNING: The end user should NEVER be able to enter or submit any information that is then passed into&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;-- the @IDs parameter. If they do, SQL-injection is available for them to hijack the database.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;-- Only pass data that has been type-checked, etc. For example, I recommend using an array or list of &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;-- integers in .NET and then using string.join() to populate the value of @IDs.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;create&lt;/span&gt; &lt;span style="color: #0000ff"&gt;proc&lt;/span&gt; IterateThroughItems @IDs &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; &lt;span style="color: #0000ff"&gt;varchar&lt;/span&gt;(2000)&lt;br /&gt;&lt;span style="color: #0000ff"&gt;as&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;Declare&lt;/span&gt; @SelectStmt &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; nvarchar(3000)&lt;br /&gt;&lt;span style="color: #0000ff"&gt;Declare&lt;/span&gt; @&lt;span style="color: #0000ff"&gt;Sql&lt;/span&gt; &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; nvarchar(3200)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;Declare&lt;/span&gt; @ID &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;Declare&lt;/span&gt; @FName &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; nvarchar(50)&lt;br /&gt;&lt;span style="color: #0000ff"&gt;Declare&lt;/span&gt; @LName &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; nvarchar(100)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;-- this is a cursor variable and is needed so we can use dynamic-sql which we need to deal with the list of ids&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;Declare&lt;/span&gt; @PersonCursor &lt;span style="color: #0000ff"&gt;CURSOR&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;Set&lt;/span&gt; @SelectStmt = &lt;span style="color: #006080"&gt;'select ID, FName, LName from Person where ID in ('&lt;/span&gt; + @IDs + &lt;span style="color: #006080"&gt;') order by ID'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;Set&lt;/span&gt; @&lt;span style="color: #0000ff"&gt;Sql&lt;/span&gt; = &lt;span style="color: #006080"&gt;'Set @PersonCursor = CURSOR FAST_FORWARD FOR '&lt;/span&gt; + @SelectStmt + &lt;span style="color: #006080"&gt;'; OPEN @PersonCursor'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;exec&lt;/span&gt; sp_executesql @&lt;span style="color: #0000ff"&gt;Sql&lt;/span&gt;, N&lt;span style="color: #006080"&gt;'@PersonCursor CURSOR OUTPUT'&lt;/span&gt;, @PersonCursor &lt;span style="color: #0000ff"&gt;OUTPUT&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;FETCH&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NEXT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; @PersonCursor &lt;span style="color: #0000ff"&gt;into&lt;/span&gt; @ID, @FName, @LName&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;WHILE&lt;/span&gt; &lt;span style="color: #cc6633"&gt;@@FETCH_STATUS&lt;/span&gt; = 0&lt;br /&gt;&lt;span style="color: #0000ff"&gt;BEGIN&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;print&lt;/span&gt; &lt;span style="color: #006080"&gt;'Processing: '&lt;/span&gt; + &lt;span style="color: #0000ff"&gt;Cast&lt;/span&gt;(@ID &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; &lt;span style="color: #0000ff"&gt;varchar&lt;/span&gt;(20))&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: #0000ff"&gt;FETCH&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NEXT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; @PersonCursor &lt;span style="color: #0000ff"&gt;into&lt;/span&gt; @ID, @FName, @LName&lt;br /&gt;&lt;span style="color: #0000ff"&gt;END&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;CLOSE&lt;/span&gt; @PersonCursor&lt;br /&gt;&lt;span style="color: #0000ff"&gt;DEALLOCATE&lt;/span&gt; @PersonCursor&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-5219401904194600873?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/5219401904194600873/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=5219401904194600873' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/5219401904194600873'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/5219401904194600873'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/01/how-to-pass-list-of-ids-to-stored.html' title='How to pass a list of ids to a stored procedure and iterate over them using a cursor'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-1166499899180311750</id><published>2011-01-18T11:54:00.001-07:00</published><updated>2011-01-18T11:54:42.712-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='LINQ'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Using LINQ in a foreach loop to build a query</title><content type='html'>&lt;p&gt;&lt;/p&gt;  &lt;p&gt;I love using LINQ because it makes building up queries so easy. The exception to this is when using a foreach with a union. I suspect it is just the foreach that is causing this behavior, but for sure the behavior is consistent when using both.&lt;/p&gt;  &lt;p&gt;Let’s pretend that you have a list of people that you let the user select one or more people from. You want to pull back the person records of just the records they selected. Maybe you want to do a database round-trip to get the latest data before an edit or may you just want to filter the list in memory. In either case, this post addresses both of them since LINQ is used in both cases. The only difference may be is that instead of a List&amp;lt;People&amp;gt; you may be using an IQueryable&amp;lt;Person&amp;gt; if you are using the database. The tricky step is identical. I know because I was originally seeing the issue on the database example I had. I wrote this using just standard LINQ (to Objects) and in memory objects to make the running of this easy for you.&lt;/p&gt;  &lt;p&gt;With that said, I have created a Person class below that is meant to simulate the Person table in the database. I then populate it with three records (Person objects). I then specify that I want just the people with the ids 1 or 2. I then run the query, dump the results. This shows the issue. We only get one record back. Then I run the next query and dump the results. This time the results are correct and give us two records as expected.&lt;/p&gt;  &lt;p&gt;What is the difference in implementation you ask? There is very little different. In both cases there is a foreach loop and use the union method to build up a query. Union is similar to using an OR in the where clause of a SQL statement, but often the performance is much better. The downside is that much of the query is duplicated and makes maintenance a pain. No so with LINQ. It is very easy to do so here.&lt;/p&gt;  &lt;p&gt;The ONLY difference between what works and what doesn’t work is that I declare a LOCAL variable INSIDE the foreach loop. I then use the LOCAL variable as a parameter in the LINQ expression. I have to assume this causes it to get the value from the variable before the LINQ expression is evaluated and thus it has the value we want. Otherwise, I assume it just looks at the current (last value) of the variable declared in the foreach statement itself at the end after the foreach loop has finished executing. I don’t know exactly how it works, but that is my assumption based on what I see from the behavior of the two methods. I don’t know if I would call this a bug or not, but it is not intuitive to me and makes for it to be very easy to write buggy code if not properly tested.&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Person&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; Name {get; set;}&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; ID {get; set;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;List&amp;lt;Person&amp;gt; people = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;Person&amp;gt;();&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Main()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #008000"&gt;// simulate a database and a table called people that has 3 records&lt;/span&gt;&lt;br /&gt;    people.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Person{ Name=&lt;span style="color: #006080"&gt;&amp;quot;Brent&amp;quot;&lt;/span&gt;, ID=1});&lt;br /&gt;    people.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Person{ Name=&lt;span style="color: #006080"&gt;&amp;quot;Lance&amp;quot;&lt;/span&gt;, ID=2});&lt;br /&gt;    people.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Person{ Name=&lt;span style="color: #006080"&gt;&amp;quot;Kim&amp;quot;&lt;/span&gt;, ID=3});&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: #008000"&gt;// this could ids of the records the user selected&lt;/span&gt;&lt;br /&gt;    List&amp;lt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&amp;gt; idsToFind = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&amp;gt;();&lt;br /&gt;    idsToFind.Add(1);&lt;br /&gt;    idsToFind.Add(2);&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: #008000"&gt;// execute the query&lt;/span&gt;&lt;br /&gt;    var allPeople = GetPeopleByIDsBroken(idsToFind);&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: #008000"&gt;// output the results&lt;/span&gt;&lt;br /&gt;    allPeople.Dump();&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: #008000"&gt;// The results will be ONE record and that is Lance&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;// This might be surprising because we passed in the ids for Lance and Brent.&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: #008000"&gt;// execute the query&lt;/span&gt;&lt;br /&gt;    var allPeople2 = GetPeopleByIDsWorks(idsToFind);&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: #008000"&gt;// output the results&lt;/span&gt;&lt;br /&gt;    allPeople2.Dump();&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: #008000"&gt;// The results will be TWO record and that is Brent and Lance&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;// This is the expected result and what we wanted.&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;IEnumerable&amp;lt;Person&amp;gt; GetPeopleByIDsBroken(List&amp;lt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&amp;gt; ids)&lt;br /&gt;{&lt;br /&gt;    IEnumerable&amp;lt;Person&amp;gt; builtUpQuery = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; id &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; ids)&lt;br /&gt;    {&lt;br /&gt;         &lt;span style="color: #008000"&gt;// first time through only.&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (builtUpQuery == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;br /&gt;        {    &lt;br /&gt;            builtUpQuery = people.Where(p =&amp;gt; p.ID == id);&lt;br /&gt;        }&lt;br /&gt;            &lt;span style="color: #008000"&gt;// all subsequent times&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;            builtUpQuery = builtUpQuery.Union(people.Where(p =&amp;gt; p.ID == id));&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; builtUpQuery;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;IEnumerable&amp;lt;Person&amp;gt; GetPeopleByIDsWorks(List&amp;lt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&amp;gt; ids)&lt;br /&gt;{&lt;br /&gt;    IEnumerable&amp;lt;Person&amp;gt; builtUpQuery = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; id &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; ids)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: #008000"&gt;// We have to get a local copy of the id. &lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #008000"&gt;// Othewise, the value is not taken from the id in the foreach loop &lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #008000"&gt;// until the entire expression is evaluated&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; localCopyOfID = id;&lt;br /&gt;        &lt;br /&gt;         &lt;span style="color: #008000"&gt;// first time through only.&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (builtUpQuery == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;br /&gt;        {    &lt;br /&gt;            builtUpQuery = people.Where(p =&amp;gt; p.ID == localCopyOfID);&lt;br /&gt;        }&lt;br /&gt;            &lt;span style="color: #008000"&gt;// all subsequent times&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;            builtUpQuery = builtUpQuery.Union(people.Where(p =&amp;gt; p.ID == localCopyOfID));&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; builtUpQuery;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-1166499899180311750?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/1166499899180311750/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=1166499899180311750' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1166499899180311750'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1166499899180311750'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/01/using-linq-in-foreach-loop-to-build.html' title='Using LINQ in a foreach loop to build a query'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-4150071180657933995</id><published>2011-01-16T20:33:00.009-07:00</published><updated>2011-01-19T17:38:43.639-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Robotics'/><title type='text'>BrentBot is born today</title><content type='html'>Here is my robot - BrentBot&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_n8NnKYKIakQ/TTPFZkmC1WI/AAAAAAAAduM/5DD7yogEQs8/s1600/01162011023.JPG"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 400px; FLOAT: left; HEIGHT: 300px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5563007007843341666" border="0" alt="" src="http://2.bp.blogspot.com/_n8NnKYKIakQ/TTPFZkmC1WI/AAAAAAAAduM/5DD7yogEQs8/s400/01162011023.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://3.bp.blogspot.com/_n8NnKYKIakQ/TTPFTvlTXjI/AAAAAAAAduE/PNe-xBNf9BY/s1600/01162011022.JPG"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 400px; FLOAT: left; HEIGHT: 300px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5563006907713805874" border="0" alt="" src="http://3.bp.blogspot.com/_n8NnKYKIakQ/TTPFTvlTXjI/AAAAAAAAduE/PNe-xBNf9BY/s400/01162011022.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://2.bp.blogspot.com/_n8NnKYKIakQ/TTPFLRnHngI/AAAAAAAAdt8/5MiRVCW2CZc/s1600/01162011021.JPG"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 400px; FLOAT: left; HEIGHT: 300px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5563006762229407234" border="0" alt="" src="http://2.bp.blogspot.com/_n8NnKYKIakQ/TTPFLRnHngI/AAAAAAAAdt8/5MiRVCW2CZc/s400/01162011021.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://3.bp.blogspot.com/_n8NnKYKIakQ/TTPEnTX0E1I/AAAAAAAAdt0/01qwxDdB7eg/s1600/01162011018.JPG"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://3.bp.blogspot.com/_n8NnKYKIakQ/TTO4fkj701I/AAAAAAAAdtg/X5nO-4S0th0/s1600/01162011003.jpg"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt; &lt;/div&gt;&lt;/div&gt;&lt;div&gt;I am very excited to have created a robot from scratch. It took a lot of research to figure out how I wanted to build the robot. In the end, I followed an article in Servo magazine that walked me through it. Like most things in life, it didn't go quite as I planned. I didn't have all the parts that the article required, so a lot of them I found at Ace Hardware and later found out that Fry's Electronics had cheaper screws when I bot some other stuff there. If you have a Fry's electronics where you live, you can start there. Some Radio Shacks are supposed to have some of this stuff, but most requires it be ordered online and shipped to your home or Radio Shack for pickup. There are lots of Robot companies online. I personally like &lt;a href="http://www.robotshop.com/"&gt;RobotShop&lt;/a&gt; since it has such a wide variety of things and they at least have a branch in the US even though they are a Canadian company.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;The cost was about $100, but I didn't end up using everything, so like the article said, it is probably pretty close to $85. If you want professional results or just want to save a ton of time fabricating the deck, connecting wheels, making servo mounts, etc I highly suggest buying them. The cost was actually only around $15, but I wanted to see what I could come up with. &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;I made my deck out of nylon cutting board. It is very strong and durable and doesn't split at all (from what I can tell). The downside is that it is not as easy to work with as I had hoped. For instance, I used my Jigsaw/Scrollsaw, etc to cut it and found that even on the lowest speed it just melted the nylon and made a mess and was hard to cut. By the end, I figured out that if I just tap the trigger and then push the saw through until the blade stopped this was slow enough and kept everything cool enough that it was fairly accurrate to cut with and was managable. If I had to do it again, I probably would not use this material again, but it was free since it was an old cutting board. I did sand it down to make it smooth since there were so many knife marks on it.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;The cutting board was a bit thicker than the original design called for and the wheels that I chose were smaller that suggested I ended up changing the original design from a two decker to a one deck robot for now. This actually worked to my favor. Now, I was able to mount the servos and the batteries on the underside of the deck and still had all the room on the top side of the deck. So really I have the same amount of deck space, but with half the height and much less weight. I like my design actually.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;I chose the Arduino Uno as the brain for controlling everything. Mostly because it is open source and open hardware and it is WAY cheaper than the Parallax Stamp Kits. Personally, I don't like VB or anything that looks like VB and that is what the Stamp uses. Unless you want to pay even more the Javaline I think it is called. That is just way too expensive for me just to not write in VB like language when I have a much cheaper (and significantly more power) processor (Arduno Uno). My goal was to build a robot under $100 and I succeeded. Granted it doesn't do much because it doesn't have any sensors. I'll add those later at additional cost obviously, but they will come in time as they are needed.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;As word about Parallax and the BeoBot. If you don't want to work really hard and do this all from scratch and you want support and supported enhancements, I think the BeoBot would be great. I also think the Lego Mindstorm is a bit more pricey, but you can do so much in a short amount of time with it. If I didn't have such a strong desire to build this robot from scratch just to say that I did it all, you may want to seriously consider one of those other options. The lego solution is great because there are parts readily available and you can create so many different kinds of robots in little time. &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;Don't underestimate the time it takes to fabricate everything. Designing a robot from scatch takes a lot of time. You have to think about how wires will be run, line up holes on parts, match nuts and bolts, solder, and in general just spend time though trial and error. Don't forget the error part is great for learning, but takes time.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;I soldered the battery connectors and barrel connector for powering the Arduino. This was time consuming. I did remember how to solder thankfully. I also figured out to de-solder because I had the polarity of the barrel connector backwards. I don't know how I did that. I did figure out that the barrel connector needs the positive on the inside part and negative on the outside part. Even with that knowledge, I got confused. Oops. Oh well, in the end it gave me a chance to add more length to the plug since the first one was a bit short. Good luck de-soldering the wires from the barrel connector if you wrap them around the posts before you solder them. They will never come off without a LOT of work, though I did finally get the wires off and new ones put on.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;When cutting the servo brackets they need to fit snuggly around the servo. This is because the mounting brackets on the servos are right there close to the sides of the servos. If you leave too much space around the servo the screws that go in the mounting brackets won't have anything to screw into. This kind of defeats the purpose of the servo brackets.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;I did and you probably will also need to have two sets of power supplies. One for the Arduino and one for the servos. The reason is that the Arduino can only handle so many things plugged into it. This is especially true when it comes to the Servoes. Besides, it is good design to have separate drive system power. That way there isn't noise (electrical noise) that can make your Arduino and you cicuits act funny. Don't worry, it is actually very easy. All you do is connect the grounds together and they work great.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;Once BrentBot started to work, I quickly found out I will need at least one swithc for the power. I don't have one right now and everytime I want to test anything, I have to disconnect the main barrel connector, and plug in the usb cable. Not to mention, I usually have to disconnect the batteries for the drive system. While not a pain, these plugs will eventually wear out and they are not really cheap to replace. A switch is a much better solution and allows for faster test cycles.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;Servos are great for a simple light weight robot that is under say 3 pounds. Over that, you'll have to get the large servos or go to a motor and gearbox. In either case, always get wheels that mount directly on the servo's shaft. If you don't, you will be spending lots of time trying to figure out how to mount a wheel onto it like I did. In the end, I think it is quite straight.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;When you are writing your code to control the servos there is a library to do so. This doesn't mean you have nothing to do. You still have to write your basic functions like forward, reverse, turn left, turn right. If you don't attach and the detach for each of these functions your servos may jitter when they are idle. To prevent the jitters all just make sure you detach after each function call. This has the added benefit of saving your battery life also.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;The power for the Arduino is a single 9V battery. The drive system is powered by 4 rechargeable AA batteries. I highly recommend rechareable batteries. Otherwise, you will be spending a lot on batteries. They don't really last long.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;By all means, unless you have servos already, be sure to by the continuous rotation versions. They are the same price and will save you from trying to figure out how to take one apart and modifying it. If you need to modify it, there are article on the internet that tell you how to do it. I didn't want to bother with it. It seems silly these days when continuous ones are readily available at the same cost.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;I found that having old computer plugs, wires, etc came in handy. If you have the long header pins they fit the computer plugs perfectly because a computer is a circuit after all. I also found the wire useful for the power lines since they are pretty thin. Yes, I know you can buy wire, but it usually isn't two wires side by side which creates less mess, and in my case I had them already so they were free to me. If you don't have them, consider an old computer from a garage sale that would have stuff you can use. Goodwill is another option that can be fairly inexpensive. On the other hand, unless you find just a screaming deal, you are probably better off just buying wire and taping them together, or using zip-ties. &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;It is important that you get your polarities correct. This is particular important with your servo. if you get this wrong, you can permanently damage your servo. I think the Arduino can cope even if the polarity is reversed, but I don't really recommend it. The easy way to do this is with a battery tester or better yet a multi-meter. To see which wire is the positive one, you touch the wire to the red lead of the meter, and the other wire to the black lead of the meter. If you get a positive voltage (or if the battery tester says good) then the wire on the red lead is your positive wire. If you get a negative voltage or no ready on the battery tester then the wire on the red lead is negative. In general it is a good idea to start at a larger range on your multi-meter. Says something like 20, but starting at 2 should be good also since we are talking about small voltages here and it is know to be say 9Volts for a 9Volt battery.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;I hope this is useful to someone that is starting with robotics.&lt;br /&gt;&lt;/div&gt;&lt;div style="TEXT-ALIGN: center; CLEAR: both"&gt; &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-4150071180657933995?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/4150071180657933995/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=4150071180657933995' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/4150071180657933995'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/4150071180657933995'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2011/01/brentbot-is-born-today.html' title='BrentBot is born today'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_n8NnKYKIakQ/TTPFZkmC1WI/AAAAAAAAduM/5DD7yogEQs8/s72-c/01162011023.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-1084910275211000505</id><published>2010-11-11T10:35:00.001-07:00</published><updated>2010-11-11T10:36:16.924-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Getting Current User information in Silverlight 4</title><content type='html'>&lt;p&gt;Let’s assume for a Silverlight application. You may be wondering where to find out who the current user is. In ASP.NET there is a User property on the Page object (also other places such as the HttpContext.Current), but where is that in Silverlight 4 (not in early versions that I am aware of). The answer is the WebContext. &lt;/p&gt;  &lt;p&gt;I think the WebContext was introduced in Silverlight 4.You The WebContext is created in the constructor of the App class that is in the App.xaml.cs file. If it isn’t you may be using a different type of Silverlight 4 project than the Silverlight Business Application or Silverlight Navigation Application. If you app doesn’t have this, I am assuming you can add it. Just create on of these projects and copy what is done there. &lt;/p&gt;  &lt;p&gt;Among other things, the WebContext has a User property. This gives you what acts like what you may expect if you are accustomed to ASP.NET. For example, it has a Roles property to see what roles the user in. It has a IsUserInRole() method to see if a user is in a particular role. It has a Name property that gives you the username.&lt;/p&gt;  &lt;p&gt;The WebContext is accessible from code by using WebContext and is also added to the Application Resources in the Application_Startup method which makes it accessible via XAML. To show the current username using XAML you would do something like the following:&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;&amp;lt;TextBlock x:Name=&amp;quot;CurrentUser&amp;quot; Text=&amp;quot;{Binding Current.User.Name, Source={StaticResource WebContext}}&amp;quot; /&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Using XAML is really great because as Current.User changes from null to some value when the user logs in or Windows Authentication logs them in automatically, the TextBlock will be notified and display the change.&lt;/p&gt;  &lt;p&gt;. The same is NOT true if you use code that you may write in ASP.NET to set the value. For example:&lt;/p&gt;  &lt;p&gt;Assume you XAML is now defined like this:&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;&amp;lt;TextBlock x:Name=&amp;quot;CurrentUser&amp;quot; /&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;You might be tempted to write the following line of code&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;CurrentUser.Text = WebContext.Current.User.Name; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;The problem is that WebContext.Current.User may be null initially AND the biggest problem is that you won’t be able to pick up the Name since it may NOT be set yet. Really what we want is to using Bindings which notify the other side of the binding when the value changes. This means that initially we would get no username, but as soon as it is loaded we would be notified that there is a new value and we can show it.&lt;/p&gt;  &lt;p&gt;The code is a little more complex than above, but not really too bad. Basically, we are trying to do what we did in XAML in the first example, but do it in code. Here is all you have to do:&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;CurrentUser.SetBinding(TextBlock.TextProperty, WebContext.Current.CreateOneWayBinding(&amp;quot;User.Name&amp;quot;));&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Now we the CurrentUser textblock will always display the current value of WebContext.Current.User.Name even as it changes. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-1084910275211000505?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/1084910275211000505/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=1084910275211000505' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1084910275211000505'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1084910275211000505'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2010/11/getting-current-user-information-in.html' title='Getting Current User information in Silverlight 4'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-862468741126110367</id><published>2010-11-03T11:05:00.001-07:00</published><updated>2010-11-03T11:05:58.104-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Dynamic Data'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Getting the Action or DynamicDataRoute from a DynamicData page</title><content type='html'>&lt;p&gt;If you are working in a Dynamic Data web application sometimes you may need to know what the Action (List, Details, Edit, Insert) is. The Action is just a string and is set in the Global.asax.cs in the RegisterRoutes() method that is called on application startup. Actually, if you look at each route that is added, the object being added is a DynamicDataRoute object. This is the object we eventually want to access since it has our Action property.&lt;/p&gt;  &lt;p&gt;When you are on a PageTemplate, a CustomPage, EntityTemplate, or a UserControl that you use in one of the previous items you have access to a class called DynamicDataRouteHandler. It has a static method called GetRequestContext() which has a RouteData property. This gives us the RouteData object which has a Route property which is of type BaseRoute. Remember, we need to get an instance of the DynamicDataRoute. As it turns out DynamicDataRoute is a subclass of Route which is a subclass of BaseRoute. So, all we have to do is cast the BaseRoute object we now have to a DynamicDataRoute and we now have access to the Action property.&lt;/p&gt;  &lt;p&gt;I guess that is a lot of explaining for a few lines of code :) Here is the code.&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;RouteData route = DynamicDataRouteHandler.GetRequestContext(Context).RouteData;     &lt;br /&gt;DynamicDataRoute ddRouteData = route.Route as DynamicDataRoute;      &lt;br /&gt;string action = ddRouteData.Action;&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-862468741126110367?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/862468741126110367/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=862468741126110367' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/862468741126110367'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/862468741126110367'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2010/11/getting-action-or-dynamicdataroute-from.html' title='Getting the Action or DynamicDataRoute from a DynamicData page'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-1122821316885175887</id><published>2010-11-02T13:43:00.001-07:00</published><updated>2011-05-05T11:29:00.494-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><category scheme='http://www.blogger.com/atom/ns#' term='Domain Service'/><title type='text'>Adding an item to the ValidationSummary programmatically</title><content type='html'>&lt;p&gt;In ASP.NET, the &lt;strong&gt;ValidationSummary&lt;/strong&gt; can be used to display errors to the end user. They can specific to a field or just be entity specific, etc. In general, field specific validation shows up next to a control that it is validating (assuming you put the validators next to it). But what about validation that happens in a &lt;strong&gt;Domain Service Class&lt;/strong&gt; or your Custom BLL for example? These exceptions will by default be caught by the application and show as a nasty error to the user, or go to the error page. This is hardly the desired behavior for a validation error. &lt;/p&gt;  &lt;p&gt;First I like to change the default behavior of bubbling up to the application to be caught to being handled at the button or page level. To do this I put a try-catch in my button action or other applicable event that you can tap into. In the catch, it would be ideal to add a custom error message to the &lt;strong&gt;ValidationSummary&lt;/strong&gt;. How do we do that though?&lt;/p&gt;  &lt;p&gt;Thankfully, it is quite easy to add an item to the &lt;strong&gt;ValidationSummary&lt;/strong&gt;. The key is that the Page has a Validators property that all validators are automatically added to when you put them on your .aspx page. The problem is that we don’t have a &lt;strong&gt;CustomValidator&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;Thus we need to create a &lt;strong&gt;CustomValidator&lt;/strong&gt;, but what a pain really since we only want to use it when we actually have an exception in our BLL. My solution is to create method to encapsulate the logic to create a new &lt;strong&gt;CustomValidator&lt;/strong&gt; and add it to the Page’s Validators collection. So that it can easily be accessed on any page, I have implemented it as an Extension to the Page class. Below is the code to do so.&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;namespace MyExtensions      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public static class PageExtensions       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static void AddValidationSummaryItem(this Page page, string errorMessage)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var validator = new CustomValidator();       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; validator.IsValid = false;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; validator.ErrorMessage = errorMessage;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; page.Validators.Add(validator);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;To use this method just put the using MyExtensions; statement at the top of your code-behind of the page that you want to use it on. Then you can do the following:&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;protected void btnSubmit_Click(object sender, EventArgs e)      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; try       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // do some stuff like call my BLL that may throw an exception       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; catch (Exception ex)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (ex.Message == &amp;quot;Some key string I want to handle&amp;quot;)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Page.AddValidationSummaryItem(&amp;quot;Password must be at least 6 characters in length.&amp;quot;);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; throw ex;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;WARNING: Be careful with what you display to the end user. You should never catch an exception and display the Message directly to the user. It could have information that a hacker can use to compromise your application.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;UPDATE 5/5/2011:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You may notice that there are times the above method does not work as expected. In particular you may notice that the error message does not show in the &lt;strong&gt;ValidationSummary&lt;/strong&gt; control as you expected even though the &lt;strong&gt;Page.IsValid&lt;/strong&gt; is false (as expected). The problem is likely that you have specified the &lt;strong&gt;ValidationGroup&lt;/strong&gt; on the &lt;strong&gt;ValidationSummary&lt;/strong&gt; control. This is a common issue when using validators and &lt;strong&gt;ValiationSummary&lt;/strong&gt; controls. They must have the same value for &lt;strong&gt;ValidationGroup&lt;/strong&gt; in order to tie them together. When using &lt;strong&gt;DynamicData&lt;/strong&gt; templates the &lt;strong&gt;ValidationGroup&lt;/strong&gt; is NOT set so the above method works great. However, in other situations such as a simple form or maybe the &lt;strong&gt;FormView&lt;/strong&gt; the &lt;strong&gt;ValidationGroup&lt;/strong&gt; property may be specified depending on how your code was generated or if you changed the defaults. &lt;/p&gt;  &lt;p&gt;To help with that issue, I have created another version (overloaded method) of this method that takes one addition parameter called validationGroup.&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;public static void AddValidationSummaryItem(this Page page, string errorMessage, &lt;strong&gt;&lt;font style="background-color: #ffff00"&gt;string validationGroup&lt;/font&gt;&lt;/strong&gt;)      &lt;br /&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; var validator = new CustomValidator();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; validator.IsValid = false;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; validator.ErrorMessage = errorMessage;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;&lt;font style="background-color: #ffff00"&gt;validator.ValidationGroup = validationGroup;         &lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;&amp;#160;&amp;#160;&amp;#160; page.Validators.Add(validator);      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;WARNING: If you call Page.Validate() or Page.Validate(“your validation group here”) after the above call, the validator will be reset to valid since we hardcoded the IsValid value and the default is valid.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-1122821316885175887?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/1122821316885175887/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=1122821316885175887' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1122821316885175887'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/1122821316885175887'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2010/11/adding-item-to-validationsummary.html' title='Adding an item to the ValidationSummary programmatically'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-2002673790540468965</id><published>2010-10-19T13:48:00.001-07:00</published><updated>2010-10-19T13:48:10.623-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='LINQ'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Returning the row index using LINQ</title><content type='html'>&lt;p&gt;Imagine you have a contest and each entry has a some points that they were awarded. To show an ordered list of them is easy enough. Something like the following will return the names and the related points.&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt; Entries     &lt;br /&gt;.Select(entry =&amp;gt; new {      &lt;br /&gt;entry.Name,      &lt;br /&gt;entry.TotalPoints,      &lt;br /&gt;}      &lt;br /&gt;)      &lt;br /&gt;.OrderBy (o =&amp;gt; o.TotalPoints)&lt;/font&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;Now what if you wanted to show the rank (1st, 2nd, 3rd, etc) for each entry. So basically now we have three columns in the results: Rank, Name, TotalPoints. How would we do this?&lt;/p&gt;  &lt;p&gt;The answer is hidden in the LINQ to Objects specially overloaded Select method that is available only when you use the Lambda syntax where if you specify a second parameter it will put the row index in it. Here is that same query, but with the Rank column added.&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt; Entries.&lt;strong&gt;&lt;font size="3"&gt;ToList()&lt;/font&gt;&lt;/strong&gt;      &lt;br /&gt;.Select((entry, &lt;strong&gt;&lt;font size="4"&gt;index&lt;/font&gt;&lt;/strong&gt;) =&amp;gt; new {      &lt;br /&gt;entry.Name,      &lt;br /&gt;entry.TotalPoints,      &lt;br /&gt;Rank = index + 1      &lt;br /&gt;}      &lt;br /&gt;)      &lt;br /&gt;.OrderBy (o =&amp;gt; o.TotalPoints)&lt;/font&gt;    &lt;br /&gt;    &lt;br /&gt;Notice how we used the ToList() to convert the query to a List first. This is critical as you will get a runtime error otherwise. &lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;FYI, the error is: Unsupported overload used for query operator 'Select'.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Also note, the name index is not important. It is the order in the Select method that is important. The index is zero based, and I wanted to show 1 based Rankings so I added one to the index to get the Rank.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-2002673790540468965?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/2002673790540468965/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=2002673790540468965' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/2002673790540468965'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/2002673790540468965'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2010/10/returning-row-index-using-linq.html' title='Returning the row index using LINQ'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-7952692824143527058</id><published>2010-10-19T11:01:00.001-07:00</published><updated>2010-10-19T11:01:03.888-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='LINQ'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Using GroupBy with LINQ</title><content type='html'>&lt;p&gt;I love LINQ, but sometimes the syntax can be a little strange. In particular, I find the group by syntax to be a little weird, but not too bad once I broke it down.&lt;/p&gt;  &lt;p&gt;For this example, let’s assume we have a person table. The person table has a column called Score and has some other fields that don’t really matter for this example. The related table is a Gender table. It has one field of importance and that is the Name field. The two rows in this table are Male and Female. There is a foreign key in the Person table that points to the Gender table. Think of it this way. The person table is the main table, and there could be a drop down list to select the gender for the person. &lt;/p&gt;  &lt;p&gt;With that in mind, we want to know what the total score for Males and Females. We want to do this using a group by. The results will be two columns: Gender and Score. &lt;/p&gt;  &lt;p&gt;Here is an example of the output that we desire.&lt;/p&gt;  &lt;table cellspacing="0" cellpadding="2" width="121" border="1"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="56"&gt;&lt;strong&gt;Gender&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="63"&gt;&lt;strong&gt;Score&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="56"&gt;Female&lt;/td&gt;        &lt;td valign="top" width="63"&gt;2013&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="56"&gt;Male&lt;/td&gt;        &lt;td valign="top" width="63"&gt;1923&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;Here is the lamdba based LINQ query we would need to do this.&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;&amp;#160;&amp;#160; People     &lt;br /&gt;&amp;#160;&amp;#160; .GroupBy (e =&amp;gt; new {Gender = e.Gender.Name} )      &lt;br /&gt;&amp;#160;&amp;#160; .Select (byGenderGroup =&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; new&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Gender = byGenderGroup.Key.Gender,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Score = byGenderGroup.Sum (t =&amp;gt; t.Score)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160;&amp;#160; );&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;If we take this line by line we will see that this really isn’t so different from SQL that would be generated. Here is the SQL&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;&amp;#160;&amp;#160; SELECT SUM([t0].[Score]) AS [Score], [t1].[Name] AS [Gender]     &lt;br /&gt;FROM [Person] AS [t0]      &lt;br /&gt;INNER JOIN [Gender] AS [t1] ON [t1].[ID] = [t0].[GenderID]      &lt;br /&gt;GROUP BY [t1].[Name]&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Let’s go line by line of the LINQ code.&lt;/p&gt;  &lt;p&gt;People is the main table we are working with&lt;/p&gt;  &lt;p&gt;GroupBy creates an anonymous type (that way we can easily add additional columns to group by). In this case we group by the Gender.Name just like the last line of the SQL statement.&lt;/p&gt;  &lt;p&gt;The Select lines create another anonymous type so that we can select just the columns we want to return. Notice that byGenderGroup doesn’t have a property called Gender. Since byGenderGroup doesn’t represent a person record and actually represents the grouped results, we can access any of the columns that we have grouped by in the above GroupBy line. In this case, Key collection only gives us one property, and that is Gender. The byGenderGroup does have many other methods that are available though. One example is the sum method. In general byGenderGroup has all the aggregate functions you would have in SQL.&lt;/p&gt;  &lt;p&gt;FYI, you can also do this without using lamdba expressions, though I personally don’t like the syntax and find it confusing.&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;var results = from p in People group p by new {Gender = p.Gender.Name} into byGenderGroup     &lt;br /&gt;select new {byGenderGroup.Key.Gender, Score = byGenderGroup.Sum (t =&amp;gt; t.Score)};&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;The choice is yours.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-7952692824143527058?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/7952692824143527058/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=7952692824143527058' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/7952692824143527058'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/7952692824143527058'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2010/10/using-groupby-with-linq.html' title='Using GroupBy with LINQ'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-6920598931157766014</id><published>2010-10-18T19:00:00.001-07:00</published><updated>2010-10-18T19:01:38.033-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='System Admin'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><title type='text'>SharePoint users can no longer upload files larger than 25 MB after moving from Windows Server 2003 to 2008</title><content type='html'>&lt;p&gt;I can’t take credit for this one, but it is worth a post.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;Problem:&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;After moving SharePoint from Windows Server 2003 to Server 2008, users can no longer upload files larger than 25 MB.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;Explanation:&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;This is by design.&amp;#160; SharePoint, by default, restricts file uploads greater than 50 MB.&amp;#160; But IIS 7, by default, restricts file uploads greater than 25 MB.&amp;#160; When this threshold is reached the user gets a 404.13 error.&amp;#160; Of course since all users have &amp;quot;friendly&amp;quot; errors turned on, it is hard to tell why the file didn't upload.&amp;#160; One user even got a Google &amp;quot;Oops&amp;quot; page.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;Solution:&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Edit the web.config file for each virtual directory and force the threshold to be a little bigger than SharePoint's threshold.&amp;#160; If the threshold is hit, you want the SharePoint error to appear and not IIS's error.&lt;/p&gt;  &lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; text-align: left"&gt;   &lt;div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;     &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; Replace:&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;system.net&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;defaultProxy&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;proxy&lt;/span&gt; &lt;span style="color: #ff0000"&gt;autoDetect&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;defaultProxy&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum6" style="color: #606060"&gt;   6:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;system.net&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum7" style="color: #606060"&gt;   7:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;configuration&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum8" style="color: #606060"&gt;   8:&lt;/span&gt;&amp;#160; &lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum9" style="color: #606060"&gt;   9:&lt;/span&gt; With:&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum10" style="color: #606060"&gt;  10:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;system.net&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum11" style="color: #606060"&gt;  11:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;defaultProxy&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum12" style="color: #606060"&gt;  12:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;proxy&lt;/span&gt; &lt;span style="color: #ff0000"&gt;autoDetect&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum13" style="color: #606060"&gt;  13:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;defaultProxy&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum14" style="color: #606060"&gt;  14:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;system.net&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum15" style="color: #606060"&gt;  15:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;system.webServer&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum16" style="color: #606060"&gt;  16:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;security&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum17" style="color: #606060"&gt;  17:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;requestFiltering&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum18" style="color: #606060"&gt;  18:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;requestLimits&lt;/span&gt; &lt;span style="color: #ff0000"&gt;maxAllowedContentLength&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;52428800&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum19" style="color: #606060"&gt;  19:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;requestFiltering&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum20" style="color: #606060"&gt;  20:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;security&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum21" style="color: #606060"&gt;  21:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;system.webServer&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum22" style="color: #606060"&gt;  22:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;configuration&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The change is instant.&amp;#160; No closing of the browser or restarting of anything is needed.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;KB Resource:&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://support.microsoft.com/kb/944981"&gt;http://support.microsoft.com/kb/944981&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-6920598931157766014?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/6920598931157766014/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=6920598931157766014' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/6920598931157766014'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/6920598931157766014'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2010/10/sharepoint-users-can-no-longer-upload.html' title='SharePoint users can no longer upload files larger than 25 MB after moving from Windows Server 2003 to 2008'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-4530213207030293686</id><published>2010-10-18T16:54:00.001-07:00</published><updated>2010-10-18T16:58:19.739-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Dynamic Data'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='ADO.NET Entity Framework'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Working with Dynamic Data Controls: Finding, Set Value, Get Value</title><content type='html'>&lt;p&gt;Once you start working with ASP.NET, FormView, and the DynamicData controls you will soon learn that it isn’t as convenient to get and set values as you might like. You may also want to find controls not by their name, but by the column / property that they are bound to in the ADO.NET Entity Model.&lt;/p&gt;  &lt;p&gt;I have put together some extensions to the Control class that make doing all these things much easier. All you have to do is create a class in your project called ControlExtensions. Copy and paste the code below into it. Change the namespace as needed. Then on the page you want to use it, just include the namespace. Then when you look at the methods on any control you will see the methods below. I have tested the code below with a FormView and also with DynamicControls on a User Control&amp;#160; that is then on a FormView. In both cases, the code works well.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;using System;     &lt;br /&gt;using System.Collections.Generic;      &lt;br /&gt;using System.Linq;      &lt;br /&gt;using System.Web;      &lt;br /&gt;using System.Web.UI;      &lt;br /&gt;using System.Web.UI.WebControls;      &lt;br /&gt;using System.Web.DynamicData;      &lt;br /&gt;using System.ComponentModel; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;namespace DistiPromo.Helpers     &lt;br /&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public static class ControlExtensions      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; { &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// This will find the Dynamic Data control for the specified column (name from Entity model)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;control&amp;quot;&amp;gt;the control (such as FormView or UserControl) that directly contains the control you are looking for&amp;lt;/param&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;columnName&amp;quot;&amp;gt;the name of the column (from the Entity Model) that you are looking for&amp;lt;/param&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;returns&amp;gt;The DynamicData Control for the column that you are looking for&amp;lt;/returns&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static Control FindFieldTemplate(this Control control, string columnName)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // code copied from internal method: System.Web.DynamicData.DynamicControl.GetControlIDFromColumnName      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Since it is internal, it could change, but I needed to get to it      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return control.FindControl(&amp;quot;__&amp;quot; + columnName);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static FieldTemplateUserControl FindFieldTemplateUserControl(this Control control, string columnName)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var userControl = ((FieldTemplateUserControl)(control.FindFieldTemplate(columnName)));      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (userControl == null) throw new Exception(&amp;quot;Could not find FieldTemplate in Control for &amp;quot; + columnName);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return userControl;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static Control FindControlForColumn(this Control control1, string columnName)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var control = FindFieldTemplateUserControl(control1, columnName).DataControl;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (control == null) throw new Exception(&amp;quot;Could not find control in Control for &amp;quot; + columnName);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return control;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static T FindControlForColumn&amp;lt;T&amp;gt;(this Control control, string columnName) where T : Control     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return FindControlForColumn(control, columnName) as T;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static object GetValueForColumn(this Control control, string columnName)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var actualControl = FindFieldTemplateUserControl(control, columnName).DataControl;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return GetValue(control, actualControl);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static T GetValue&amp;lt;T&amp;gt;(this Control control, string columnName)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; object rawVal = GetValueForColumn(control, columnName);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; //return (T)Convert.ChangeType(rawVal, typeof(T)); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // this is a little better because it handles nullable types also     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFrom(rawVal);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static T GetValue&amp;lt;T&amp;gt;(this Control control1, Control control)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; object rawVal = GetValue(control1, control);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; //return (T)Convert.ChangeType(rawVal, typeof(T)); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // this is a little better because it handles nullable types also     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFrom(rawVal);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static object GetValue(this Control control, Control actualControl)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (actualControl is ITextControl)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return (actualControl as ITextControl).Text;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else if (actualControl is ICheckBoxControl)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return (actualControl as ICheckBoxControl).Checked;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else if (actualControl is ListControl)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return (actualControl as ListControl).SelectedValue;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else if (actualControl is HiddenField)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return (actualControl as HiddenField).Value;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else throw new Exception(&amp;quot;Could not get value of unknown control type: &amp;quot; + actualControl.GetType().ToString()); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static void SetValue(this Control control, string columnName, object value)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Control actualControl = FindControlForColumn(control, columnName);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SetValue(control, actualControl, value);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static void SetValue(this Control control, Control actualControl, object value)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (actualControl is ITextControl)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; (actualControl as ITextControl).Text = Convert.ToString(value);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else if (actualControl is ICheckBoxControl)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; (actualControl as ICheckBoxControl).Checked = Convert.ToBoolean(value);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else if (actualControl is ListControl)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; (actualControl as ListControl).SelectedValue = Convert.ToString(value);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else if (actualControl is HiddenField)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; (actualControl as HiddenField).Value = Convert.ToString(value);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else throw new Exception(&amp;quot;Could not set value of unknown control type: &amp;quot; + actualControl.GetType().ToString());      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt; &lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4702950152327976706-4530213207030293686?l=justgeeks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://justgeeks.blogspot.com/feeds/4530213207030293686/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4702950152327976706&amp;postID=4530213207030293686' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/4530213207030293686'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4702950152327976706/posts/default/4530213207030293686'/><link rel='alternate' type='text/html' href='http://justgeeks.blogspot.com/2010/10/working-with-dynamic-data-controls.html' title='Working with Dynamic Data Controls: Finding, Set Value, Get Value'/><author><name>Brent V</name><uri>http://www.blogger.com/profile/15891142062380248367</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4702950152327976706.post-5455814967312078120</id><published>2010-10-15T16:26:00.001-07:00</published><updated>2010-10-15T16:26:36.558-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Dynamic Data'/><category scheme='
