<?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-8024416128576404267</id><updated>2012-02-16T02:11:07.978-08:00</updated><category term='economy'/><category term='resume'/><category term='connectionstring'/><category term='uplifting'/><category term='connection string'/><category term='reverse string object c#'/><category term='config location'/><category term='custom config'/><category term='web.config'/><category term='Job'/><title type='text'>Kevin Landivar</title><subtitle type='html'>All about software development, tips, tricks, and the life around it.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://kevinlandivar.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8024416128576404267/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://kevinlandivar.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Kevin Landivar</name><uri>http://www.blogger.com/profile/11526893732033752004</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://2.bp.blogspot.com/_qcgRgxqp_N8/So2S2isA02I/AAAAAAAAABQ/_d-QXM-xB8w/S220/USA.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8024416128576404267.post-6163938046008662995</id><published>2012-02-06T20:01:00.000-08:00</published><updated>2012-02-06T20:01:22.088-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='reverse string object c#'/><title type='text'>Reversing a string without creating a new string object in C#</title><content type='html'>&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;A while ago i was asked to switch a group of words in the reverse order.&amp;nbsp; This was a simple task until they added the caveat that i could not create a new string object while switching the order of the words.&amp;nbsp; I searched the web and i really could not find a straight and complete way to accomplish this.&amp;nbsp; So i came out with my own way.&amp;nbsp; Not to say that it is the best way, but it is a way to do it.&amp;nbsp; I kept things simple to make it easier to understand.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;The first  thing i do is create the string of words using the StringBuilder.&amp;nbsp; I  defined a few variables to track the characters in the string. &amp;nbsp; My  approach here was to first flip the whole string of characters.&amp;nbsp; In  order to accomplish this i use a while loop and i start switching  characters from the back to the front and from the front to the back  until i get to the middle of the string.&amp;nbsp; It is important to stop in the  middle or you will end up with the original string.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-hMHtZdVNdro/TzCKlzXFAXI/AAAAAAAAAV0/P6XNI9dbj3Q/s1600/ReverseString1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="238" src="http://4.bp.blogspot.com/-hMHtZdVNdro/TzCKlzXFAXI/AAAAAAAAAV0/P6XNI9dbj3Q/s320/ReverseString1.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt; &lt;/span&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;The  next step is where the actual work happens.&amp;nbsp; Line 35 and 36 include a  logic to look for the instance of blank spaces.&amp;nbsp; The blank spaces are  the delimiters for each work in the full string.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;Lines 38-41 determines where the next word will end.&amp;nbsp; This is necessary since the last word must be determine.&amp;nbsp; &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;The  while loop in lines 43-49 flip the letters in each word.&amp;nbsp; After the  flipping is completed for the word, the outer loop moves forward to the  next group of characters to continue the flipping process.&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt; &lt;/span&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-4NhIRXShAYQ/TzCNVaZ60aI/AAAAAAAAAV8/AgF5fVGKWNI/s1600/ReverseString2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="255" src="http://4.bp.blogspot.com/-4NhIRXShAYQ/TzCNVaZ60aI/AAAAAAAAAV8/AgF5fVGKWNI/s320/ReverseString2.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;The final result illustrates flipping a group of words in the opposite way without creating different objects.&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-46gk9mt7Cjo/TzCVgqI2sMI/AAAAAAAAAWE/CekVKt5fMKY/s1600/ReverseString3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="68" src="http://4.bp.blogspot.com/-46gk9mt7Cjo/TzCVgqI2sMI/AAAAAAAAAWE/CekVKt5fMKY/s320/ReverseString3.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;You can imagine that there are many other ways to accomplish this task, but if someone ever ask you to perform this task with the minimum amount f string creation, you can use this.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8024416128576404267-6163938046008662995?l=kevinlandivar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kevinlandivar.blogspot.com/feeds/6163938046008662995/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kevinlandivar.blogspot.com/2012/02/reversing-string-without-creating-new.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8024416128576404267/posts/default/6163938046008662995'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8024416128576404267/posts/default/6163938046008662995'/><link rel='alternate' type='text/html' href='http://kevinlandivar.blogspot.com/2012/02/reversing-string-without-creating-new.html' title='Reversing a string without creating a new string object in C#'/><author><name>Kevin Landivar</name><uri>http://www.blogger.com/profile/11526893732033752004</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://2.bp.blogspot.com/_qcgRgxqp_N8/So2S2isA02I/AAAAAAAAABQ/_d-QXM-xB8w/S220/USA.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-hMHtZdVNdro/TzCKlzXFAXI/AAAAAAAAAV0/P6XNI9dbj3Q/s72-c/ReverseString1.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8024416128576404267.post-294358090507060764</id><published>2010-05-09T20:58:00.000-07:00</published><updated>2012-02-06T20:19:02.716-08:00</updated><title type='text'>Super Fast Record Search in C#</title><content type='html'>Searching for a piece of data in your tables is a common task in almost every single application whether it is a desktop or web application.  If you want to look for an item in a relatively small set of records most likely you use some type of record iteration like a foreach loop.  We all have done some type of search similar to the one i mentioned. &lt;br /&gt;&lt;br /&gt;The problem comes when the amount of information stored in your database begins to increase, and then it grows exponetially!  At this point if you have not plan properly you will have to come up with ingenous ideas on how to speed up the data processing and retrieval.  Most of this ideas include throwing more hardware power, indexing and the kitchen sink.&lt;br /&gt;&lt;br /&gt;Since I am certain that at some point in your life you are going to run into this issue, well here it is.  A search that can tackle a large number of record in a very short amount of time, or at least i think so :-\ &lt;br /&gt;&lt;br /&gt;In this exercise we will create a set of 1 million records, the records are in a circular array that have been shifted "n" positions to the right.  The task at hand is to find the amount of spaces in the array that the first element was shifted to the right.  No need to worry about the amount of iterations in the array, just the current position. &lt;br /&gt;&lt;br /&gt;The keyword here is "BinarySearch"  The BinarySearch allows us to search a one dimensional sorted array for an specific value.  It uses a binary type of search algorithm. &lt;br /&gt;&lt;br /&gt;&lt;textarea&gt;&lt;br /&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.Collections;&lt;br /&gt;&lt;br /&gt;namespace SearchShiftedArray&lt;br /&gt;{    &lt;br /&gt;    //Kevin L.&lt;br /&gt;    //This is just a test for a rapid search on a shifted position&lt;br /&gt;    //in a large array of records&lt;br /&gt;    public class Program&lt;br /&gt;    {&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {   &lt;br /&gt;            int[] iMillionNumbers = new int[1000000];&lt;br /&gt;&lt;br /&gt;            int counter = 0;&lt;br /&gt;            int i = 3;&lt;br /&gt;&lt;br /&gt;            //Just creating dummy data to test&lt;br /&gt;            while (counter &lt; 1000000)&lt;br /&gt;            {&lt;br /&gt;                if (i == 1000001)&lt;br /&gt;                    i = 1;&lt;br /&gt;&lt;br /&gt;                iMillionNumbers[counter] = i;&lt;br /&gt;&lt;br /&gt;                i++;&lt;br /&gt;                counter++;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            //I want to save original item in first position for comparison&lt;br /&gt;            int originalFirstItem = iMillionNumbers[0];            &lt;br /&gt;&lt;br /&gt;            //Get the array re-sorted before a perfom a binary search&lt;br /&gt;            ReverseComparer rc = new ReverseComparer();&lt;br /&gt;            Array.Sort(iMillionNumbers, rc);&lt;br /&gt;&lt;br /&gt;            //Looking for the first item from original shifted set of records&lt;br /&gt;            int indexShifted = Array.BinarySearch(iMillionNumbers, originalFirstItem, rc);&lt;br /&gt;            &lt;br /&gt;            //Amount of shifted positions in the array&lt;br /&gt;            Console.WriteLine("Shifted by {0} spaces.", iMillionNumbers.Count() - indexShifted);&lt;br /&gt;            Console.ReadLine();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public class ReverseComparer : IComparer&lt;int&gt;&lt;br /&gt;    {&lt;br /&gt;        public int Compare(int x, int y)&lt;br /&gt;        {&lt;br /&gt;            // Compare y and x in reverse order.&lt;br /&gt;            return x.CompareTo(y);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8024416128576404267-294358090507060764?l=kevinlandivar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kevinlandivar.blogspot.com/feeds/294358090507060764/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kevinlandivar.blogspot.com/2010/05/super-fast-record-search-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8024416128576404267/posts/default/294358090507060764'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8024416128576404267/posts/default/294358090507060764'/><link rel='alternate' type='text/html' href='http://kevinlandivar.blogspot.com/2010/05/super-fast-record-search-in-c.html' title='Super Fast Record Search in C#'/><author><name>Kevin Landivar</name><uri>http://www.blogger.com/profile/11526893732033752004</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://2.bp.blogspot.com/_qcgRgxqp_N8/So2S2isA02I/AAAAAAAAABQ/_d-QXM-xB8w/S220/USA.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8024416128576404267.post-5412303673916115991</id><published>2009-05-15T12:46:00.000-07:00</published><updated>2009-05-15T13:06:29.307-07:00</updated><title type='text'>IE Open new window with focus using Update Panels</title><content type='html'>&lt;span style=";font-family:arial;font-size:100%;"  &gt;Every once in a while&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt; we need to open a new window from our main page and we want to make sure it has the focus so the user does not keep on clicking the same "open" button creating multiple pages in the background.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;It sounds simple but if you are using "Update Panels" so avoid the annoying refresh look in your page and then you want to open a new window, this can be challenging.  Instead here is a way to do it.  I used a mix of javascript and c# code.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;In my client javascript I defined a function that calls the window.open and pass the proper parameters to declare the page i would like to open.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;//script language="javascript"//&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; function ReportDetailPopup(xCaseNumber) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;           var w = window.open("ReportUIDetail.aspx?ExternalCaseNumber=" + xCaseNumber);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;       }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;//script//&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;Now in my codebehind i call  the "RegisterStartupScript" function to call my javascript function and then i set the focus on the Page recently called.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;protected void grdResults_SelectedIndexChanged(object sender, EventArgs e)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        {&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;            string externalCaseNumber = "";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            externalCaseNumber = grdResults.SelectedDataKey.Value.ToString();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "OpenNewWindow", "ReportDetailPopup('" + externalCaseNumber + "');", true);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            Page.Focus();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: arial;"&gt;I am certain that there are other ways to do it, but if you are entering the world of "update panels"  you will find that many things don't work the way they should for obvious reasons.  I will post more tricks to get the most out of update panels.&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8024416128576404267-5412303673916115991?l=kevinlandivar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kevinlandivar.blogspot.com/feeds/5412303673916115991/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kevinlandivar.blogspot.com/2009/05/ie-open-new-window-with-focus-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8024416128576404267/posts/default/5412303673916115991'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8024416128576404267/posts/default/5412303673916115991'/><link rel='alternate' type='text/html' href='http://kevinlandivar.blogspot.com/2009/05/ie-open-new-window-with-focus-using.html' title='IE Open new window with focus using Update Panels'/><author><name>Kevin Landivar</name><uri>http://www.blogger.com/profile/11526893732033752004</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://2.bp.blogspot.com/_qcgRgxqp_N8/So2S2isA02I/AAAAAAAAABQ/_d-QXM-xB8w/S220/USA.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8024416128576404267.post-3723492426683297491</id><published>2009-05-15T10:46:00.000-07:00</published><updated>2009-05-15T12:26:40.737-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='web.config'/><category scheme='http://www.blogger.com/atom/ns#' term='connection string'/><category scheme='http://www.blogger.com/atom/ns#' term='connectionstring'/><category scheme='http://www.blogger.com/atom/ns#' term='config location'/><category scheme='http://www.blogger.com/atom/ns#' term='custom config'/><title type='text'>Custom Config file in a custom location?</title><content type='html'>&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;Have you ever had the need to share some settings among different parts of your n-tier environment? Obviously yes! Well recently i was in need of using some type of file that will contain data that can be use in different components of my application without having to replicate the file/data inside and turn it into a maintenance nightmare. Many ideas were thrown around. At the end we agree on using a config file. Similar to the Web.config or the App.Config, but fully customize for our application.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;There is a fairly simple way of doing this. First you will create your config file with the values you want.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_qcgRgxqp_N8/Sg23NT2LuPI/AAAAAAAAAAM/iSXvzS-V-YM/s1600-h/Fig1.JPG"&gt;&lt;img style="cursor: pointer; width: 520px; height: 100px;" src="http://4.bp.blogspot.com/_qcgRgxqp_N8/Sg23NT2LuPI/AAAAAAAAAAM/iSXvzS-V-YM/s320/Fig1.JPG" alt="" id="Fig. 1" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;I called this file “DBSettings.config” and I place it in the same directory as all of my assemblies (dlls) &lt;/span&gt;&lt;span style="font-family:arial;"&gt;the actual “bin” folder.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;Secondly, I created a project called “Controller” with a class called “ConfigurationSettings.cs” Here is &lt;/span&gt;&lt;span style="font-family:arial;"&gt;the code for this file.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;using System;&lt;br /&gt;using System.Reflection;&lt;br /&gt;using System.Collections;&lt;br /&gt;using System.Collections.Specialized;&lt;br /&gt;using System.Globalization;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Xml;&lt;br /&gt;using System.IO;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;namespace MyNamespace.Controller&lt;br /&gt;{&lt;br /&gt;  public class ConfigurationSettings&lt;br /&gt;  {&lt;br /&gt;      private const string APPSETTINGS_SECTION_NAME = "appSettings";&lt;br /&gt;      private const string CONFIG_SECTIONS_PATH = "/configuration/configSections";&lt;br /&gt;      private const string CONFIG_SECTIONS_GROUP_PATH = "sectionGroup";&lt;br /&gt;      private const string CONFIG_SECTION_PATH = "section";&lt;br /&gt;      private static Assembly _callingAssembly = null;&lt;br /&gt;&lt;br /&gt;      private ConfigurationSettings()&lt;br /&gt;      {&lt;br /&gt;&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      public static object GetConfig(string sectionName, string configFileName)&lt;br /&gt;      {&lt;br /&gt;          XmlDocument xmlDoc = new XmlDocument();&lt;br /&gt;          xmlDoc.Load(configFileName);&lt;br /&gt;&lt;br /&gt;          IConfigurationSectionHandler handler = GetHandler(sectionName, xmlDoc);&lt;br /&gt;          object config = null;&lt;br /&gt;&lt;br /&gt;          if (sectionName == APPSETTINGS_SECTION_NAME)&lt;br /&gt;          {&lt;br /&gt;              config = GetAppSettingsFileHandler(sectionName, handler, xmlDoc);&lt;br /&gt;          }&lt;br /&gt;          else&lt;br /&gt;          {&lt;br /&gt;              XmlNode node = xmlDoc.SelectSingleNode("//" + sectionName);&lt;br /&gt;              config = handler.Create(null, null, node);&lt;br /&gt;          }&lt;br /&gt;&lt;br /&gt;          return config;&lt;br /&gt;      }&lt;br /&gt;      public static object GetConfig(string sectionName)&lt;br /&gt;      {&lt;br /&gt;          Assembly asm = Assembly.GetCallingAssembly();&lt;br /&gt;          if (_callingAssembly != null &amp;amp;&amp;amp; _callingAssembly != asm)&lt;br /&gt;          {&lt;br /&gt;              asm = _callingAssembly;&lt;br /&gt;          }&lt;br /&gt;&lt;br /&gt;          string filePath = Path.GetDirectoryName(asm.Location);&lt;br /&gt;          string asmName = Path.GetFileName(asm.Location);&lt;br /&gt;&lt;br /&gt;          string configFileName = Path.Combine(filePath, asmName + ".config");&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;          return GetConfig(sectionName, configFileName);&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      public static NameValueCollection AppSettingsLocationDefined(string configFileName)&lt;br /&gt;      {&lt;br /&gt;          NameValueCollection appSettings = (NameValueCollection)ConfigurationSettings.GetConfig(APPSETTINGS_SECTION_NAME, configFileName);&lt;br /&gt;          if (appSettings == null)&lt;br /&gt;          {&lt;br /&gt;              appSettings = new NameValueCollection();&lt;br /&gt;          }&lt;br /&gt;&lt;br /&gt;          return appSettings;&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      public static NameValueCollection AppSettings&lt;br /&gt;      {&lt;br /&gt;          get&lt;br /&gt;          {&lt;br /&gt;              //Store the calling assembly because we are about to call ourselves&lt;br /&gt;              _callingAssembly = Assembly.GetCallingAssembly();&lt;br /&gt;&lt;br /&gt;              NameValueCollection appSettings = (NameValueCollection)ConfigurationSettings.GetConfig(APPSETTINGS_SECTION_NAME);&lt;br /&gt;              if (appSettings == null)&lt;br /&gt;              {&lt;br /&gt;                  appSettings = new NameValueCollection();&lt;br /&gt;              }&lt;br /&gt;&lt;br /&gt;              return appSettings;&lt;br /&gt;          }&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      protected static IConfigurationSectionHandler GetHandler(string sectionName, XmlDocument xmlDoc)&lt;br /&gt;      {&lt;br /&gt;          IConfigurationSectionHandler handler = null;&lt;br /&gt;&lt;br /&gt;          if (sectionName == APPSETTINGS_SECTION_NAME)&lt;br /&gt;          {&lt;br /&gt;              handler = new NameValueSectionHandler();&lt;br /&gt;              return handler;&lt;br /&gt;          }&lt;br /&gt;&lt;br /&gt;          string[] sections = sectionName.Split('/');&lt;br /&gt;          string sectionGroup = string.Empty;&lt;br /&gt;          string section = string.Empty;&lt;br /&gt;          string xPath = string.Empty;&lt;br /&gt;&lt;br /&gt;          //see if we have a section group that we have to go through&lt;br /&gt;          if (sections.Length &gt; 1)&lt;br /&gt;          {&lt;br /&gt;              sectionGroup = sections[0];&lt;br /&gt;              section = sections[1];&lt;br /&gt;&lt;br /&gt;              xPath = string.Format(CONFIG_SECTIONS_PATH + "/" +&lt;br /&gt;                  CONFIG_SECTIONS_GROUP_PATH + "[@name='" + sectionGroup + "']/" +&lt;br /&gt;                  CONFIG_SECTION_PATH + "[@name='" + section + "']");&lt;br /&gt;          }&lt;br /&gt;          else&lt;br /&gt;          {&lt;br /&gt;              section = sections[0];&lt;br /&gt;&lt;br /&gt;              xPath = string.Format(CONFIG_SECTIONS_PATH + "/" +&lt;br /&gt;                  CONFIG_SECTION_PATH + "[@name='" + section + "']");&lt;br /&gt;          }&lt;br /&gt;&lt;br /&gt;          XmlNode node = xmlDoc.SelectSingleNode(xPath);&lt;br /&gt;&lt;br /&gt;          string typeName = node.Attributes["type", ""].Value;&lt;br /&gt;&lt;br /&gt;          if (typeName == null || typeName.Length == 0)&lt;br /&gt;              return handler;&lt;br /&gt;&lt;br /&gt;          Type handlerType = Type.GetType(typeName);&lt;br /&gt;          handler = (IConfigurationSectionHandler)Activator.CreateInstance(handlerType);&lt;br /&gt;&lt;br /&gt;          return handler;&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      protected static object GetAppSettingsFileHandler(string sectionName, IConfigurationSectionHandler parentHandler, XmlDocument xmlDoc)&lt;br /&gt;      {&lt;br /&gt;          object handler = null;&lt;br /&gt;          XmlNode node = xmlDoc.SelectSingleNode("//" + sectionName);&lt;br /&gt;          XmlAttribute att = (XmlAttribute)node.Attributes.RemoveNamedItem("file");&lt;br /&gt;&lt;br /&gt;          if (att == null || att.Value == null || att.Value.Length == 0)&lt;br /&gt;          {&lt;br /&gt;              return parentHandler.Create(null, null, node);&lt;br /&gt;          }&lt;br /&gt;          else&lt;br /&gt;          {&lt;br /&gt;              string fileName = att.Value;&lt;br /&gt;              string dir = Path.GetDirectoryName(fileName);&lt;br /&gt;              string fullName = Path.Combine(dir, fileName);&lt;br /&gt;              XmlDocument xmlDoc2 = new XmlDocument();&lt;br /&gt;              xmlDoc2.Load(fullName);&lt;br /&gt;&lt;br /&gt;              object parent = parentHandler.Create(null, null, node);&lt;br /&gt;              IConfigurationSectionHandler h = new NameValueSectionHandler();&lt;br /&gt;              handler = h.Create(parent, null, xmlDoc2.DocumentElement);&lt;br /&gt;          }&lt;br /&gt;&lt;br /&gt;          return handler;&lt;br /&gt;      }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;          &lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;Finally I created another project within the solution called “Controller.Database” with a class called &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;“LoadData.cs” This class contains all of the DB calls with sprocs and query calls, but the important part &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;is the actual connection string. I am including the part that bring the connection string from the &lt;/span&gt;&lt;span style="font-family:arial;"&gt;customize config file. It is important to remember that you need to reference the IO and the Reflection &lt;/span&gt;&lt;span style="font-family:arial;"&gt;assemblies in order to get it to read the proper values.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:arial;"&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Data.SqlClient;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.Collections.ObjectModel;&lt;br /&gt;using System.Threading;&lt;br /&gt;using System.ComponentModel;&lt;br /&gt;using MyNamespace.Controller;&lt;br /&gt;using System.IO;&lt;br /&gt;using System.Reflection;&lt;br /&gt;&lt;br /&gt;namespace MyNamespace.Controller.Database&lt;br /&gt;{&lt;br /&gt;  public class DataAccessManager&lt;br /&gt;  {&lt;br /&gt;      private const int DEFAULT_MAPPING_SERVICETYPE = 0;&lt;br /&gt;      #region Connection String&lt;br /&gt;      public static string ConnectionString&lt;br /&gt;      {&lt;br /&gt;          get&lt;br /&gt;          {&lt;br /&gt;              //Retrieving the location of the assembly file.            &lt;br /&gt;              string appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);&lt;br /&gt;              //Appending the custom config file name.&lt;br /&gt;              appPath = Path.Combine(appPath, "DBSettings.config");&lt;br /&gt;              return ConfigurationSettings.AppSettingsLocationDefined(appPath)["ConnectionString"].ToString();&lt;br /&gt;          }&lt;br /&gt;      }&lt;br /&gt;      #endregion&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;...more code that makes specific calls to get data to different components accros the application.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:arial;font-size:100%;"&gt;From this point on you can call the ConnectionString static string from the LoadData.cs and the rest will &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;font-size:100%;"&gt;be taken care of.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;font-size:100%;"&gt;The way we implemented this code allowed us to not include any db connection objects in the UI by &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-size:100%;"&gt;referencing only the components that are in charge of gathering the data.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8024416128576404267-3723492426683297491?l=kevinlandivar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kevinlandivar.blogspot.com/feeds/3723492426683297491/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kevinlandivar.blogspot.com/2009/05/custom-config-file-in-custom-location.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8024416128576404267/posts/default/3723492426683297491'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8024416128576404267/posts/default/3723492426683297491'/><link rel='alternate' type='text/html' href='http://kevinlandivar.blogspot.com/2009/05/custom-config-file-in-custom-location.html' title='Custom Config file in a custom location?'/><author><name>Kevin Landivar</name><uri>http://www.blogger.com/profile/11526893732033752004</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://2.bp.blogspot.com/_qcgRgxqp_N8/So2S2isA02I/AAAAAAAAABQ/_d-QXM-xB8w/S220/USA.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_qcgRgxqp_N8/Sg23NT2LuPI/AAAAAAAAAAM/iSXvzS-V-YM/s72-c/Fig1.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8024416128576404267.post-4871362823370730838</id><published>2009-03-31T20:31:00.000-07:00</published><updated>2009-03-31T20:44:41.809-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='resume'/><category scheme='http://www.blogger.com/atom/ns#' term='Job'/><category scheme='http://www.blogger.com/atom/ns#' term='uplifting'/><category scheme='http://www.blogger.com/atom/ns#' term='economy'/><title type='text'>Finding a job</title><content type='html'>If you are like most people in the USA right now, you either know someone that lost their job or you are someone that lost your job!  I was both.  In my previous company they laid off 4,000 employees in one day.  I survived three laid offs, but the last one got me. &lt;br /&gt;&lt;br /&gt;I do want to share some tips on finding a job.  One of the most important items in your list is to use this time to increase your expertise in anything that relates to your industry of work.  You don't have to spend tons of money in courses or training DVD's.  You can get most if not all the resources that you can imagine in your local library.  It is almost free (unless you are late in returning items) since you already pay for it in your taxes! &lt;br /&gt;&lt;br /&gt;For real just grab a book and read it, you will see how your knowledge will increase and in time will make you more appealing for companies.  Another tip and one that i believe to be "essential" in finding a job is to post your resume online...once it is nice and ready make sure to update it at least once a week.  Otherwise your resume will go to the bottom of the list and recruiters would not see it.  It might sound crazy, but i swear it works.  It does not matter how good your resume is, everyday these websites are bombarded with new and updated resumes that go to the "top" of the pile, meanwhile your gets to the bottom.  It actually makes sense since the system assumes that since you have not updated your resume, you probably are no longer looking.  I don't mean to update the whole information, but at least a letter or a number would do. &lt;br /&gt;&lt;br /&gt;Last but not least, always think positively even if it looks gloomy and you feel like a loser you are not!  We are all going through the same thing and it could happen to anyone. &lt;br /&gt;&lt;br /&gt;Best of luck and God Speed!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8024416128576404267-4871362823370730838?l=kevinlandivar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kevinlandivar.blogspot.com/feeds/4871362823370730838/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kevinlandivar.blogspot.com/2009/03/finding-job.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8024416128576404267/posts/default/4871362823370730838'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8024416128576404267/posts/default/4871362823370730838'/><link rel='alternate' type='text/html' href='http://kevinlandivar.blogspot.com/2009/03/finding-job.html' title='Finding a job'/><author><name>Kevin Landivar</name><uri>http://www.blogger.com/profile/11526893732033752004</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://2.bp.blogspot.com/_qcgRgxqp_N8/So2S2isA02I/AAAAAAAAABQ/_d-QXM-xB8w/S220/USA.JPG'/></author><thr:total>0</thr:total></entry></feed>
