tag:blogger.com,1999:blog-47018704748775956732024-03-05T14:43:26.563-08:00Brook's Software Development BlogBrookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.comBlogger65125tag:blogger.com,1999:blog-4701870474877595673.post-45262926294188430892020-01-20T09:56:00.000-08:002020-01-20T09:56:27.019-08:00Viewing Different Locations in the Same Visual Studio File<span style="font-family: Verdana, sans-serif;">I frequently want to view two parts of a file at the same time. Like if I am copying or moving code from one place to another in the same file.</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">I have found it handy to drag the split bar down to get two panes of the same file.</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipWXbRK2G8fmaDB7WKlU1nGpAJH3AIM12KFKNavIc1LCrXeRXIttK5iKpzG9dCRMR9pwtnoBCuv6SEJN5Yph_O8BDuXLVmw8YbBztDtBOKSNmUMnSoleNtYqXD_AQ7KlEO7RKmVRnIcKI/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Verdana, sans-serif;"><img border="0" data-original-height="47" data-original-width="16" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipWXbRK2G8fmaDB7WKlU1nGpAJH3AIM12KFKNavIc1LCrXeRXIttK5iKpzG9dCRMR9pwtnoBCuv6SEJN5Yph_O8BDuXLVmw8YbBztDtBOKSNmUMnSoleNtYqXD_AQ7KlEO7RKmVRnIcKI/s200/Untitled.png" width="67" /></span></a></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;">Sometimes I want to view more than two places in a file at once or the two blocks of code I am looking at are really long, so I would like to see them side by side. For that, I s<span style="background-color: white; color: #555555;">elect from the menu Window => New Window.</span></span><br />
<span style="font-family: Verdana, sans-serif;"><span style="background-color: white; color: #555555;"><br /></span></span>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIkHrDwUMqhj8wO-6vrqcx9EIBkKSe212LwRUKSz_3WcMksUis-AmGTVamGpzdau03FozQB7OKHIpCThIzrIWgxysX3uJ9sySZYR2-Fb2CYO8z16DsZunF6sVbG5cNk2ubLqQTs4FIFvI/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="131" data-original-width="125" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIkHrDwUMqhj8wO-6vrqcx9EIBkKSe212LwRUKSz_3WcMksUis-AmGTVamGpzdau03FozQB7OKHIpCThIzrIWgxysX3uJ9sySZYR2-Fb2CYO8z16DsZunF6sVbG5cNk2ubLqQTs4FIFvI/s1600/Untitled.png" /></a></div>
<span style="font-family: Verdana, sans-serif;"><span style="background-color: white; color: #555555;"><br /></span></span>Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-87965854843959014242018-09-26T14:34:00.001-07:002018-09-26T14:34:02.191-07:00CallerMemberName (C# 5.0 and above)<span style="background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: x-small;">CallerMemberName (C# 5.0 and above)</span><br />
<div style="background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;">
When the CallerMemberName attribute is applied to an argument, the calling method/property/etc name will be supplied. This is useful for snippets, and for implementing non-volatile sections of code without needing to fill-in specifics.</div>
<div style="background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;">
Example:</div>
<div style="background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;">
<span class="m_-7987880372338155532gmail-hljs-keyword" style="box-sizing: inherit; color: #0101fd; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 14px; white-space: pre-wrap;">public</span><span style="background-color: #f9f9f9; color: black; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 14px; white-space: pre-wrap;"> </span><span class="m_-7987880372338155532gmail-hljs-keyword" style="box-sizing: inherit; color: #0101fd; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 14px; white-space: pre-wrap;">event</span><span style="background-color: #f9f9f9; color: black; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 14px; white-space: pre-wrap;"> PropertyChangedEventHandler PropertyChanged;</span> </div>
<div style="background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;">
<span class="m_-7987880372338155532gmail-hljs-keyword" style="box-sizing: inherit; color: #0101fd; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 14px; white-space: pre-wrap;">private</span><span style="color: black; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 14px; white-space: pre-wrap;"> </span><span class="m_-7987880372338155532gmail-hljs-keyword" style="box-sizing: inherit; color: #0101fd; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 14px; white-space: pre-wrap;">void</span><span style="color: black; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 14px; white-space: pre-wrap;"> </span><span class="m_-7987880372338155532gmail-hljs-title" style="box-sizing: inherit; color: #007d9a; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 14px; white-space: pre-wrap;">NotifyPropertyChanged</span><span style="color: black; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 14px; white-space: pre-wrap;">(</span><span class="m_-7987880372338155532gmail-hljs-params" style="box-sizing: inherit; color: black; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 14px; white-space: pre-wrap;">[<wbr></wbr>CallerMemberName] string propertyName = <span class="m_-7987880372338155532gmail-hljs-string" style="box-sizing: inherit; color: #a31515;">""</span></span><span style="color: black; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 14px; white-space: pre-wrap;">) </span></div>
<span class="m_-7987880372338155532gmail-hljs-function" style="background-color: white; box-sizing: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 14px; white-space: pre-wrap;"> </span><span style="background-color: #f9f9f9; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 14px; white-space: pre-wrap;">{
PropertyChanged?.Invoke(</span><span class="m_-7987880372338155532gmail-hljs-keyword" style="background-color: white; box-sizing: inherit; color: #0101fd; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 14px; white-space: pre-wrap;">this</span><span style="background-color: #f9f9f9; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 14px; white-space: pre-wrap;">, </span><span class="m_-7987880372338155532gmail-hljs-keyword" style="background-color: white; box-sizing: inherit; color: #0101fd; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 14px; white-space: pre-wrap;">new</span><span style="background-color: #f9f9f9; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 14px; white-space: pre-wrap;"> PropertyChangedEventArgs(<wbr></wbr>propertyName));
} </span>Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-57013848149676788112016-04-14T12:27:00.000-07:002016-04-14T12:27:27.946-07:00Error When Using Distinct - ORA-01791: not a SELECTed expression<strong>The Problem</strong><br />
I had a query that was working, but when I added a DISTINCT to it started throwing an error. The error I was receiving was ORA-01791: not a SELECTed expression. It didn't give me which field it didn't like, so I was confused.<br />
<br /><br />
<strong>The Solution</strong><br />
What I found was that once DISTINCT was in play all the fields in my ORDER BY had to be in the SELECT. All of the ORDER BY fields had to be fields and not calculations.Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-45186016583951249492016-03-18T10:34:00.000-07:002016-03-18T10:34:17.619-07:00How to insert an ampersand into an Oracle field<br />
I was trying to insert a value into a varchar2 field. The value contained an ampersand. Something like "A&B Home Remodeling". It kept giving me an error like &B was a variable.<br />
<br /><br />
What worked for me was storing it like this:<br />
'A'||'&'||'B'<br />
<br /><br />
It like that much better. I also saw suggestions to chr(38). I did not try that, so I am not sure if it works, but I am guessing it would be very similar to what I did. Something like:<br />
'A'||chr(38)||'B'Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-20454617780690332015-12-16T06:53:00.000-08:002015-12-16T07:37:54.810-08:00Updating a Session Variable With JavaScript<span style="font-family: "verdana" , sans-serif;">Although JavaScript is client side code with an AJAX call you can set or update a session variable on the server when client side code fires.</span><br />
<span style="font-family: "verdana" , sans-serif;"><br /></span><br />
<span style="font-family: "verdana" , sans-serif;">In my case I couldn't do a post back, since I could not have a form on the page, so I needed to do a reload. I still needed the values from the page, which reload does not preserve. Because it is a reload it shouldn't preserve those values, but for my purpose I needed one of them.</span><br />
<span style="font-family: "verdana" , sans-serif;"><br /></span><br />
<span style="font-family: "verdana" , sans-serif;">What I ended up doing was using JQuery to make an AJAX call to a handler page.</span><br />
<span style="font-family: "verdana" , sans-serif;"><br /></span><br />
<span style="font-family: "verdana" , sans-serif;">Once the AJAX call returns then I call the reload. The code looks similar to this:</span><br />
<span style="font-family: "verdana" , sans-serif;"><br /></span><br />
<span style="color: black;"><span style="font-family: "verdana" , sans-serif;"><span style="color: gainsboro;"><span style="color: gainsboro;"><span style="color: gainsboro;"> <span style="color: black;">$</span></span></span></span>.ajax(</span></span><br />
<span style="font-family: "verdana" , sans-serif;"><span style="color: black;">
</span></span><br />
<span style="color: black;"><span style="color: black; font-family: "verdana" , sans-serif;"> {</span></span><br />
<span style="font-family: "verdana" , sans-serif;"><span style="color: black;">
</span></span><br />
<span style="color: black; font-family: "verdana" , sans-serif;"> cache: false,</span><br />
<span style="font-family: "verdana" , sans-serif;"><span style="color: black;">
</span></span><br />
<span style="color: black; font-family: "verdana" , sans-serif;"> url: sURL,</span><br />
<span style="font-family: "verdana" , sans-serif;"><span style="color: black;">
</span></span><br />
<span style="color: black; font-family: "verdana" , sans-serif;"> datatype: "html"</span><br />
<span style="color: black; font-family: "verdana" , sans-serif;">
</span><span style="color: black; font-family: "verdana" , sans-serif;">
</span><br />
<span style="color: black; font-family: "verdana" , sans-serif;"> }).done(function (data) {</span><br />
<span style="font-family: "verdana" , sans-serif;"><span style="color: black;">
</span></span><br />
<span style="color: black; font-family: "verdana" , sans-serif;"> if (data != "") alert(data);</span><br />
<span style="font-family: "verdana" , sans-serif;"><span style="color: black;">
</span></span><br />
<span style="color: black; font-family: "verdana" , sans-serif;"> //alert("Should reload");</span><br />
<span style="font-family: "verdana" , sans-serif;"><span style="color: black;">
</span></span><br />
<span style="color: black; font-family: "verdana" , sans-serif;"> window.location.href = window.location;</span><br />
<span style="font-family: "verdana" , sans-serif;"><span style="color: black;">
</span></span><br />
<span style="color: black; font-family: "verdana" , sans-serif;"> window.location.reload(true);</span><br />
<span style="color: black; font-family: "verdana" , sans-serif;">
</span><span style="color: black; font-family: "verdana" , sans-serif;">
</span><br />
<span style="color: black; font-family: "verdana" , sans-serif;"> })</span><br />
<span style="font-family: "verdana" , sans-serif;"><span style="color: black;">
</span></span><br />
<span style="color: black; font-family: "verdana" , sans-serif;"> .fail(function (xhr, ajaxOptions, thrownError) {</span><br />
<span style="font-family: "verdana" , sans-serif;"><span style="color: black;">
</span></span><br />
<span style="color: black; font-family: "verdana" , sans-serif;"> alert("fail");</span><br />
<span style="font-family: "verdana" , sans-serif;"><span style="color: black;">
</span></span><br />
<span style="color: black; font-family: "verdana" , sans-serif;"> alert(thrownError);</span><br />
<span style="font-family: "verdana" , sans-serif;"><span style="color: black;">
</span></span><br />
<span style="color: black;"><span style="font-family: "verdana" , sans-serif;"><span style="font-family: "verdana" , sans-serif;"> <span style="color: #b4b4b4; font-family: "consolas";"><span style="color: #b4b4b4; font-family: "consolas";"><span style="color: black; font-family: "consolas";">});</span></span></span></span></span></span><br />
<span style="font-family: Consolas;"><br /></span><br />
<span style="font-family: Verdana;">sURL is the address of the handler page. You will need to pass a parameter to the handler page to tell it that you want to call the routine in the handler that sets the session variable. The handler code in ASP.NET with C# would look like this:</span><br />
<span style="font-family: Verdana;"><br /></span><br />
<span style="font-family: Verdana;"></span><span style="font-family: Verdana, sans-serif;">static</span><span style="font-family: Verdana;"><span style="color: black;"><span style="font-family: Verdana, sans-serif;"> HttpContext _context;</span></span></span><br />
<span style="font-family: Verdana;"><br /></span><br />
<span style="font-family: Verdana;"><span style="color: black; font-family: Verdana, sans-serif;">
</span><br />
<span style="color: black; font-family: Verdana, sans-serif;"> public void ProcessRequest(HttpContext context)</span><br />
<span style="color: black; font-family: Verdana, sans-serif;"></span><br />
<span style="color: black; font-family: Verdana, sans-serif;"></span><br />
<span style="color: black; font-family: Verdana, sans-serif;"></span><br />
<span style="color: black; font-family: Verdana, sans-serif;">
</span><br />
<span style="color: black; font-family: Verdana, sans-serif;"> {</span><br />
<span style="color: black; font-family: Verdana, sans-serif;">
</span><br />
<span style="color: black; font-family: Verdana, sans-serif;"></span><br />
<span style="color: black; font-family: Verdana, sans-serif;"></span><br />
<span style="color: black; font-family: Verdana, sans-serif;"> string retval = "";</span><br />
<span style="color: black; font-family: Verdana, sans-serif;">
</span><br />
<span style="color: black; font-family: Verdana, sans-serif;"> _context = context;</span><br />
<span style="color: black; font-family: Verdana, sans-serif;">
</span><br />
<span style="color: black; font-family: Verdana, sans-serif;"> switch (context.Request["method"])</span><br />
<span style="color: black; font-family: Verdana, sans-serif;"></span><br />
<span style="color: black; font-family: Verdana, sans-serif;"></span><br />
<span style="color: black; font-family: Verdana, sans-serif;"></span><br />
<span style="color: black; font-family: Verdana, sans-serif;">
</span><br />
<span style="color: black; font-family: Verdana, sans-serif;"> {</span><br />
<span style="color: black; font-family: Verdana, sans-serif;">
</span><br />
<span style="color: black; font-family: Verdana, sans-serif;"></span><br />
<span style="color: black; font-family: Verdana, sans-serif;"></span><br />
<span style="color: black; font-family: Verdana, sans-serif;"> case "SetSession":</span><br />
<span style="color: black; font-family: Verdana, sans-serif;">
</span><br />
<span style="font-family: Verdana, sans-serif;"><span style="color: black;"> Session[context.Request["SessionVarName"])]</span><span style="color: black;">
= context.Request["SessionValue"])</span></span><br />
<span style="color: black; font-family: Verdana, sans-serif;"> break;</span><br />
<span style="color: black; font-family: Verdana, sans-serif;">
</span><br />
<span style="color: black; font-family: Verdana, sans-serif;"> default:</span><br />
<span style="color: black; font-family: Verdana, sans-serif;">
</span><br />
<span style="color: black; font-family: Verdana, sans-serif;"> context.Response.ContentType = "text/plain";</span><br />
<span style="color: black; font-family: Verdana, sans-serif;">
</span><br />
<span style="color: black; font-family: Verdana, sans-serif;"> retval = "Invalid method specified";</span><br />
<span style="color: black; font-family: Verdana, sans-serif;">
</span><br />
<span style="color: black; font-family: Verdana, sans-serif;"> break;</span><br />
<span style="color: black; font-family: Verdana, sans-serif;"></span><br />
<span style="color: black; font-family: Verdana, sans-serif;"></span><br />
<span style="color: black; font-family: Verdana, sans-serif;"></span><br />
<span style="color: black; font-family: Verdana, sans-serif;">
</span><br />
<span style="color: black; font-family: Verdana, sans-serif;"> }</span><br />
<span style="color: black; font-family: Verdana, sans-serif;">
</span><br />
<span style="color: black; font-family: Verdana, sans-serif;"></span><br />
<span style="color: black; font-family: Verdana, sans-serif;"></span><br />
<span style="color: black; font-family: Verdana, sans-serif;"> context.Response.Write(retval);</span><br />
<span style="color: black; font-family: Verdana, sans-serif;"></span><br />
<span style="font-family: Consolas; font-size: xx-small;"><span style="color: black; font-family: Verdana, sans-serif; font-size: small;"></span><br />
<span style="font-family: Consolas; font-size: xx-small;"><span style="color: black; font-family: Verdana, sans-serif; font-size: small;"></span><br />
<span style="font-family: Consolas; font-size: xx-small;"><span style="color: black; font-family: Verdana, sans-serif; font-size: small;">
</span><br />
<span style="color: black; font-family: Verdana, sans-serif; font-size: small;"> }</span><br />
<span style="color: black;">
</span></span><span style="color: black;"></span><br /></span><span style="color: black;"></span><br /></span><span style="color: black;"><span style="font-family: Consolas; font-size: xx-small;"><span style="font-family: Consolas; font-size: xx-small;"><span style="font-family: Consolas; font-size: xx-small;"> </span></span></span></span><br />
<span style="color: gainsboro; font-family: Consolas; font-size: xx-small;"><br /><br />
<span style="color: gainsboro; font-family: Consolas; font-size: xx-small;"><br /><br />
<span style="color: gainsboro; font-family: Consolas; font-size: xx-small;"><br /><br />
<br /><br />
<br /></span><br /></span><br /></span><br /></span><br />Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-43539908559051133062015-11-10T13:19:00.002-08:002015-11-10T13:19:45.200-08:00Oracle Scheduled Jobs<b style="font-weight: normal;"><div dir="ltr" id="docs-internal-guid-cd41e193-f33c-3148-cdf7-7fc9311ef0b6" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">TO CREATE A JOB:</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;"></span><br /></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">Begin</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;"> Dbms_scheduler.Create_job (</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;"> </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">Job_name => 'RUN_JOB_TO_RUN',</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;"> </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">Job_type => 'PLSQL_BLOCK',</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;"> </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">Job_action => 'BEGIN JOB_TO_RUN(); END;',</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;"> </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">Start_date => To_timestamp_tz('10-NOV-2015 13:00:00','DD-MM-YYYY HH24:MI:SS'),</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;"> </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">Repeat_interval => 'FREQ = DAILY; BYHOUR=13',</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;"> </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">comments => 'Some job to run.',</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;"> </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">Enabled => True);</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">End;</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;"><br /></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;"></span><br /></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">TO UPDATE A JOB:</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;"></span><br /></div>
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;"><b style="font-weight: normal;"><div dir="ltr" id="docs-internal-guid-cd41e193-f344-1b03-5652-9dfe4bce05c9" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">begin</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">Dbms_scheduler.Set_attribute</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;"> ( name => 'RUN_JOB_TO_RUN'</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;"> , Attribute =>'REPEAT_INTERVAL'</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;"> , value =>'FREQ=DAILY; BYHOUR=2');</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.66px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">End;</span></div>
</b><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<br /></div>
</span><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<br /></div>
</b><br />Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-56012419459683168682015-09-24T08:41:00.000-07:002015-09-24T08:41:46.639-07:00Format Strings to Use a Percent Sign (%) Without the Formatter Multiplying the Value by 100I had an application that needed to display a value with a percent sign (%) after it. The value had already been converted from decimal to integer, or in other words had already been multiplied by 100. I did not have the option to just append a % at the end of the string. All the object gave me access to was the format. I tried "#0%", which gave me what I wanted, except that it multiplied the value by 100, so 20% became 2000%.<br /><br />After a little research I found that using an escape character gave me what I wanted.<br /><br />ToString("#0\\%")<br />
<br />Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-64767202523751036582015-09-09T17:42:00.002-07:002015-09-09T17:42:38.481-07:00C# Equivalent of DoEventsI have been looking for a long time for an equivalent to Visual Basic's DoEvents statement.<br />
<br />
DoEvents allows your code to yield execution to other threads in order to share processing time. This could be do in a loop to allow you to process an iteration of the loop and when done yield. This is often done to attempt to keep the UI responsive. After each iteration you would call DoEvents thus allowing the UI some processing time.<br />
<br />
I was studying today about multi threading and asynchronous processing when I came across some code that did a loop and called Thread.Sleep(0) at the end of each iteration. Supposedly this yields execution without causing the loop to execute longer, since the sleep is for zero milliseconds. Since the thread goes to sleep, other threads can then take over and release control when it is done.<br />
<br />
I think you can use DoEvents in C# by using the the Visual Basic library, but from what I have seen people saying that is not recommended. This is why I have been looking for a native C# method of doing this.<br />
<br />
Visual Basic<br />
<pre style="font-family: Consolas, Courier, monospace !important; font-size: 13px; line-height: 17.55px; overflow: auto; padding: 5px; word-wrap: normal;"> <span style="color: blue;">For</span> <span style="color: blue;">Each</span> file <span style="color: blue;">In</span> files
<span style="line-height: 17.55px;"> </span>DoFileStuff()</pre>
<pre style="font-family: Consolas, Courier, monospace !important; font-size: 13px; line-height: 17.55px; overflow: auto; padding: 5px; word-wrap: normal;"> Application.DoEvents()
<span style="color: blue;">Next</span></pre>
<br />This is useful if DoFileStuff() updates the UI. DoEvents() would then let go of control, so the UI could take a turn and refresh itself.<div>
<br /></div>
<div>
C#</div>
<div>
<pre style="font-family: Consolas, Courier, monospace !important; font-size: 13px; line-height: 17.55px; overflow: auto; padding: 5px; word-wrap: normal;"> <span style="color: blue;">foreach</span> (<span class="kwd" style="background-color: #eeeeee; border: 0px; color: darkblue; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; line-height: 17.55px; margin: 0px; padding: 0px; white-space: inherit;">var</span><span class="pln" style="background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; line-height: 17.55px; margin: 0px; padding: 0px; white-space: inherit;"> file in files</span><span style="line-height: 17.55px;">)</span>
{
<pre style="font-family: Consolas, Courier, monospace !important; line-height: 17.55px; overflow: auto; padding: 5px; word-wrap: normal;"><span style="line-height: 17.55px;"> </span>DoFileStuff();</pre>
<pre style="font-family: Consolas, Courier, monospace !important; line-height: 17.55px; overflow: auto; padding: 5px; word-wrap: normal;"> Thread.Sleep(0);</pre>
}</pre>
The thread goes to sleep and immediately wakes up ready to be scheduled for execution when it is its turn again.</div>
Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-89661595714622350392015-01-24T09:38:00.000-08:002015-01-24T09:38:29.723-08:00HttpContext.Current Null in Asynchronous MethodsI created a page that had some logic to dynamically create the page. It was doing a lot of fetches from the database and then calculating how to display each batch of data that was retrieved. The page became slow.<br />
<br />
To speed it up I converted the most time intensive loop to a parallel for each. Inside the loop it was using HttpContext.Current. Once I made the loop Parallel HttpContext.Current was null inside things called inside the loop..<br />
<br />
It appears that if you leave the main thread of execution it no longer has a reference to the current context.<br />
<br />
I found that HttpContext.Current can be set as well as read. Outside the parallel loop I captured HttpContext.Current in a local variable. I then accessed the variable in the loop. The other things I was calling inside the parallel for each needed HttpContext.Current, so I set HttpContext.Current to the local variable. The other methods were able to read HttpContext.Current as long as they were on the same thread as the calling method.Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-56823120805141891372014-11-25T13:40:00.002-08:002014-11-25T13:40:39.846-08:00Making a DIV Dynamically Adjust to the Size of the Content and Not Fill the Entire ParentI had created an HTML table with three cells (td). The first cell was 20% of the whole the second 60% and the third 20%. In the second cell I place a div. I needed the div to not fill the entire cell, but stretch or shrink based on how much content is in it. The following code is what I started with. The div would fill the cell, even if empty.<br /><br />table><br /> tr><br /> td style="width: 20%"><br /><br />/td><br />td style="width: 60%;text-align:center;"><br /> div id="divMiddleCell"><br /><br /> Dynamic Content<br /><br /> /div><br /><br />/td><br />/tr><br />/table><br /><br />I altered it as follows to add display: inline-block tot he style property of the div and it made the div dynamically shrink and grow.<br />
<br /><br />
table><br />tr><br /> td style="width: 20%"><br /><br /> /td><br /> td style="width: 60%;text-align:center;display: inline-block"><br /> div id="divMiddleCell" "><br /><br /> Dynamic Content<br /><br /> /div><br /><br />/td><br />/tr><br />/table><br />
<span style="color: grey; font-family: Consolas; font-size: x-small;"><br /><br />
<span style="color: black;"><span style="color: black;"><span style="color: #c8c8c8; font-family: Consolas; font-size: x-small;"><span style="color: #c8c8c8; font-family: Consolas; font-size: x-small;"><span style="color: #c8c8c8; font-family: Consolas; font-size: x-small;"></span></span></span></span></span><br /></span>Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-88525117322407606822014-03-13T17:45:00.000-07:002014-03-13T17:45:20.023-07:00How to do Select Top in OracleIn SQL Server I often do a SELECT TOP 10 FROM [TableName].<br />
<br />
To get the bottom ten I found that I could ORDER BY DESC.<br />
<br />
In Oracle things are a bit different. In Oracle they have a ROWNUM system field. To get the first ten records you just have to get the ROWNUMs that are 10 and below like the following: <br />
<br />
SELECT * FROM [TableName] WHERE ROWNUM >= 11 Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-69990029039983181792014-03-13T17:39:00.001-07:002014-03-13T17:39:58.751-07:00Control 'gv' of type 'GridView' must be placed inside a form tag with runat=server.<span style="font-family: Arial;"><br /></span>
<span style="font-family: Arial;"><br /></span>
<span style="font-family: Arial;">I have gotten this error several times:</span><br />
<span style="font-family: Arial;"><br /></span>
<span style="font-family: Arial;">Control 'gv' of type 'GridView' must be placed inside a form tag with runat=server.</span><br />
<span style="font-family: Arial;"></span><br />
<span style="font-family: Arial;">Each time I forget the solution and after I fix it I eventually forget why I was getting it. This time is not different. I can't remember why it started happening, but the solution is to create a method like this.</span><br />
<br />
<span style="color: gainsboro; font-family: Consolas; font-size: x-small;"><span style="color: gainsboro; font-family: Consolas; font-size: x-small;"><span style="color: gainsboro; font-family: Consolas; font-size: x-small;"> </span></span></span><span style="color: black;"><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">public</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">override</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">void</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">VerifyRenderingInServerForm</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">(</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">Control</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">control</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">)</span></span></span></span><br />
<span style="color: black;"></span><br />
<span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="color: black;">{</span><br />
</span></span></span><span style="color: black;"><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">/* Verifies that the control is rendered */</span></span></span></span><br />
<span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: x-small;">
</span></span></span>
<span style="color: gainsboro; font-family: Consolas; font-size: x-small;"><span style="color: gainsboro; font-family: Consolas; font-size: x-small;"><span style="color: gainsboro; font-family: Consolas; font-size: x-small;"><span style="color: black;">}</span></span></span></span>Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-24230388043373288102014-03-13T13:57:00.001-07:002014-03-13T13:57:57.509-07:00Sometimes & nbsp; Doesn't Work and I Have to Use & #160; InsteadI found recently that sometimes when I use an HTML & nbsp; it literally prints & nbsp; instead of a nonbreaking space.<br />
<br />
Blogger is having trouble taking what I want to say, so I have to put a space between the ampersand and the nbsp; characters to get it to print correctly.<br />
<br />
One instance that gave me trouble with the nbsp was between a td tag, even though I can include other HTML markup in between the opening and closing tag.<br />
<br />
After some head scratching and reading I tried using a & #160; and that worked.<br />
<br />
I guess HTML has two different ways of expressing non breaking spaces.Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-49891016190046088112014-02-06T08:05:00.000-08:002014-02-06T08:05:20.640-08:00ASP.Net Web Forms Application Can't Find NamespaceI was creating a test Web Forms application and added some existing code files.<br />
<br />
I first added them to the app_code folder, but in there they could not find the OracleDataClient namespace. I found something that said to move the code file out of app_code and that fixed the Oracle problem.<br />
<br />
Then when I would reference classes in those files the page code did not recognize the namespace.<br />
<br />
After a while of searching I found someone who said to right click on the files and view properties.<br />
<br />
The property they said to look at was Build Action. My file was set to Content and I saw to change it to Compile. That fixed it.<br />
<br />
<br />Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-55620272683043352852014-01-15T19:27:00.001-08:002014-01-15T19:27:51.553-08:00DataReader Problems Boxing and UnboxingAfter I researched the problems and implemented the solutions in this post <a href="http://brookssoftwaredev.blogspot.com/2014/01/net-datareader-not-closing-connection.html">http://brookssoftwaredev.blogspot.com/2014/01/net-datareader-not-closing-connection.html</a> I found that I was still getting timeouts while trying to obtain a connection from the pool.<br />
<br />
I researched more and found that doing normal conversion like<br />
<br />
int.Parse(reader["FieldName"]);<br />
<br />
caused boxing and unboxing of the values. I was doing this on several values for many records.<br />
<br />
I did some research and found that the boxing and unboxing causes the garbage collector to bog down. I found that the DataReader has special methods to avoid the boxing and unboxing. These methods are things like <span style="background-color: white; color: #333333; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 13px;">GetChar</span><span style="background-color: white; color: #333333; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 13px;">, </span><span style="background-color: white; color: #333333; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 13px;">GetDouble</span><span style="background-color: white; color: #333333; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 13px;">, GetDateTime, and </span><span style="background-color: white; color: #333333; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 13px;">GetInt32. From what I read these stop the boxing and unboxing and prevent the garbage collector from thrashing.</span><br />
<span style="background-color: white; color: #333333; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 13px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 13px;">Once I implemented those methods my timeouts on the connection pool went away. It appears as though the garbage collector couldn't clean up the connections, since it was busy with all of the rogue objected from the DataReader boxing and unboxing.</span><br />
<span style="background-color: white; color: #333333; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 13px;"><br /></span>
<span style="color: #333333; font-family: Segoe UI, Arial, Verdana, Tahoma, sans-serif; font-size: x-small;">I realized that using a DataReader left the connection open and there needed to be precautions taken, but there are several other things that you must deal with when using a DataReader, so use caution.</span>Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-28159501704900464442014-01-11T14:22:00.001-08:002014-01-11T14:22:36.275-08:00.Net DataReader Not Closing Connection After Closed<span style="background-color: white; font-family: Verdana, sans-serif;">As I research using the .Net DataReader I kept seeing information online that said things like "<span style="line-height: 18px;">When the command is executed, the associated Connection object is closed when the associated DataReader object is closed."</span></span><br />
<span style="background-color: white; line-height: 18px;"><span style="font-family: Verdana, sans-serif;"><br /></span></span>
<span style="background-color: white; line-height: 18px;"><span style="font-family: Verdana, sans-serif;">There had been concerns that the data reader would tie up the connection too long. There was also concern that we were closing the connection explicitly, especially since the creation of the reader was abstracted into another class. The class using the reader would not have access to the command or connection that created it.</span></span><br />
<span style="background-color: white; line-height: 18px;"><span style="font-family: Verdana, sans-serif;"><br /></span></span>
<span style="background-color: white; line-height: 18px;"><span style="font-family: Verdana, sans-serif;">In various different places I have worked we have used this and were confident that the DataReader would clean itself and its connection up, based upon what we had read.</span></span><br />
<span style="background-color: white; line-height: 18px;"><span style="font-family: Verdana, sans-serif;"><br /></span></span>
<span style="background-color: white; font-family: Verdana, sans-serif;"><span style="line-height: 18px;">We did a small test page recently and i</span><span style="line-height: 18px;">t turns out that by default it leaves the connection open.</span></span><br />
<span style="background-color: white; line-height: 18px;"><span style="font-family: Verdana, sans-serif;"><br /></span></span>
<span style="background-color: white; font-family: Verdana, sans-serif;"><span style="line-height: 18px;">We opened a connection and created a command tied to that connection and then used that command to create a DataReader. We did </span><span style="line-height: 16px;">command</span><span style="line-height: 16px;">.ExecuteReader() to create the reader.</span></span><br />
<span style="background-color: white; line-height: 16px;"><span style="font-family: Verdana, sans-serif;"><br /></span></span>
<span style="background-color: white; font-family: Verdana, sans-serif;"><span style="line-height: 16px;">As we researched further we found that ExecuteReader has an optional parameter of a </span><span style="line-height: 17px;">CommandBehavior enumeration. If you pass </span><span style="line-height: 17px;">CommandBehavior.CloseConnection then it closes the connection when the reader closes.</span></span><br />
<span style="font-family: Arial, Liberation Sans, DejaVu Sans, sans-serif;"><span style="font-size: 14px; line-height: 18px;"><br /></span></span>
<br />Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-4214094747247380712013-09-26T21:05:00.000-07:002013-09-26T21:05:35.788-07:00Dynamically Created Control Not Firing Events in ASP.NetI have an aspx page where when someone changes the value in a Drop Down List the database is queried and records are displayed in an HTML table. As the table is created I add a Button control to each row. I have tried this with a CheckBox as well with similar results. I also wire up a click event for each button when it is created. All the events for the Buttons point to the same event.<br />
<br />
The grid is created properly, with the button on each line. When I click one of the buttons the Page_Load event fires, but the click event does not.<br />
<br />
When I dynamically create a button outside the grid from the Drop Down List's SelectedIndexChanged event it also does not fire the click event.<br />
<br />
When I move the button creation code to the Page_Load event wrapped in an If (!IsPostback) block the Click event works properly.<br />
<br />
It appears that if the control is not created in Form_Load or Form_Init the dynamic control's events do not fire. I have not found a solution to be able to do what I want, but I thought what I found in my research so far might be useful to someone.Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-33881347793188270362013-08-05T13:58:00.000-07:002013-08-14T10:37:23.293-07:00How to Get SQL Report Services Report Built With Report Builder to Display No Page Breaks on Screen, But Still Break When Printed<span style="background-color: white; color: #333333; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px;">I created a report with Report Builder 3. My users are us to seeing reports displayed on screen with no page breaks. It looks like the default is to have page breaks. </span><span style="background-color: white; color: #333333; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px;">I found that in the report properties there are a couple of properties to manage page breaks.</span><br />
<span style="background-color: white; color: #333333; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px;">In Report Builder, right click outside the report body and click Report Properties. In the properties window there is a page section when you have it sorted by property category. In that section there is a property called InterActiveSize. If you set the height and the width of this property both to be 0 the report is displayed on screen in one long page with no breaks.</span><br />
<span style="background-color: white; color: #333333; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px;">The other property is PageSize. This has to do with the printed page. It is right below the margin property where you can control margins. I think this only controls them for the printed page.</span>Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-90122474587609758442013-08-02T06:54:00.002-07:002013-08-02T06:54:51.623-07:00Data Bound GridView and Asp.Net Ajax UpdatePanelI tried loading a couple of grids through an update panel with a timer to try to get the rest of the page to display to the user quickly and do the heavy lifting of these two grids in the background.<br />
<br />
I wrapped the two grids in an update panel and added a timer. I put code in the tick event of the timer. I loaded the page and it came up quickly and moments later the grids filled in. Moments after that all of my dynamic data i have created with template fields was erased. The main data that was being bound was still there.<br />
<br />
As I researched it I found that the RowCreated event was firing repeatedly. I viewed the call stack and saw that it was being fired by system code that I could not see and not by my code.<br />
<br />
I tried using session variables to get it to routed around the multiple calls, but the damage was being done before it got to the RowCreated event. The event also was getting null values for ID fields I was using to populate the grid correctly, which is why the dynamic data was not being displayed.<br />
<br />
I did a couple of hours of research, but found nothing specific to my problem, but I did start stumbling upon two properties of the update panel, ChildrenAsTriggers and UpdateMode. Honestly I don't entirely understand UpdateMode yet, but ChildrenAsTriggers got me thinking that maybe the grid was triggering a refresh of its own somehow after I got everything set the way I wanted it.<br />
<br />
I set ChildrenAsTriggers="false". It required that I have UpdateMode="Conditional". I think this also required that I have an explicit Trigger tag for the update panel that was set to the Tick event of my timer.<br />
<br />
After all that, it appears to be working.Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-2640739832233865462013-06-28T13:42:00.001-07:002013-06-28T13:42:26.862-07:00IIS Routing and Paths With 404 in ThemWe had a problem today with a path routing. We had a path similar to this http://localhost:54612/mydir/invoice/40414<br />
<br />
It appeared that this path was never getting to the code, but being bounced back by IIS. The URL http://localhost:54612/mydir/40399 worked just fine.<br />
<br />
After further research we found that it was number at the end with 404 in it that was breaking us. http://localhost:54612/mydir/30404 also broke.<br />
<br />
The code we were using was<br />
<br />
RouteTable.Routes.Add(new RegexRoute(@"^/mydir/invoice/(?<id>\d+)/?$", new PathRouteHandler("~/myotherdir/file.aspx")));</id><br />
<br />
Once we changed it to<br />
<br />
RouteTable.Routes.Add(new Route(@"mydir/invoice", new PathRouteHandler("~/myotherdir/file.aspx")));<br />
<br />
it worked.<br />
<br />
We had to change the catching code to check the query string instead of the route path, but it worked.<br />
<br />
We have yet to discover why it was behaving badly with invoice numbers containing 404. I would love to read your thoughts if you have run across such a thing.Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-71428629337490735462013-04-12T15:18:00.001-07:002013-04-12T15:18:07.048-07:00There is already an open DataReader associated with this Command which must be closed first<span style="font-family: Verdana, sans-serif;">Every so often in our ASP.Net website we would get the error, "</span><span style="background-color: white; font-family: Verdana, sans-serif; line-height: 1.3;">There is already an open DataReader associated with this Command which must be closed first</span><span style="background-color: white; font-family: Verdana, sans-serif; line-height: 1.3;">" referring to a SqlDataReader. We would tweak code here and there and get it to go away. Later another code tweak would bring it back. We have no idea what is causing it. </span><br />
<h1 itemprop="name" style="background-color: white; border: 0px; line-height: 1.3; margin: 0px 0px 7px; padding: 0px; vertical-align: baseline;">
<span style="font-family: Verdana, sans-serif; font-size: small; font-weight: normal;"><br /></span></h1>
<h1 itemprop="name" style="background-color: white; border: 0px; line-height: 1.3; margin: 0px 0px 7px; padding: 0px; vertical-align: baseline;">
<span style="font-family: Verdana, sans-serif; font-size: small; font-weight: normal;">It is in a block of code that creates a SQLCommand, creates a SQLDataReader, and destroys the <span style="line-height: 1.3;">SQLDataReader and </span><span style="line-height: 1.3;">SQLCommand. We are not sure how it is possible that another reader is executing on that command.</span></span></h1>
<div>
<span style="font-family: Verdana, sans-serif; font-size: small;"><span style="line-height: 1.3;"><br /></span></span></div>
<h1 itemprop="name" style="background-color: white; border: 0px; line-height: 1.3; margin: 0px 0px 7px; padding: 0px; vertical-align: baseline;">
<span style="font-family: Verdana, sans-serif; font-size: small; font-weight: normal;">As a work around until we can find the issue we have added this attribute</span></h1>
<h1 itemprop="name" style="background-color: white; border: 0px; margin: 0px 0px 7px; padding: 0px; vertical-align: baseline;">
<span style="font-weight: normal; line-height: 26.363636016845703px;"><span style="font-family: Verdana, sans-serif; font-size: small;">MultipleActiveResultSets=True</span></span></h1>
<h1 itemprop="name" style="background-color: white; border: 0px; line-height: 1.3; margin: 0px 0px 7px; padding: 0px; vertical-align: baseline;">
<span style="font-family: Verdana, sans-serif; font-size: small; font-weight: normal;">to our connection string and it has seemed to have bypassed the problem. I know it likely causes other problems, but due to the environment we work it that's what we have to do.</span></h1>
Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-91770214484635499402013-04-12T13:47:00.002-07:002013-04-12T13:47:26.926-07:00Installing Spring...<img height="299" src="https://sphotos-b.xx.fbcdn.net/hphotos-ash3/547841_4559605629175_497659703_n.jpg" width="400" /><br />
<br />
Installing Spring...<br />
<br />
50% ready...<br />
<br />
! Installation failed. Error 404 Spring not found. Spring is not available in your state. Please try Florida.Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-65992373171778056972013-04-12T12:20:00.002-07:002013-04-16T12:52:32.305-07:00ReportViewer Control ASP.Net Disabled When Routing<span style="font-family: Verdana, sans-serif;">I was experimenting with possibly using Microsoft's Report Builder tool to create reports and then use the ReportViewer WebForms control to display them on a web page.</span><br />
<div>
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Verdana, sans-serif;">When I would create a small test site everything was great. When I would add a report to our existing site it would show me a disabled ReportViewer task bar and no data from the report.</span></div>
<div>
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Verdana, sans-serif;">It took me forever to figure out why this was happening and longer to track down solutions.</span></div>
<div>
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Verdana, sans-serif;">Everywhere I went I saw people saying that it was something in my web config. They sited that SQL Server 6 needed a different section in the web config than SQL Server 7 needs. I saw that my web config had both and at one point I removed the older declaration and things started to work.</span></div>
<div>
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Verdana, sans-serif;">Then it happened. The other day I was adding controls and experimenting with the page and all of a sudden I was back to square one. I did ctrl-Z until I had removed all the changes I had been making on the page and got everything back to the way they were in code. It didn't fix the display of the page.</span></div>
<div>
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Verdana, sans-serif;">This was horrible. I was so close to delivering something and I had even told my superiors it was just about done and now I was stuck with a broken page I had no idea how to fix. Nothing logically made sense.</span></div>
<div>
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Verdana, sans-serif;">I knew that one of the big differences with our site and a quick and dirty site with one page was routing. We have a file filled with different routings. I decided I would try disabling them and see what happened. Sure enough it worked. The problem was that the rest of the site was broken without the routings being turned on.</span></div>
<div>
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Verdana, sans-serif;">I searched and searched and kept finding the same old things about the web config. Then I found a block of code like this.</span></div>
<div>
<br /></div>
<div>
<pre class="code" style="background-color: #f8f8ec; clear: both; color: #151515; line-height: 16px; max-width: 810px; overflow: auto; padding: 10px; text-align: justify;"><span style="color: blue;"> <</span><span style="color: #a31515;">handlers</span><span style="color: blue;">>
<</span><span style="color: #a31515;">remove </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">WebServiceHandlerFactory-Integrated</span>"<span style="color: blue;">/>
<</span><span style="color: #a31515;">remove </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">ScriptHandlerFactory</span>"<span style="color: blue;">/>
<</span><span style="color: #a31515;">remove </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">ScriptHandlerFactoryAppServices</span>"<span style="color: blue;">/>
<</span><span style="color: #a31515;">remove </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">ScriptResource</span>"<span style="color: blue;">/>
<strong> <</strong></span><strong><span style="color: #a31515;">add </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">: Reserved-ReportViewerWebControl-axd</span>" <span style="color: red;">path</span><span style="color: blue;">=</span>"<span style="color: blue;">Reserved.ReportViewerWebControl.axd</span>" <span style="color: red;">verb</span><span style="color: blue;">=</span>"<span style="color: blue;">*</span>" <span style="color: red;">type</span><span style="color: blue;">=</span>"<span style="color: blue;">Microsoft.Reporting.WebForms.HttpHandler</span>" <span style="color: red;">resourceType</span><span style="color: blue;">=</span>"<span style="color: blue;">Unspecified</span>" <span style="color: red;">preCondition</span><span style="color: blue;">=</span>"<span style="color: blue;">integratedMode</span>" </strong><span style="color: blue;"><strong>/>
</strong> <</span><span style="color: #a31515;">add </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">ScriptHandlerFactory</span>" <span style="color: red;">verb</span><span style="color: blue;">=</span>"<span style="color: blue;">*</span>" <span style="color: red;">path</span><span style="color: blue;">=</span>"<span style="color: blue;">*.asmx</span>" <span style="color: red;">preCondition</span><span style="color: blue;">=</span>"<span style="color: blue;">integratedMode</span>" <span style="color: red;">type</span><span style="color: blue;">=</span>"<span style="color: blue;">System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35</span>"<span style="color: blue;">/>
<</span><span style="color: #a31515;">add </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">ScriptHandlerFactoryAppServices</span>" <span style="color: red;">verb</span><span style="color: blue;">=</span>"<span style="color: blue;">*</span>" <span style="color: red;">path</span><span style="color: blue;">=</span>"<span style="color: blue;">*_AppService.axd</span>" <span style="color: red;">preCondition</span><span style="color: blue;">=</span>"<span style="color: blue;">integratedMode</span>" <span style="color: red;">type</span><span style="color: blue;">=</span>"<span style="color: blue;">System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35</span>"<span style="color: blue;">/>
<</span><span style="color: #a31515;">add </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">ScriptResource</span>" <span style="color: red;">preCondition</span><span style="color: blue;">=</span>"<span style="color: blue;">integratedMode</span>" <span style="color: red;">verb</span><span style="color: blue;">=</span>"<span style="color: blue;">GET,HEAD</span>" <span style="color: red;">path</span><span style="color: blue;">=</span>"<span style="color: blue;">ScriptResource.axd</span>" <span style="color: red;">type</span><span style="color: blue;">=</span>"<span style="color: blue;">System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35</span>"<span style="color: blue;">/>
<</span><span style="color: #a31515;">add </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">UrlRoutingHandler</span>" <span style="color: red;">preCondition</span><span style="color: blue;">=</span>"<span style="color: blue;">integratedMode</span>" <span style="color: red;">verb</span><span style="color: blue;">=</span>"<span style="color: blue;">*</span>" <span style="color: red;">path</span><span style="color: blue;">=</span>"<span style="color: blue;">UrlRouting.axd</span>" <span style="color: red;">type</span><span style="color: blue;">=</span>"<span style="color: blue;">System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</span>"<span style="color: blue;">/>
</</span><span style="color: #a31515;">handlers</span><span style="color: blue;">></span></pre>
<span style="font-family: Verdana, sans-serif;">This is much like the web config stuff I had seen elsewhere, but it had a bunch of other stuff around it. I have no idea if they relate, but I plugged them all in wholesale and decided I would yank out what didn't compile.<br />I also noticed that the line starting with <add name=": Reserved-ReportViewerWebControl-axd" had more attributes assigned than what the ones in my code had.</span></div>
<div>
<span style="font-family: Verdana, sans-serif;"><br />Everything worked. No compile errors. The control displayed the report and was not disabled.</span></div>
<div>
<span style="font-family: Verdana, sans-serif;"><br />I had no time to figure out if it was the extra attributes or the extra lines of code. All I know is it works. I hope this post will help someone else climb out of what they are struggling with because this was horrendously frustrating.</span></div>
<div>
<span style="font-family: Verdana, sans-serif;"><br />Update:<br />After adding all that and getting ready to deploy, I moved the site to a different location on the same machine. Not even a different machine. The original location continued to work fine, but the new location gave the disable ReportViewer control. I searched and search again.</span></div>
<div>
<span style="font-family: Verdana, sans-serif;"><br />When I had the problem previously I tried disabling routing for the control with the follow 2 lines of code:</span><pre class="code" style="clear: both; max-width: 810px; overflow: auto; padding: 10px;"><span style="color: blue;"><span style="background-color: #f8f8ec; line-height: 16px;">RouteTable.Routes.Add(new Route("{resource}.axd/{*pathInfo}", new StopRoutingHandler()));
RouteTable.Routes.Ignore("{resource}.axd/{*pathInfo}");</span></span>
</pre>
<span style="font-family: Verdana, sans-serif;">Neither worked. When I ran into the problem again I seemed to recall one post saying that the order of routes mattered. Previously I had tried to remove the routes with these lines at the end of all the routing, thinking it would remove whatever got added. It appears that it is the opposite. If you tell it not to route from the start then nothing gets applied to it in the other routes.</span></div>
<div>
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Verdana, sans-serif;">I moved the lines to the top of the routing code and tested each line. I found that either of them worked.</span></div>
Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-37458940662461970112013-03-25T07:29:00.001-07:002013-03-25T07:29:12.285-07:00Abstract Class vs Interface<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;">Conceptually, abstract classes are very similar to interfaces with a few differences. One way to think of the two is like this: </span><span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 12px;"> An abstract class can be defined as "Is a". An interface can be defined as "Can do".</span><br />
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 12px;"><br /></span>
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 12px;">When you create an abstract class you are creating a thing that something else would be. For example, "car" could be an abstract class and everything that inherits from it is a car. When you create an interface you are defining what something can do. If you define an interface of "drive", anything that implements that is saying that their object can drive. The interface doesn't say how to drive it just says your object needs to be able to drive and it defines what things something can do to be able to drive, just not how they do it.</span><br />
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;"><br /></span>
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;"><b>Interface</b></span><br />
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;">Interfaces cannot implement method implementations. They can contain abstract methods.</span><br />
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;"><br /></span>
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;">An abstract method defines a method signature (types of parameters it takes and the type it returns), but does not define the implementation or how the method does what it does. The implementation will be coded in the class that uses the interface. Many classes can use an interface and each of them may implement a certain method of the interface entirely different.</span><br />
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;"><br /></span>
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;">Interfaces do not have constructors or destructors (special methods that fire upon creation or disposal of an object to allow the class to initialize things or clean up things)</span><br />
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;"><br /></span>
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;">A class can implement multiple interfaces.</span><br />
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;"><br /></span>
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;">An interface is sometimes called a contract or promise.</span><br />
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;"><br /></span>
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;">An interface cannot extend classes, but they can extend other interfaces.</span><br />
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;"><br /></span>
<br />
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;">Interfaces can be used as bridges across classes inherited from different base classes. They can also be used to make it easier for third parties to communicate with your classes. </span><br />
<div>
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;"><br /></span></div>
<br />
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;"><br /></span>
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;"><b>Abstract Class</b></span><br />
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;">Abstract classes must contain at least one abstract method. Abstract classes can also contain concrete methods or methods that already have an implementation defined.</span><br />
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;"><br /></span>
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;">Just like any other class abstract classes contain constructors and destructors.</span><br />
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;"><br /></span>
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;">A class can not inherit from multiple classes, not even multiple abstract classes.</span><br />
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;"><br /></span>
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;">Abstract classes cannot be instantiated directly. They must be inherited from and then the class that inherits from them can be implemented. </span><span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;">The abstract keyword indicates that the class is defined for inheritance. </span><br />
<br style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;" />
To create an abstract class you use the abstract keyword:<br />
<br />
<br />
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;">public abstract class MyAbstractClass {}</span><br />
<br />
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;"><br /></span>
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;">Abstract classes can use interfaces, but every class that inherits from the abstract class will be bound by the interface, which means they must implement every method and property in the interface.</span><br />
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;"><br /></span>
<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 15px;">An abstract class is used for creating a class hierarchy. </span><br />
<div class="MsoNormal" style="background-color: white; color: #5d5d5d; font-family: Calibri; font-size: 15px; line-height: 21px; margin-bottom: 0.0001pt;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
</div>
Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0tag:blogger.com,1999:blog-4701870474877595673.post-83652080226188144172013-03-22T19:41:00.000-07:002013-03-25T10:40:59.351-07:00Array vs ArrayList vs Generic List vs LinkedList in .Net<b><span style="background-color: white; font-family: Verdana, sans-serif;">Array vs ArrayList vs Generic List<t> vs LinkedList<t> in .Net</t></t></span></b><br />
<span style="background-color: white; font-family: Verdana, sans-serif;"><br />
<b>Arrays</b></span><br />
<span style="background-color: white; font-family: Verdana, sans-serif;">Arrays cannot shrink or grow unless you copy the array to an entirely new array of a different size. Once the size of an array is declared that is the size it must remain without heavy overhead.</span><br />
<span style="background-color: white; font-family: Verdana, sans-serif;"><br />
Arrays can contain objects or primitives.</span><br />
<div>
<span style="background-color: white; font-family: Verdana, sans-serif;"><br /></span></div>
<div>
<b><span style="background-color: white; font-family: Verdana, sans-serif;">ArrayLists</span></b></div>
<div>
<span style="background-color: white; font-family: Verdana, sans-serif;">An ArrayList uses a dynamically expanding Array internally, so there can be a performance hit when expanding past the size of its internal Array. The size of the internal array of an array list does not change, in order to increase performance. When an element is added beyond the capacity of the ArrayList the internal array is copied and a new array of twice the number of elements is created. Thus reducing the need to expand the internal array for a while. This uses more memory, but can make it perform more quickly. Array lists also start with an internal Array with ten elements, also to reduce the need to increase its size.</span></div>
<div>
<span style="background-color: white; font-family: Verdana, sans-serif;"><br /></span></div>
<div>
<span style="background-color: white; font-family: Verdana, sans-serif;">ArrayLists can only contain objects.</span></div>
<div>
<span style="background-color: white; font-family: Verdana, sans-serif;"><br /></span></div>
<div>
<b><span style="background-color: white; font-family: Verdana, sans-serif;">List<t><t></t></t></span></b></div>
<div>
<span style="background-color: white; font-family: Verdana, sans-serif;">List<t> is a generic implementation of ArrayList. ArrayList appears to be being deprecated.</t></span></div>
<div>
<span style="background-color: white; font-family: Verdana, sans-serif;"><br /></span></div>
<div>
<b><span style="background-color: white; font-family: Verdana, sans-serif;">LinkedList<t><t></t></t></span></b></div>
<div>
<span style="background-color: white; font-family: Verdana, sans-serif;">LinkedList<t> can have performance issues since it can cause memory fragmentation. There is no set bounds for a LinkedList<t>, so data in the list can end up anywhere in memory. This can be confusing, since we also said that ArrayLists can have performance issues due to recreating the internal Array on inserts.</t></t></span></div>
<div>
<span style="background-color: white; font-family: Verdana, sans-serif;"><br /></span></div>
<div>
<span style="background-color: white; font-family: Verdana, sans-serif;">You have to determine when you need to gain. Do you need to free up memory or need to have fast inserts and deletions, then LinkedList. Do you need fast access to items and will be doing very few inserts, then perhaps Array or List is what you want.</span></div>
<div>
<span style="background-color: white; font-family: Verdana, sans-serif;"><br /></span></div>
<b><span style="background-color: white; font-family: Verdana, sans-serif;">Memory</span></b><br />
<span style="background-color: white; font-family: Verdana, sans-serif;">ArrayLists can use 100s of percent more memory than List<t>.</t></span><br />
<span style="background-color: white; font-family: Verdana, sans-serif;"><br />
<b>Types</b></span><br />
<span style="background-color: white; font-family: Verdana, sans-serif;">Under the covers ArrayList is an array of type object[]. List<t> is an array of whatever specific type T you make it. This can allow for better memory usage and a more precise implementation in code.</t></span><br />
<span style="background-color: white; font-family: Verdana, sans-serif;"><br />
<b>Performance</b></span><br />
<span style="background-color: white; font-family: Verdana, sans-serif;">Arrays and Lists allow for very fast read since they are a fix size making each piece of data stored right next to each other in memory.</span><br />
<span style="background-color: white; font-family: Verdana, sans-serif;"><br />
LinkedList<t> can have performance issues since it can cause memory fragmentation. There is no set bounds for a LinkedList<t>, so data in the list can end up anywhere in memory.</t></t></span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
Brookhttp://www.blogger.com/profile/15364549498171802139noreply@blogger.com0