Matt Pavey's Blog [RSS] http://www.pavey.net Matt Pavey's blog with information about web technologies such as .Net, ASP.Net, VB.Net, C#, AJAX, LINQ, XML, XSL, WCF Services, Web Services, SQL Server, SSIS, T-SQL, stored procedures and more. en-us Copyright © 2010 Matt Pavey 3/10/2010 3:38:08 PM 3/10/2010 3:38:08 PM http://www.pavey.net Matt Pavey mpavey@gmail.com mpavey@gmail.com 5 http://www.pavey.net/Uploads/VforVendetta.jpg Move/Scroll Page to Top After Asynchronous Postback in UpdatePanel in ASP.Net AJAXhttp://www.pavey.net/?BlogID=486<div><font color="#a31515" size="2"><font color="#a31515" size="2"><font color="#0000ff" size="2"><font color="#0000ff" size="2">&lt;</font></font>script</font></font><font size="2"> </font><font color="#ff0000" size="2"><font color="#ff0000" size="2">type</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">="text/javascript"&gt;<br /> </font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">&nbsp;&nbsp;&nbsp;function</font></font><font size="2"> pageLoad() {<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">var</font></font><font size="2"> manager = Sys.WebForms.PageRequestManager.getInstance();<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;manager.add_endRequest(endRequest);<br /> &nbsp;&nbsp;&nbsp;}</font></div> <div>&nbsp;</div> <div><font color="#0000ff" size="2"><font color="#0000ff" size="2">&nbsp;&nbsp;&nbsp;function</font></font><font size="2"> endRequest(sender, args) {<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;window.scrollTo(0, 0);<br /> &nbsp;&nbsp;&nbsp;}<br /> </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">&lt;/</font></font><font color="#a31515" size="2"><font color="#a31515" size="2">script</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">&gt;</div> <div></font></font>&nbsp;</div> <div><a href="http://www.codedigest.com/CodeDigest/120-Move-Scroll-Page-to-Top-After-Asynchronous-Postback-in-UpdatePanel-in-ASP-Net-AJAX.aspx" target="_blank">http://www.codedigest.com/CodeDigest/120-Move-Scroll-Page-to-Top-After-Asynchronous-Postback-in-UpdatePanel-in-ASP-Net-AJAX.aspx</a></div>Matt PaveyAJAXhttp://www.pavey.net/?BlogID=4862009-07-30 09:18:57New ASP.NET Charting Control: <asp:chart runat="server"/>http://www.pavey.net/?BlogID=485Another great article on <a href="http://weblogs.asp.net/scottgu/" target="_blank">ScottGu's Blog</a>. <p><em>Microsoft recently released a cool new ASP.NET server control - &lt;asp:chart /&gt; - that can be used for free with ASP.NET 3.5 to enable rich browser-based charting scenarios:</em></p> <ul> <li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=130f7986-bf49-4fe5-9ca8-910ae6ea442c&amp;DisplayLang=en" target="_blank">Download the free Microsoft Chart Controls</a> <li><a href="http://www.microsoft.com/downloads/details.aspx?familyid=1D69CE13-E1E5-4315-825C-F14D33A303E9&amp;displaylang=en" target="_blank">Download the VS 2008 Tool Support for the Chart Controls</a> <li><a href="http://code.msdn.microsoft.com/mschart/Release/ProjectReleases.aspx?ReleaseId=1591" target="_blank">Download the Microsoft Chart Controls Samples</a> <li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=EE8F6F35-B087-4324-9DBA-6DD5E844FD9F&amp;displaylang=en" target="_blank">Download the Microsoft Chart Controls Documentation</a> <li><a href="http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/threads/" target="_blank">Visit the Microsoft Chart Control Forum</a> </li> </ul> <p>Check out the article for more information on dowloading the free chart control, samples and documentation:</p> <p><a href="http://weblogs.asp.net/scottgu/archive/2008/11/24/new-asp-net-charting-control-lt-asp-chart-runat-quot-server-quot-gt.aspx" target="_blank">http://weblogs.asp.net/scottgu/archive/2008/11/24/new-asp-net-charting-control-lt-asp-chart-runat-quot-server-quot-gt.aspx</a></p> <em>"&lt;asp:chart /&gt; supports a rich assortment of chart options - including pie, area, range, point, circular, accumulation, data distribution, ajax interactive, doughnut, and more.&nbsp; You can statically declare chart data within the control declaration, or alternatively use data-binding to populate it dynamically.&nbsp; At runtime the server control generates an image (for example a .PNG file) that is referenced from the client HTML of the page using a &lt;img/&gt; element output by the &lt;asp:chart/&gt; control.&nbsp; The server control supports the ability to cache the chart image, as well as save it on disk for persistent scenarios.&nbsp; It does not require any other server software to be installed, and will work with any standard ASP.NET page."</em>Matt PaveyASP.Nethttp://www.pavey.net/?BlogID=4852009-01-22 09:17:03Hosting options for WCF serviceshttp://www.pavey.net/?BlogID=484<div><em>"These hosting options range from running inside a console application to server environments such as a Windows service running within a worker process managed by Internet Information Services (IIS) or by Windows Process Activation Service (WAS). Developers choose the hosting environment that satisfies the service's deployment requirements. These requirements might derive from the platform on which the application is deployed, the transport on which it must send and receive messages, or on the type of process recycling and other process management required to ensure adequate availability, or on some other management or reliability requirements."</em></div> <div>&nbsp;</div> <div><a href="http://msdn.microsoft.com/en-us/library/ms730158.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/ms730158.aspx</a></div> <div>&nbsp;</div> <div>The article above provides some great information on how to use the different hosting services and explains in detail the key benefits and limitations to each.</div> <div>&nbsp;</div> <div>For more specific information about each hosting service check out the following links also referenced in the above article:</div> <div>&nbsp;</div> <div>- <a href="http://msdn.microsoft.com/en-us/library/ms731758.aspx" target="_blank">Self-Hosting in a Managed Application</a><br /> - <a href="http://msdn.microsoft.com/en-us/library/ms733069.aspx" target="_blank">Managed Windows Services</a><br /> - <a href="http://msdn.microsoft.com/en-us/library/ms733766.aspx" target="_blank">Internet Information Services (IIS)</a><br /> - <a href="http://msdn.microsoft.com/en-us/library/ms733109.aspx" target="_blank">Windows Process Activation Service (WAS)</a></div> <div>&nbsp;</div> <div>These links were very helpful in understanding the different hosting options available for WCF services and more importantly understanding the right hosting environment to use based on&nbsp; <em>"... the version of Windows on which it is deployed, the transports it requires to send messages and the type of process and application domain recycling it requires."</em></div>Matt PaveyWCFhttp://www.pavey.net/?BlogID=4842009-01-12 20:54:49Creating your first WCF servicehttp://www.pavey.net/?BlogID=483<div>If you are just getting started with Windows Communication Foundation (WCF) here's a great resource with videos that really help get you moving in the right direction.</div> <div>&nbsp;</div> <div>The videos will make more sense if watched in the following order:</div> <div>&nbsp;</div> <div><a href="http://channel9.msdn.com/shows/Endpoint/Endpoint-Screencasts-Creating-Your-First-WCF-Service/" target="_blank">http://channel9.msdn.com/shows/Endpoint/Endpoint-Screencasts-Creating-Your-First-WCF-Service/</a><br /> &nbsp;<br /> <a href="http://channel9.msdn.com/shows/Endpoint/Endpoint-Screencasts-Configuring-Services-with-Endpoints/" target="_blank">http://channel9.msdn.com/shows/Endpoint/Endpoint-Screencasts-Configuring-Services-with-Endpoints/</a><br /> &nbsp;<br /> <a href="http://channel9.msdn.com/shows/Endpoint/Endpoint-Screencasts-Hosting-WCF-Services-in-IIS/" target="_blank">http://channel9.msdn.com/shows/Endpoint/Endpoint-Screencasts-Hosting-WCF-Services-in-IIS/</a><br /> &nbsp;<br /> <a href="http://channel9.msdn.com/shows/Endpoint/Endpoint-Screencasts-Self-hosting-WCF-Services/" target="_blank">http://channel9.msdn.com/shows/Endpoint/Endpoint-Screencasts-Self-hosting-WCF-Services/</a></div> <div>&nbsp;</div> <div>The videos demonstrate the following:</div> <div>&nbsp;</div> <div>- Creating a WCF service</div> <div>- Configuring a WCF service with various endpoints</div> <div>- How to host a WCF service in IIS</div> <div>- How to self-host&nbsp;a WCF service in your own applications</div> <div>&nbsp;</div> <div>For additional information on WCF, check out the&nbsp;<a href="http://msdn.microsoft.com/wcf/" target="_blank">WCF Dev Center on MSDN</a> and the <a href="http://blogs.msdn.com/endpoint/" target="_blank">.NET Endpoint team blog</a>.</div>Matt PaveyWCFhttp://www.pavey.net/?BlogID=4832009-01-12 20:34:11SQL Server 2008 Management Studiohttp://www.pavey.net/?BlogID=481<div>Here is the error I received:</div> <div><br /> TITLE: Microsoft SQL Server Management Studio<br /> ------------------------------<br /> <br /> Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)<br /> <br /> For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&amp;LinkId=20476<br /> <br /> ------------------------------<br /> ADDITIONAL INFORMATION:<br /> <br /> An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)<br /> <br /> ------------------------------<br /> <br /> The server principal "UserName" is not able to access the database "DatabaseName" under the current security context. (Microsoft SQL Server, Error: 916)<br /> <br /> For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&amp;ProdVer=09.00.3239&amp;EvtSrc=MSSQLServer&amp;<br/>EvtID=916&amp;LinkId=20476<br /> <br /> ------------------------------<br /> BUTTONS:<br /> <br /> OK<br /> ------------------------------</div> <div>&nbsp;</div> <div>After doing some digging I found the answer on <a href="http://sqlblog.com/blogs/aaron_bertrand/default.aspx" target="_blank">Aaron Bertrand's</a> SQL blog.</div> <div>&nbsp;</div> <div><a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2008/07/07/a-little-management-studio-oops.aspx" target="_blank">http://sqlblog.com/blogs/aaron_bertrand/archive/2008/07/07/a-little-management-studio-oops.aspx</a></div> <div>&nbsp;</div> <div><em>"For those of you who connect to database servers where you are not in full control over all databases, or where some of your databases are ever offline (or auto-closed), the new version of Management Studio that is shipping with SQL Server 2008 is going to bring you some surprises, when you try to present a list of databases in Object Explorer."</em></div> <div>&nbsp;</div> <div><em>"It seems that the ability to do so is hinged upon the columns that are set up in Object Explorer Details by default.&nbsp; In the case I came across yesterday, the offender was "Collation."&nbsp; The problem is that for a database that is offline or has been auto-closed, collation comes back as NULL.&nbsp; Well, that's not really the problem... the real problem is that SSMS throws its hands in the air when it comes across NULL for these values, and assumes this is NULL because you don't have permission."</em></div> <div><em></em>&nbsp;</div> <div><em>"And then refuses to show the data for ANY database, instead of just hiding the one(s) that caused the error.&nbsp; And this is true whether or not you have Object Explorer Details even open (my guess here is that the contents of OED are cached behind the scenes, even when it is disabled... which I speculate may be part of the reason behind the sluggishness that many have complained about).&nbsp; You can read more about this in </em><a title="Connect #354322" href="http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=354322" target="_blank"><em>Connect #354322</em></a><em> and in </em><a title="Connect #354291" href="http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=354291" target="_blank"><em>Connect #354291</em></a><em>."</em><br /> </div> <div><em></em>&nbsp;</div> <div><em>"For those of you that connect to databases that are hosted by 3rd party providers, some of which are accustomed to leaving as many databases in auto-close mode as possible, you are first going to have to go to Object Explorer Details, right-click the column header list, and un-check Collation.&nbsp; At this point, if you refresh the Databases node in Object Explorer, you should again see all of the databases on the server, even those where you don't have access.&nbsp; Strangely enough, OED still shows you some other data by default, that it probably shouldn't (e.g. recovery model, last backup, owner)."</em></div>Matt PaveySQL Serverhttp://www.pavey.net/?BlogID=4812008-12-28 22:16:04Check/Uncheck all items in a CheckBoxList using ASP.NET and JavaScripthttp://www.pavey.net/?BlogID=480<div>Here's an easy way to check or uncheck all items in a CheckBoxList.</div> <div>&nbsp;</div> <div><a href="http://www.dotnetcurry.com/ShowArticle.aspx?ID=77&amp;AspxAutoDetectCookieSupport=1" target="_blank">http://www.dotnetcurry.com/ShowArticle.aspx?ID=77&amp;AspxAutoDetectCookieSupport=1</a></div> <div>&nbsp;</div> <div><strong>JavaScript</strong></div> <div>&nbsp;</div> <div><font color="#0000ff" size="2"><font color="#0000ff" size="2"><font size="1">function</font></font></font><font size="1"> CheckBoxListSelect(cbControl, state)</font></div> <div><font size="1">{</font></div> <div><font size="1">&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000ff"><font color="#0000ff">var</font></font> chkBoxList = document.getElementById(cbControl);</font></div> <div><font size="1">&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000ff"><font color="#0000ff">var</font></font> chkBoxCount = chkBoxList.getElementsByTagName(<font color="#a31515"><font color="#a31515">"input"</font></font>);</font></div> <div>&nbsp;</div> <div><font size="1">&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000ff"><font color="#0000ff">for</font></font>(<font color="#0000ff"><font color="#0000ff">var</font></font> i=0; i &lt; chkBoxCount.length; i++)</font></div> <div><font size="1">&nbsp;&nbsp;&nbsp;&nbsp; {</font></div> <div><font size="1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chkBoxCount[i].checked = state;</font></div> <div><font size="1">&nbsp;&nbsp;&nbsp;&nbsp; }</font></div> <div>&nbsp;</div> <div><font size="1">&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000ff"><font color="#0000ff">return</font></font> <font color="#0000ff"><font color="#0000ff">false</font></font>;</font></div> <div><font size="1">}</font><font size="2"></div> </font> <div>&nbsp;</div> <div><strong>ASP.Net CheckBoxList</strong></div> <div>&nbsp;</div> <div><font size="1"><font color="#0000ff"><font color="#0000ff">&lt;</font></font><font color="#a31515"><font color="#a31515">div</font></font><font color="#0000ff"><font color="#0000ff">&gt;</font></font></font></div> <div><font size="1"><font color="#0000ff">&nbsp;&nbsp;&nbsp;&nbsp; &lt;</font><font color="#a31515"><font color="#a31515">a</font></font> <font color="#ff0000"><font color="#ff0000">href</font></font><font color="#0000ff"><font color="#0000ff">="javascript:void(0)"</font></font> <font color="#ff0000"><font color="#ff0000">onclick</font></font><font color="#0000ff"><font color="#0000ff">="javascript: CheckBoxListSelect('</font></font>&lt;%=chkStates.ClientID %&gt;<font color="#0000ff"><font color="#0000ff">', true)"&gt;</font></font>Select All<font color="#0000ff"><font color="#0000ff">&lt;/</font></font><font color="#a31515"><font color="#a31515">a</font></font><font color="#0000ff"><font color="#0000ff">&gt;</font></font> | <font color="#0000ff"><font color="#0000ff">&lt;</font></font><font color="#a31515"><font color="#a31515">a</font></font> <font color="#ff0000"><font color="#ff0000">href</font></font><font color="#0000ff"><font color="#0000ff">="javascript:void(0)"</font></font> <font color="#ff0000"><font color="#ff0000">onclick</font></font><font color="#0000ff"><font color="#0000ff">="javascript: CheckBoxListSelect('</font></font>&lt;%=chkStates.ClientID %&gt;<font color="#0000ff"><font color="#0000ff">', false)"&gt;</font></font>Select None<font color="#0000ff"><font color="#0000ff">&lt;/</font></font><font color="#a31515"><font color="#a31515">a</font></font><font color="#0000ff"><font color="#0000ff">&gt;</font></font></font></div> <div><font size="1"><font color="#0000ff"><font color="#0000ff">&lt;/</font></font><font color="#a31515"><font color="#a31515">div</font></font><font color="#0000ff"><font color="#0000ff">&gt;</font></font></font></div> <div><font size="1"></font>&nbsp;</div> <div><font size="1"><font color="#0000ff"><font color="#0000ff">&lt;</font></font><font color="#a31515"><font color="#a31515">div</font></font><font color="#0000ff"><font color="#0000ff">&gt;</font></font></font></div> <div><font size="1"><font color="#0000ff">&nbsp;&nbsp;&nbsp;&nbsp; &lt;</font><font color="#a31515"><font color="#a31515">asp</font></font><font color="#0000ff"><font color="#0000ff">:</font></font><font color="#a31515"><font color="#a31515">CheckBoxList</font></font> <font color="#ff0000"><font color="#ff0000">ID</font></font><font color="#0000ff"><font color="#0000ff">="chkStates"</font></font> <font color="#ff0000"><font color="#ff0000">RepeatColumns</font></font><font color="#0000ff"><font color="#0000ff">="6"</font></font> <font color="#ff0000"><font color="#ff0000">Width</font></font><font color="#0000ff"><font color="#0000ff">="100%"</font></font> <font color="#ff0000"><font color="#ff0000">runat</font></font><font color="#0000ff"><font color="#0000ff">="server"</font></font> <font color="#0000ff"><font color="#0000ff">/&gt;</font></font></font></div> <div><font size="2"><font size="1"><font color="#0000ff"><font color="#0000ff">&lt;/</font></font><font color="#a31515"><font color="#a31515">div</font></font><font color="#0000ff"><font color="#0000ff">&gt;</font></font></font></font></div>Matt PaveyASP.Nethttp://www.pavey.net/?BlogID=4802008-11-18 19:32:06SSIS loading Excel validation errorhttp://www.pavey.net/?BlogID=479<div>I ran into a situation today where I needed to have an <strong>Excel Source</strong> for an Excel file that would <u>not</u>&nbsp;always exist at the path specified in the <em>ExcelFilePath</em> property. This would cause the SSIS package to fail when the Excel file did not exist since the <strong>Data Flow Task</strong> could not validate the Excel file.</div> <div>&nbsp;</div> <div><a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2170106&amp;SiteID=1" target="_blank">http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2170106&amp;SiteID=1</a></div> <div>&nbsp;</div> <div>The simple fix was to right click the <strong>Data Flow Task</strong> and go to <em>Properties</em> and set the <em>DelayValidation</em> property to <em>True</em>.</div>Matt PaveySSIShttp://www.pavey.net/?BlogID=4792008-11-11 20:24:50Importing Excel data with SQL Server Integration Services SSIS with unicode and non-unicode data issueshttp://www.pavey.net/?BlogID=478<div><em>"If you have used SSIS to import Excel data into SQL Server you may have run into the issue of having to convert data from Unicode to non-Unicode."</em></div> <div>&nbsp;</div> <div>This article discusses some different options for handling Unicode to non-Unicode warning messages that are fairly common if you deal with importing data from one source to another, for example from Excel to SQL.</div> <div>&nbsp;</div> <div><a href="http://www.mssqltips.com/tip.asp?tip=1393" target="_blank">http://www.mssqltips.com/tip.asp?tip=1393</a></div> <div>&nbsp;</div> <div>In my case today I ended up just having to add a <strong>Data Conversion</strong> transformation between my <strong>Excel Source</strong> and <strong>SQL Server Destination</strong> to convert my data-types accordingly.</div>Matt PaveySSIShttp://www.pavey.net/?BlogID=4782008-11-11 20:24:29SQL Server 2008 Designer Behavior Change: Saving Changes Not Permittedhttp://www.pavey.net/?BlogID=476<div><em>Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created.</em></div> <div>&nbsp;</div> <div><a href="http://pragmaticworks.com/community/blogs/brianknight/archive/2008/06/04/sql-server-2008-designer-behavior-change-saving-changes-not-permitted.aspx" target="_blank">http://pragmaticworks.com/community/blogs/brianknight/archive/2008/06/04/sql-server-2008-designer-behavior-change-saving-changes-not-permitted.aspx</a></div> <div>&nbsp;</div> <div><em>"This is by design and can be quickly fixed in Management Studio by unchecking a property. To fix this in Management Studio, go to Tools -&gt; Options then go to the Designer Page and uncheck <strong>Prevent saving changes that require table re-creation</strong>."</em></div>Matt PaveySQL Serverhttp://www.pavey.net/?BlogID=4762008-10-30 12:49:47New Date Data Types in Microsoft SQL Server 2008http://www.pavey.net/?BlogID=475<div>Here's another good article article written by <a href="http://www.4guysfromrolla.com/ScottMitchell.shtml" target="_blank">Scott Mitchell</a>&nbsp;discussing the new date data types available in Microsoft SQL Server 2008.</div> <div>&nbsp;</div> <div><em>"This article explores the <code>time</code> and <code>date</code> data types and shows how they can be used and formatted from within an ASP.NET page. This article also includes a short discussion on the <code>datetime2</code> and <code>datetimeoffset</code> and compares and constrasts SQL Server 2008's six different date data types."</em></div> <div>&nbsp;</div> <div><a href="http://aspnet.4guysfromrolla.com/articles/101508-1.aspx" target="_blank">http://aspnet.4guysfromrolla.com/articles/101508-1.aspx</a></div> <div>&nbsp;</div> <div><a href="http://www.4guysfromrolla.com/ScottMitchell.shtml" target="_blank">Scott Mitchell</a>&nbsp;is the the editor, founder, and primary contributor to <a href="http://www.4guysfromrolla.com/" target="_blank">4GuysFromRolla.com</a>.</div>Matt PaveySQL Serverhttp://www.pavey.net/?BlogID=4752008-10-21 18:47:35Web Platform Installer: Trying to make it easier to setup for web developmenthttp://www.pavey.net/?BlogID=474<a href="http://www.hanselman.com/blog/WebPlatformInstallerTryingToMakeItEasierToSetupForWebDevelopment.aspx" target="_blank">http://www.hanselman.com/blog/WebPlatformInstallerTryingToMakeItEasierToSetupForWebDevelopment.aspx</a>Matt PaveyOtherhttp://www.pavey.net/?BlogID=4742008-10-21 18:40:11Lightbox2http://www.pavey.net/?BlogID=472"Lightbox is a <em>simple, unobtrusive</em> script used to overlay images on the current page. It's a <em>snap to setup</em> and works on <em>all modern browsers</em>." <p><a href="http://www.huddletogether.com/projects/lightbox2" target="_blank">http://www.huddletogether.com/projects/lightbox2</a></p>Matt PaveyOtherhttp://www.pavey.net/?BlogID=4722008-10-03 15:27:47Adobe Spry framework for AJAXhttp://www.pavey.net/?BlogID=471<em>Spry is a JavaScript-based framework that enables the rapid development of Ajax-powered web pages. Not a JavaScript guru? No problem. Spry was designed to feel like an extension of HTML and CSS, so anyone with basic web-production skills can create next-generation web experiences by adding the power of Ajax to their pages.</em> <p><em>Spry can be used with any server-side technology (ColdFusion, PHP, ASP.Net etc.). By building the front-end of your web application with Spry you enable a more efficient designer-developer workflow by keeping UI separated from back-end application logic.</em></p> <p><strong>Home:<br /> </strong><a href="http://labs.adobe.com/technologies/spry/home.html" target="_blank">http://labs.adobe.com/technologies/spry/home.html</a></p> <p><strong>Demos:</strong><br /> <a href="http://labs.adobe.com/technologies/spry/samples/" target="_blank">http://labs.adobe.com/technologies/spry/samples/</a></p>Matt PaveyOtherhttp://www.pavey.net/?BlogID=4712008-09-24 12:31:07The Yahoo! User Interface Library (YUI)http://www.pavey.net/?BlogID=470<div><em>The Yahoo! User Interface (YUI) Library is a set of utilities and controls, written in JavaScript, for building richly interactive web applications using techniques such as DOM scripting, DHTML and AJAX. The YUI Library also includes several core CSS resources. All components in the YUI Library have been released as open source under a </em><a href="http://developer.yahoo.com/yui/license.html" target="_blank"><em>BSD license</em></a><em> and are free for all uses.</em></div> <div>&nbsp;</div> <div><a href="http://developer.yahoo.com/yui/" target="_blank">http://developer.yahoo.com/yui/</a></div>Matt PaveyOtherhttp://www.pavey.net/?BlogID=4702008-09-24 12:22:22Granting execute permissions to all stored procedures in a databasehttp://www.pavey.net/?BlogID=469<em>"Whilst SQL Server 2000 has fixed database roles such as db_datareader and db_datawriter that allow a user read or write access respectively to all the table is a database, no such role exists for the execution of stored procedures (a db_executor role if you will). This article describes how to grant execute permission to all stored procedures in a database to a specific user or role in both SQL2000 and SQL2005."</em> <br><br> <a href="http://www.sqldbatips.com/showarticle.asp?ID=8" target="_blank">http://www.sqldbatips.com/showarticle.asp?ID=8</a>Matt PaveySQL Serverhttp://www.pavey.net/?BlogID=4692008-09-11 01:03:55Sending Email in ASP.NET 2.0http://www.pavey.net/?BlogID=468<div>Coincidentally for the 3rd time in the past week an issue I was working on led me to an article written by <a href="http://www.4guysfromrolla.com/ScottMitchell.shtml" target="_blank"><font color="#0000cc">Scott Mitchell</font></a>. </div> <div>&nbsp;</div> <div><a href="http://aspnet.4guysfromrolla.com/articles/072606-1.aspx" target="_blank">http://aspnet.4guysfromrolla.com/articles/072606-1.aspx</a></div> <div>&nbsp;</div> <div><em>"The relay server information used by the <strong>SmtpClient</strong> class can be specified programmatically, through the <strong>SmtpClient</strong> class's properties, or can be centralized in <strong>Web.config</strong>. To use the <strong>Web.config</strong> approach, add a <strong>&lt;system.net&gt;</strong> element within the <strong>&lt;configuration&gt;</strong> element. Then, add a <strong>&lt;mailSettings&gt;</strong> element that contains an <strong>&lt;smtp&gt;</strong> element whose settings are specified within its <strong>&lt;network&gt;</strong> child element, like so:"</em></div> <div><font color="#0000ff" size="2"><font color="#0000ff" size="2"></font></font>&nbsp;</div> <div><font size="1"><font color="#0000ff"><font color="#0000ff">&lt;</font></font><font color="#a31515"><font color="#a31515">configuration</font></font></font><font size="1"><font color="#0000ff"><font color="#0000ff">&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp; &lt;!--</font></font><font color="#008000"><font color="#008000"> Add the email settings to the &lt;system.net&gt; element </font></font></font><font size="1"><font color="#0000ff"><font color="#0000ff">--&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp; &lt;</font></font><font color="#a31515"><font color="#a31515">system.net</font></font></font><font size="1"><font color="#0000ff"><font color="#0000ff">&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</font></font><font color="#a31515"><font color="#a31515">mailSettings</font></font></font><font size="1"><font color="#0000ff"><font color="#0000ff">&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</font></font><font color="#a31515"><font color="#a31515">smtp</font></font></font><font size="1"><font color="#0000ff"><font color="#0000ff">&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font><font color="#0000ff"><font color="#0000ff">&lt;</font></font></font><font size="1"><font color="#a31515"><font color="#a31515">network <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font><font color="#ff0000"><font color="#ff0000">host</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">relayServerHostname</font></font>"<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ff0000"><font color="#ff0000">port</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">portNumber</font></font>"<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#ff0000"><font color="#ff0000">userName</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">username</font></font>"<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#ff0000"><font color="#ff0000">password</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">password</font></font>"</font><font size="1"><font color="#0000ff"><font color="#0000ff"> /&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</font></font><font color="#a31515"><font color="#a31515">smtp</font></font></font><font size="1"><font color="#0000ff"><font color="#0000ff">&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</font></font><font color="#a31515"><font color="#a31515">mailSettings</font></font></font><font size="1"><font color="#0000ff"><font color="#0000ff">&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp; &lt;/</font></font><font color="#a31515"><font color="#a31515">system.net</font></font></font><font size="1"><font color="#0000ff"><font color="#0000ff">&gt;<br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp; &lt;</font></font><font color="#a31515"><font color="#a31515">system.web</font></font></font><font size="1"><font color="#0000ff"><font color="#0000ff">&gt;<br /> </font></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...<br /> <font color="#0000ff"><font color="#0000ff">&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</font></font><font color="#a31515"><font color="#a31515">system.web</font></font></font><font size="1"><font color="#0000ff"><font color="#0000ff">&gt;<br /> &lt;/</font></font><font color="#a31515"><font color="#a31515">configuration</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">&gt;</div> </font></font></font> <div>&nbsp;</div> <div><a href="http://www.4guysfromrolla.com/ScottMitchell.shtml" target="_blank">Scott Mitchell</a>&nbsp;is the the editor, founder, and primary contributor to <a href="http://www.4guysfromrolla.com/" target="_blank">4GuysFromRolla.com</a>.</div>Matt Pavey.Nethttp://www.pavey.net/?BlogID=4682008-08-18 10:51:50Taking an ASP.NET 2.0 Application Offlinehttp://www.pavey.net/?BlogID=467Here's another good article written by <a href="http://www.4guysfromrolla.com/ScottMitchell.shtml" target="_blank">Scott Mitchell</a>. <div>&nbsp;</div> <div><a href="http://aspnet.4guysfromrolla.com/articles/110707-1.aspx" target="_blank">http://aspnet.4guysfromrolla.com/articles/110707-1.aspx</a></div> <div>&nbsp;</div> <div><em>"When updating a web application that's currently in production, it is best to take the application offline so that users understand that the application is being worked on. This can be accomplished in a variety of ways, from simply stopping the web server software to displaying a web page that informs the user that the site is offline for maintenance. What you don't want to do is have the application appear to work, only to have some error pop up later because you are in the middle of updating the production server. This is a sure-fired way to frustrate your users."</em></div> <div>&nbsp;</div> <div>The article discusses 4 ways to take an application offline:</div> <ul> <li>Taking a Website Offline through IIS <li>Disabling the &lt;httpRuntime&gt; <li>Using App_Offline.htm <li>Creating a "Manage Offline Status" Page</li> </ul> <div><a href="http://www.4guysfromrolla.com/ScottMitchell.shtml" target="_blank">Scott Mitchell</a>&nbsp;is the the editor, founder, and primary contributor to <a href="http://www.4guysfromrolla.com/" target="_blank">4GuysFromRolla.com</a>.</div>Matt Pavey.Nethttp://www.pavey.net/?BlogID=4672008-08-17 18:20:23Displaying the Sizes of Your SQL Server's Database's Tableshttp://www.pavey.net/?BlogID=466<div>By <a href="http://www.4guysfromrolla.com/ScottMitchell.shtml" target="_blank">Scott Mitchell</a><br /> <br /> <a href="http://www.4guysfromrolla.com/webtech/032906-1.shtml" target="_blank">http://www.4guysfromrolla.com/webtech/032906-1.shtml</a></div> <div>&nbsp;</div> <div><em>"SQL Server has a handy little system stored procedure named <strong>sp_spaceused</strong> that will return the space used by a database or by a particular table. To determine the size used by the <strong>database</strong>, simply run:"</em></div> <div><em></em>&nbsp;</div> <div><font face="Courier New">EXEC sp_spaceused</font> </div> <div><em></em>&nbsp;</div> <div><em>"This will return two result sets, the first one containing the database name, size, and unallocated space and the second containing a breakdown of the database's size into how much size is reserved and how much of that is taken up by data, how much by indexes, and how much remains unused."</em></div> <div><em></em>&nbsp;</div> <div><em>"To return information about a particular <strong>table</strong>, simply call <strong>sp_spaceused</strong> passing in as the first parameter the name of the table. To determine the space used by the Orders table in the Northwind database use:"</em></div> <div>&nbsp;</div> <div><font face="Courier New">EXEC sp_spaceused 'Orders'</font></div> <div>&nbsp;</div> <div>This will return a single result set that provides the following information:</div> <ul> <li><strong>Name</strong> - the name of the table <li><strong>Rows</strong> - the number of rows in the table <li><strong>Reserved</strong> - amount of total reserved space for the table <li><strong>Data</strong> - amount of space used by the data for the table <li><strong>Index_Size</strong> - amount of space used by the table's indexes <li><strong>Unused</strong> - amount of usused space in the table </li> </ul> <p><em>"While <strong>sp_spaceused</strong> can be used to return the space usage for a single table, more than likely we want a web page where we can view the space used for all tables in a database. There are a number of ways to accomplish this, but in short we need to execute <strong>sp_spaceused</strong> once for every table in the database. In order to accomplish that we could do one of two things:"</em> </p> <ul> <li>Query the <strong>sysobjects</strong> table to get a list of tables in the database, then use a <strong>CURSOR</strong> to iterate through these table results one at a time, executing <strong>sp_spaceused</strong> for each one.<br /> <li>Use the undocumented <strong>sp_MSforeachtable</strong> stored procedure, which takes in a command and executes that command against all of the user tables in the database. </li> </ul> <p><em>"The <strong>sp_MSforeachtable</strong> stored procedure is one of many undocumented stored procedures tucked away in the depths of SQL Server. A list of these handy stored procedures can be found at <a href="http://www.mssqlcity.com/Articles/Undoc/SQL2000UndocSP.htm" target="_blank">SQL Server 2000 Useful Undocumented Stored Procedures</a>. In short, you can use <strong>sp_MSforeachtable</strong> like so:"</em></p> <p><font face="Courier New">EXEC sp_MSforeachtable @command1="<em><strong>command to run</strong></em>"</font></p> <p><em>"In the <strong>command to run</strong> put a ? where you want the table name to be inserted. For example, to run the <strong>sp_spaceused</strong> stored procedure for each table in the database, we'd use:"</em></p> <p><font face="Courier New">EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'"</font></p> <div>This will execute <strong>EXEC sp_spaceused 'TableName'</strong> for each user table in the database.</div> <div>&nbsp;</div> <div><em>"An alternative option is to create a stored procedure from which a temporary table is created and populated with one record for each result set returned by sp_spaceused. The entire results, then, can be returned to the ASP.NET page as a single result set by selecting the entire contents of the temporary table at the end of the stored procedure."</em></div> <p><font color="#0000ff" size="2"><font color="#0000ff" size="2"><font size="1">create</font></font></font><font size="1"> <font color="#0000ff"><font color="#0000ff">table</font></font> #spaceused </font><font color="#808080"><font color="#808080"><font size="1">(</font></font></font><font size="1"><font color="#0000ff"><font color="#0000ff">name</font></font> <font color="#0000ff"><font color="#0000ff">varchar</font></font><font color="#808080"><font color="#808080">(</font></font>128<font color="#808080"><font color="#808080">),</font></font> <font color="#0000ff"><font color="#0000ff">rows</font></font> <font color="#0000ff"><font color="#0000ff">bigint</font></font><font color="#808080"><font color="#808080">,</font></font> reserved <font color="#0000ff"><font color="#0000ff">varchar</font></font><font color="#808080"><font color="#808080">(</font></font>25<font color="#808080"><font color="#808080">),</font></font> data <font color="#0000ff"><font color="#0000ff">varchar</font></font><font color="#808080"><font color="#808080">(</font></font>25<font color="#808080"><font color="#808080">),</font></font> index_size <font color="#0000ff"><font color="#0000ff">varchar</font></font><font color="#808080"><font color="#808080">(</font></font>25<font color="#808080"><font color="#808080">),</font></font> unused <font color="#0000ff"><font color="#0000ff">varchar</font></font><font color="#808080"><font color="#808080">(</font></font>25<font color="#808080"><font color="#808080">))</font></font> </font></p> <font color="#0000ff"><font color="#0000ff"> <p><font size="1">EXEC</font></font></font><font size="1"> <font color="#800000"><font color="#800000">sp_MSforeachtable</font></font> @command1<font color="#808080"><font color="#808080">=</font></font>"insert into #spaceused EXEC sp_spaceused '?'" </font></p> <font color="#0000ff"><font color="#0000ff"> <p><font size="1">select</font></font></font><font size="1"> <font color="#808080"><font color="#808080">*</font></font> <font color="#0000ff"><font color="#0000ff">from</font></font> #spaceused </font></p> <font color="#0000ff"><font color="#0000ff"> <p><font size="1">drop</font></font></font><font size="1"> <font color="#0000ff"><font color="#0000ff">table</font></font> #spaceused </font></p> <div>The above SQL code courtesy of Toby.</div> <div>&nbsp;</div> <div><a href="http://www.4guysfromrolla.com/ScottMitchell.shtml" target="_blank">Scott Mitchell</a>&nbsp;is the the editor, founder, and primary contributor to <a href="http://www.4guysfromrolla.com/" target="_blank">4GuysFromRolla.com</a>.</div>Matt PaveySQL Serverhttp://www.pavey.net/?BlogID=4662008-08-12 23:30:07Scheduling Backups for SQL Server 2005 Expresshttp://www.pavey.net/?BlogID=465<div><em>"One problem with SQL Server 2005 Express is that it does not offer a way to schedule jobs. In a previous tip, <font style="color: #000000" color="#000000"><a href="http://www.mssqltips.com/tip.asp?tip=1083" target="_blank">Free Job Scheduling Tool for SQL Server Express and MSDE</a>,</font> we looked at a free tool that allows you to create scheduled jobs for SQL Server. The one issue people often face though is what to install and what not to install on their production servers and therefore these items go without resolution. One very important part of managing SQL Server is to ensure you run backups on a set schedule. I often hear about corrupt databases and no backups, so let's take a look at another approach of scheduling backups using the included tools in both the operating system and SQL Server."</em></div> <div>&nbsp;</div> <div>This article provides an easy solution for using the SQL&nbsp;<strong>BACKUP</strong> command to backup a database and shows you how to use <strong>SQLCMD.EXE</strong> with <strong>Scheduled Tasks</strong> to schedule it to run automatically, thus giving you the scheduled backups&nbsp;functionality you would typically have in SQL Server Agent.</div> <div>&nbsp;</div> <div><a href="http://www.mssqltips.com/tip.asp?tip=1174" target="_blank">http://www.mssqltips.com/tip.asp?tip=1174</a></div>Matt PaveySQL Serverhttp://www.pavey.net/?BlogID=4652008-07-31 18:50:26Web Farms and ASP.NET ViewStatehttp://www.pavey.net/?BlogID=464<div><em>"The default ASP.NET settings ensure that forms authentication tickets are tamper proof and encrypted, and that ViewState is tamper proof. This ensures that any modification of the ViewState or authentication tickets either on the client's computer or over the network is detected when the server processes the data."</em></div> <div>&nbsp;</div> <div>For example, when the viewstate generated on server&nbsp;A is&nbsp;posted back to server B you may receive a viewstate validation error if the &lt;machineKey&gt; is not the same on all of the servers in the web farm or cluster.</div> <div>&nbsp;</div> <div>Here is one of the exceptions you may receive:</div> <div>&nbsp;</div> <div><em>Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that &lt;machineKey&gt; configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.</em></div> <div>&nbsp;</div> <div>This is because the viewstate is salted with a unique, autogenerated machine key from the originating server's machine.config file.</div> <div>&nbsp;</div> <div><em>"This is done to prevent users from somehow tampering with the ViewState. Any change to the ViewState data on the client will be detected. But this has a side effect: it also prevents multiple servers from processing the same ViewState. One solution is to force every server in your farm to use the same key -- generate a hex encoded 64-bit or 128-bit &lt;machineKey&gt; and put that in each server's machine.config"</em></div> <div>&nbsp;</div> <div>If you do not have access to the machine.config files in the web farm or cluster you can disable the enableViewStateMac using a simple page directive:</div> <div>&nbsp;</div> <div>&lt;%@ Page Language="vb" AutoEventWireup="false" Codebehind="MyPage.aspx.vb"<br /> &nbsp;Inherits="MyAssembly.MyPage" <strong>enableViewStateMac="false"</strong> %&gt;</div> <div>&nbsp;</div> <div>Alternately, you can modify the pages element in Web.config:</div> <div>&nbsp;</div> <div>&lt;system.web&gt;<br /> &nbsp; &lt;pages <strong>enableViewStateMac="false"</strong> /&gt;<br /> &lt;/system.web&gt;</div> <div><br /> Of course caution should be taken when setting the enableViewStateMac to <strong>false&nbsp;</strong>since the viewstate could potentially be tampered with.</div> <div>&nbsp;</div> <div><strong>If you have a web farm or cluster and receive this error the optimal solution would be to update the machine.config files on all of the servers in the web farm or cluster to ensure that the &lt;machineKey&gt; configuration specifies the same validationKey and validation algorithm.</strong></div> <div>&nbsp;</div> <div><a href="http://www.codinghorror.com/blog/archives/000132.html" target="_blank">http://www.codinghorror.com/blog/archives/000132.html</a></div> <div>&nbsp;</div> <div><a href="http://blogs.msdn.com/rich_crane/archive/2004/05/12/130693.aspx" target="_blank">http://blogs.msdn.com/rich_crane/archive/2004/05/12/130693.aspx</a></div> <div>&nbsp;</div> <div><a href="http://msdn.microsoft.com/en-us/library/ms998288.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/ms998288.aspx</a></div>Matt Pavey.Nethttp://www.pavey.net/?BlogID=4642008-07-31 18:49:49Checking All CheckBoxes in a GridView Using Client-Side Script and a Check All CheckBoxhttp://www.pavey.net/?BlogID=463<em>"In this article we saw how to add a "Check/Uncheck All" header CheckBox to the GridView that, using client-side techniques, provides a means to quickly check or uncheck all row-level CheckBoxes. The header CheckBox, along with the "Check All" and "Uncheck All" buttons, provide the user with multiple ways for checking or unchecking all of the grid's CheckBoxes. Since client-side script is used to handle checking and unchecking the CheckBoxes, the interface provides a snappy user experience."</em> <p><a href="http://aspnet.4guysfromrolla.com/articles/053106-1.aspx" target="_blank">http://aspnet.4guysfromrolla.com/articles/053106-1.aspx</a></p>Matt PaveyASP.Nethttp://www.pavey.net/?BlogID=4632008-05-22 09:47:09LINQ Dynamic Querieshttp://www.pavey.net/?BlogID=462<div>I came across an article this morning that helped me with a LINQ query issue that I was trying to work through regarding dynamic queries.</div> <div>&nbsp;</div> <div><a href="http://www.rocksthoughts.com/blog/archive/2008/01/24/linq-to-sql-dynamic-queries.aspx" target="_blank">http://www.rocksthoughts.com/blog/archive/2008/01/24/linq-to-sql-dynamic-queries.aspx</a></div> <div>&nbsp;</div> <div>My situation was very similar; however, in my case I was querying an ENTITY rather than SQL directly; however, the same rules applied.</div> <div>&nbsp;</div> <div>I knew I could easily write a query that was <u>not</u> type safe and <u>not</u> checked at compile time; however, the thought of doing that really bothered me because I wanted to leverage the full power of LINQ and keep everything type safe and checked at compile time.</div> <div>&nbsp;</div> <div>I ended up taking advantage of Lambda Expressions:</div> <font size="1"><font color="#0000ff"> <div><br /> Public</font> <font color="#0000ff">Function</font> Search(<font color="#0000ff">ByVal</font>&nbsp;Name <font color="#0000ff">As</font> <font color="#0000ff">String</font>, <font color="#0000ff">ByVal</font>&nbsp;City <font color="#0000ff">As</font> <font color="#0000ff">String</font>) <font color="#0000ff">As</font> IEnumerable(<font color="#0000ff">Of</font> MyTable)<br /> &nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1"><font color="#0000ff">Dim</font> MyEntities <font color="#0000ff">As</font> <font color="#0000ff">New</font> DbEntities()<br /> &nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1"><font color="#0000ff">Dim</font> MyQuery <font color="#0000ff">As</font> ObjectQuery(<font color="#0000ff">Of</font> MyTable) = MyEntities.MyTableSet<br /> &nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1"><font color="#0000ff">Dim</font> MyResults = <font color="#0000ff">From</font> x <font color="#0000ff">In</font> MyQuery <font color="#0000ff">Select</font> x<br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1"><font color="#0000ff">If</font> <font color="#0000ff">Not</font> IsBlank(Name) <font color="#0000ff">Then<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font><font size="1">MyResults = MyResults.Where(<font color="#0000ff">Function</font>(e) e.Name.Equals(Name))<br /> &nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1"><font color="#0000ff">End</font> <font color="#0000ff">If</font></font></div> <div>&nbsp;</div> <div><font size="1"><font color="#0000ff">&nbsp;&nbsp;&nbsp;&nbsp; If</font> <font color="#0000ff">Not</font> IsBlank(City) </font><font color="#0000ff"><font size="1">Then<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font><font size="1">MyResults = MyResults.Where(<font color="#0000ff">Function</font>(e) e.City.Equals(City))<br /> &nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1"><font color="#0000ff">End</font> <font color="#0000ff">If<br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp; </font></font><font size="1"><font color="#0000ff">Return</font> MyResults.AsEnumerable<br /> </font><font size="1"><font color="#0000ff">End Function</font><font color="#0000ff" size="2"></div> </font></font> <div>&nbsp;</div> <div>More information on Lambda Expressions can be found here:</div> <div>&nbsp;</div> <div><a href="http://weblogs.asp.net/scottgu/archive/2007/04/08/new-orcas-language-feature-lambda-expressions.aspx" target="_blank">http://weblogs.asp.net/scottgu/archive/2007/04/08/new-orcas-language-feature-lambda-expressions.aspx</a></div>Matt PaveyLINQhttp://www.pavey.net/?BlogID=4622008-05-06 10:46:50ADO.NET Entity Framework Beta 3http://www.pavey.net/?BlogID=461<div>I started working on a new application for a client this week that is going to use the ADO.NET Entity Framework. Since it is not final release yet I had to download and setup the ADO.NET Entity Framework Beta 3. It wasn't too bad to get installed but I did run into a few issues along the way that I thought I'd share to save you some time if you end up having to do something similar.</div> <div>&nbsp;</div> <div>I ended up having to install the following in this order:</div> <div>&nbsp;</div> <div><strong>ADO.NET Entity Framework Beta 3</strong></div> <div><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=15DB9989-1621-444D-9B18-D1A04A21B519&amp;displaylang=en" target="_blank">http://www.microsoft.com/downloads/details.aspx?FamilyId=15DB9989-1621-444D-9B18-D1A04A21B519&amp;displaylang=en</a></div> <div>&nbsp;</div> <div><strong>ADO.NET Entity Framework Tools Preview can only be installed if a necessary Visual Studio patch is installed.</strong></div> <div><a href="http://go.microsoft.com/fwlink/?LinkID=104985">http://go.microsoft.com/fwlink/?LinkID=104985</a></div> <div>&nbsp;</div> <div><strong>ADO.Net Entity Framework Tools Dec 07 Community Technology Preview</strong></div> <div><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=D8AE4404-8E05-41FC-94C8-C73D9E238F82&amp;displaylang=en" target="_blank">http://www.microsoft.com/downloads/details.aspx?FamilyId=D8AE4404-8E05-41FC-94C8-C73D9E238F82&amp;displaylang=en</a></div> <div>&nbsp;</div> <div>At this point I had everything installed so I could add a <em>ADO.NET Entity Data Model</em> to my project.</div> <div>&nbsp;</div> <div>Another good resource for ADO.NET related info can be found here:</div> <div>&nbsp;</div> <div><a href="http://blogs.msdn.com/adonet/" target="_blank">http://blogs.msdn.com/adonet/</a></div> <div>&nbsp;</div> <div>One other thing I did notice when working with the <em>ADO.NET Entity Data Model</em> was that it all seemed to be very straight forward to setup and test if your UI and data access were in the same project; however, I found that when setting up a n-tier architecture I ran into some annoyances. The data layer I setup contained my <em>ADO.NET Entity Data Model</em> and it automatically creates an <strong>App.Config</strong> file with the necessary connection information and it creates the <strong>.csdl </strong>file, <strong>.ssdl</strong> file and <strong>.msl</strong> file in the data layer's /bin folder; however, when you add a reference to your data layer from your UI or business layer it does <u>not</u> automatically copy the connection string information into your <strong>Web.config</strong> file and it does <u>not</u> copy the <strong>.csdl </strong>file, <strong>.ssdl</strong> file and <strong>.msl</strong> file into the web application's /bin folder. So I ran into error messages until I finally figured out was going on. </div> <div>&nbsp;</div> <div>To work arond this I created a <strong>Config/ConnectionStrings.config</strong> file and copied the connection information from the <strong>App.Config</strong> file into the new config file and had the <strong>Web.config</strong> reference the new config file. Then I copied the <strong>.csdl </strong>file, <strong>.ssdl</strong> file and <strong>.msl</strong> file into the web application's /bin folder. Once I did this I was able to use the <em>ADO.NET Entity Data Model</em> as my data access and isolate the data access to the data layer. The issue with this is that if you change your model you have to manually copy the files to the web application's /bin folder again. I'm hoping that I'm either just not doing something right or this is just because it is still Beta and will be easier in the final release.</div> <div>&nbsp;</div> <div>I also found that quite a few code samples&nbsp;I came across had the <em>Using ... End Using</em> notation around their entity code; however anytime I returned a generic list, for example IEnumerable(Of T), from the data layer to another layer the connection would be lost and I would get an error that said:</div> <div>&nbsp;</div> <div><em>A connection string must be set on the connection before attempting the operation.</em></div> <div>&nbsp;</div> <div>It wasn't apparent to me what the problem was initially but then I took out the <em>Using ... End Using</em> notation and everything worked perfect. The <em>End Using</em> code from the code samples was forcing certain objects to be destroyed, including the connection.</div> <div>&nbsp;</div> <div>I've tested retrieving data, adding data, deleting data, updating data, filtering data using standard LINQ syntax as well as Lambda Expressions and binding IEnumerable(Of T) data to a GridView.</div> <div>&nbsp;</div> <div>So aside from the minor annoyances I ran into along the way I now have a working project that uses the <em>ADO.NET Entity Data Model</em>.</div>Matt PaveyLINQhttp://www.pavey.net/?BlogID=4612008-05-06 10:29:01Temporary Tables and Dynamic SQLhttp://www.pavey.net/?BlogID=460<div>When programming in SQL sometimes you need to generate temporary tables inside a stored procedure. That's pretty straight forward with code like this:</div> <div><font color="#0000ff" size="2"><font size="1"></font></font>&nbsp;</div> <div><font color="#0000ff" size="2"><font size="1">SELECT&nbsp;&nbsp;&nbsp;&nbsp; </font></font><font size="1">TrackingGroupID<font color="#808080">,<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></font><font size="1">Tag</font></div> <div><font size="1"><font color="#0000ff">INTO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font>#temp<br /> </font><font size="1"><font color="#0000ff">FROM</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyTable</font><font size="2"></div> </font> <div>&nbsp;</div> <div>And you can access #temp in the rest of your stored procedure and drop the temp table when complete.</div> <div>&nbsp;</div> <div><font color="#0000ff" size="2"><font size="1"><font color="#008000" size="1">-- testing<br /> </font><font color="#0000ff">SELECT</font><font color="#000000"> </font><font color="#ff00ff">COUNT</font><font color="#808080">(*)</font><font color="#000000"> </font><font color="#0000ff">FROM</font><font color="#000000"> #temp</font></font></font></div> <div><font color="#0000ff" size="2"><font size="1"></font></font>&nbsp;</div> <div><font color="#0000ff" size="2"><font size="1"><font color="#008000">-- drop temp table</font></font></font></div> <div><font color="#0000ff" size="2"><font size="1"><font color="#0000ff">DROP</font><font color="#000000"> </font><font color="#0000ff">TABLE</font><font size="2"><font color="#000000" size="1"> #temp</font></font></font></font></div> <div><font color="#0000ff" size="2"><font size="1"><font size="2"><font color="#000000" size="1"></font></font></font></font>&nbsp;</div> <div>But if you ever have a situation where you also need to&nbsp;use dynamic SQL you&nbsp;will likely have scope issues. In my particular case I ran into a situation where I needed to apply a dynamic filter to a query and store that data in a temporary table so I could access it after the filter was applied and do further manipulation and analysis and grouping with the data.</div> <div>&nbsp;</div> <div>Note: Typically when I work with temp tables I try to use tables-variables like so:</div> <div>&nbsp;</div> <div><font color="#008000" size="1">-- create temp table<br /> </font><font color="#0000ff"><font size="1">DECLARE</font></font><font size="1"> @Temp <font color="#0000ff">TABLE<br /> </font></font><font color="#808080" size="1">(<br /> &nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1">TrackingGroupID&nbsp; <font color="#0000ff">INT</font><font color="#808080">,<br /> &nbsp;&nbsp;&nbsp;&nbsp; </font></font><font size="1">Tag&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000ff">VARCHAR</font><font color="#808080">(</font>50<font color="#808080">)</font> <font color="#808080">NOT</font> <font color="#808080">NULL</font> <font color="#0000ff">DEFAULT</font> <font color="#ff0000">''<br /> </font></font><font color="#808080" size="1">)</div> </font> <div>&nbsp;</div> <div>However, in this case I was not able to get a table-variable to work. So I ended up using a #temp table instead.</div> <div>&nbsp;</div> <div>My first attempt looked something like this:</div> <div><font color="#008000" size="1"></font>&nbsp;</div> <div><font color="#008000" size="1">-- declare variables<br /> </font><font color="#0000ff"><font size="1">DECLARE</font></font><font size="1"> @SQL <font color="#0000ff">VARCHAR</font><font color="#808080">(</font>8000<font color="#808080">)</font></font></div> <div>&nbsp;</div> <div><font color="#008000" size="1">-- apply filter<br /> </font><font color="#0000ff"><font size="1">SET</font></font><font size="1"> @SQL <font color="#808080">=</font> </font><font color="#ff0000"><font size="1">'SELECT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TrackingGroupID,<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1">Tag<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font size="1">INTO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #temp<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1">FROM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyTable<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1">WHERE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1=1 '</font></font><font size="1"> <font color="#808080">+</font> @Where <font color="#808080">+</font> </font><font color="#ff0000"><font size="1">' <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1">GROUP BY&nbsp; TrackingGroupID, Tag'<br /> <br /> </font></font><font color="#008000" size="1">-- apply filter<br /> </font><font color="#0000ff"><font size="1">EXEC</font></font><font size="1"><font color="#808080">(</font>@SQL<font color="#808080">)<br /> <br /> </font></font><font color="#008000" size="1">-- do further manipulation or analysis on #temp table<br /> <font color="#808080" size="2"><font size="1">....</font></font></font><font size="1"><br /> <br /> </font><font color="#008000" size="1">-- drop temp table<br /> </font><font color="#0000ff"><font size="1">DROP</font></font><font size="1"> <font color="#0000ff">TABLE</font> #temp</font><font size="2"></div> </font> <div>&nbsp;</div> <div>But I received this error:</div> <div><font size="1"></font>&nbsp;</div> <div><font size="1">Msg 208, Level 16, State 0, Line 18<br /> Invalid object name '#temp'.</font><font size="1"></div> </font> <div>&nbsp;</div> <div> <div>I knew it was a scoping issue, but I wasn't sure how to work around it exactly. Researching on Google I came across this article:</div> <div>&nbsp;</div> </div> <div><a href="http://blog.shkedy.com/2007/01/temporary-tables-and-dynamic-sql.html" target="_blank">http://blog.shkedy.com/2007/01/temporary-tables-and-dynamic-sql.html</a></div> <div>&nbsp;</div> <div><em>"The problem here is the scope of the session. When we execute dynamic sql via EXEC or sp_executesql a new scope is created for a child session. Any objects created in that session are dropped as soon as the session is closed."</em></div> <div>&nbsp;</div> <div>So I modified my code like so:</div> <div>&nbsp;</div> <div><font color="#008000" size="1">-- create temp table</font></div> <div><font color="#0000ff"><font size="1">CREATE</font></font><font size="1"> <font color="#0000ff">TABLE</font> #temp<br /> </font><font color="#808080" size="1">(<br /> &nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1">TrackingGroupID&nbsp; <font color="#0000ff">INT</font></font><font color="#808080"><font size="1">,<br /> &nbsp;&nbsp;&nbsp;&nbsp; </font></font><font size="1">Tag&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000ff">VARCHAR</font><font color="#808080">(</font>50<font color="#808080">)</font> <font color="#808080">NOT</font> <font color="#808080">NULL</font> <font color="#0000ff">DEFAULT</font> <font color="#ff0000">''<br /> </font></font><font color="#808080" size="1">)</font></div> <div>&nbsp;</div> <div><font color="#008000" size="1">-- declare variables<br /> </font><font color="#0000ff"><font size="1">DECLARE</font></font><font size="1"> @SQL <font color="#0000ff">VARCHAR</font><font color="#808080">(</font>8000<font color="#808080">)</font></font></div> <div>&nbsp;</div> <div><font color="#008000" size="1">-- apply filter<br /> </font><font color="#0000ff"><font size="1">SET</font></font><font size="1"> @SQL <font color="#808080">=</font> </font><font color="#ff0000"><font size="1">'INSERT INTO #temp<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1">(TrackingGroupID, Tag)<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1">SELECT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TrackingGroupID,<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1">Tag<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1">FROM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyTable<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1">WHERE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1=1 '</font></font><font size="1"> <font color="#808080">+</font> @Where <font color="#808080">+</font> </font><font color="#ff0000"><font size="1">' <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1">GROUP BY&nbsp; TrackingGroupID, Tag'</font></font></div> <div>&nbsp;</div> <div><font color="#008000" size="1">-- apply filter<br /> </font><font color="#0000ff"><font size="1">EXEC</font></font><font size="1"><font color="#808080">(</font>@SQL<font color="#808080">)</font></font></div> <div>&nbsp;</div> <div><font color="#008000" size="1"><font color="#008000" size="2"><font size="1">-- do further manipulation or analysis on #temp table<br /> </font></font><font color="#808080" size="2"><font size="1">....</font></font></font></div> <div>&nbsp;</div> <div><font color="#008000" size="1">-- drop temp table<br /> </font><font color="#0000ff"><font size="1">DROP</font></font><font size="1"> <font color="#0000ff">TABLE</font> #temp</font><font size="2"></div> </font> <div>&nbsp;</div> <div>Now I had access to the #temp table throughout the scope of the stored procedure!</div> <div>&nbsp;</div> <div><em>I've been told that ##temp might have solved it also since it's global; however, I'm not as familiar with ## so I didn't go down that road.</em></div>Matt PaveySQL Serverhttp://www.pavey.net/?BlogID=4602008-05-01 08:54:27SQL Server 2008 New DATETIME DataTypeshttp://www.pavey.net/?BlogID=458<em>"The DATETIME function&#8217;s major change in SQL Server 2008 is the four DATETIME data types introduced. They are DATE, TIME, DATETIMEOFFSET and DATETIME2. IN addition to these newly introduced data types, there are new DATETIME functions all well."</em> <p><a href="http://www.sql-server-performance.com/articles/dev/datetime_2008_p1.aspx" target="_blank">http://www.sql-server-performance.com/articles/dev/datetime_2008_p1.aspx</a></p>Matt PaveySQL Serverhttp://www.pavey.net/?BlogID=4582008-04-18 09:46:05SQL Server 2008 Demos and Videoshttp://www.pavey.net/?BlogID=457Learn more about SQL Server 2008 through these demos and videos. <p><a href="http://www.microsoft.com/sqlserver/2008/en/us/demos.aspx" target="_blank">http://www.microsoft.com/sqlserver/2008/en/us/demos.aspx</a></p> I found the <em>Application Development Videos</em> particularly useful.Matt PaveySQL Serverhttp://www.pavey.net/?BlogID=4572008-04-17 21:56:14Enterprise Library 4.0http://www.pavey.net/?BlogID=456<a class="" title="EntLib4.0 March 2008 CTP download site" href="https://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=entlib&amp;ReleaseId=12142" target="_blank">Enterprise Library 4.0 March 2008 CTP download site</a>Matt Pavey.Nethttp://www.pavey.net/?BlogID=4562008-04-02 15:11:06Sys WebForms Page Request Manager Parser Error Exceptionhttp://www.pavey.net/?BlogID=455<div><em>"If you've used the </em><a href="http://ajax.asp.net/" target="_blank"><em>Microsoft ASP.NET AJAX</em></a><em> </em><a href="http://ajax.asp.net/docs/tutorials/UpdatePanelTutorials.aspx" target="_blank"><em>UpdatePanel</em></a><em> control, there's a good chance you've hit the Sys.WebForms.PageRequestManagerParserErrorException error."</em></div> <div><br /> This article provides some details on what this error is, common reasons it occurs, and ways to avoid getting the error.</div> <div>&nbsp;</div> <div><a href="http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx" target="_blank">http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx</a></div>Matt PaveyAJAXhttp://www.pavey.net/?BlogID=4552008-03-26 14:57:17MSXML2.ServerXMLHTTPhttp://www.pavey.net/?BlogID=454<div>I don't get to dabble in classic ASP much anymore, which is ok with me, but for the first time in years I had to debug some ASP code this morning to figure out an error for someone who is consuming one of our webservices.</div> <div>&nbsp;</div> <div>The code was as simple as this:</div> <div><font color="#0000ff" size="2"><font size="1"></font></font>&nbsp;</div> <div><font color="#0000ff" size="2"><font size="1">Set</font></font><font size="1"> MyXmlHttp = Server.CreateObject(<font color="#a31515">"MSXML2.ServerXMLHTTP"</font>)<br /> </font><font size="1">MyXmlHttp.open <font color="#a31515">"get"</font>, <font color="#a31515">"https://www.test.com/webservice.asmx/GetSites?StudyID=35"</font>, <font color="#0000ff">False<br /> </font></font><font size="1">MyXmlHttp.setRequestHeader <font color="#a31515">"Content-Type"</font>, <font color="#a31515">"text/xml"<br /> </font></font><font size="1">MyXmlHttp.send()<br /> </font><font size="1">XmlData = MyXmlHttp.responseText</font></div> <div> <p><font size="1">Response.Write(Server.HtmlEncode(XmlData))</font><font size="2"></p> </font></div> <div>The error was:</div> <div>&nbsp;</div> <div><strong>HTTP Error 403.1 - Forbidden: Execute access is denied</strong></div> <div>&nbsp;</div> <div>Can you spot the problem?</div> <div>&nbsp;</div> <div><font size="1">MyXmlHttp.open <font color="#a31515">"GET"</font>, <font color="#a31515">"https://www.test.com/webservice.asmx/GetSites?StudyID=35"</font>, <font color="#0000ff">False</font></font></div> <div>&nbsp;</div> <div>It might not be obvious what I changed, but simply changing the method from "get" to "GET" fixed the problem.</div> <div>&nbsp;</div> <div>I wondered if this was a bug but this MSDN article seems to confirm that the method is case-sensitive and must be in UPPER case.</div> <div>&nbsp;</div> <div><a href="http://msdn2.microsoft.com/en-us/library/ms763809(VS.85).aspx" target="_blank">http://msdn2.microsoft.com/en-us/library/ms763809(VS.85).aspx</a></div> <div>&nbsp;</div> <div><em>"The HTTP method used to open the connection, such as PUT or PROPFIND. For ServerXMLHTTP, this parameter is case-sensitive and the method name must be entered in all upper-case letters."</em></div>Matt PaveyASPhttp://www.pavey.net/?BlogID=4542008-03-14 11:42:48Creating a Data Access Layer with LINQ to SQLhttp://www.pavey.net/?BlogID=453<div>Here's an interesting article regarding the challenges of creating a true data access layer using LINQ to SQL.</div> <div>&nbsp;</div> <div><a href="http://krisvandermotten.wordpress.com/2006/11/30/creating-a-data-access-layer-with-linq-to-sql-part-2/" target="_blank">http://krisvandermotten.wordpress.com/2006/11/30/creating-a-data-access-layer-with-linq-to-sql-part-2/</a></div> <div>&nbsp;</div> <div>It's an older article; however, it covers some interesting questions. I'd recommend in addition to reading the article actually reading through the responses as well at the end of the article.</div> <div>&nbsp;</div> <div><em>"... it is absolutely not clear where a developer should draw the line between what&#8217;s business logic, and what belongs in the DAL ..."</em></div> <div>&nbsp;</div> <div>It seems the primary concerns are what exactly the data access layer should be returning and where exactly the actual query should be executed.</div> <div>&nbsp;</div> <div><em>"That is, the data access layer should be returning just arrays of entities (T[] or IEnumerable). It should [not] be returning IQueryable. Returning IQueryable gives you more rope to hang yourself with because (i) the caller (business logic layer) can redefine the query that ultimately gets sent to the database (ii) the caller (business logic layer) now executes the query because of deferred query execution (iii) the distinction between the caller (business logic layer) and the DAL blurs."</em></div> <div>&nbsp;</div> <div>If you return IQueryable(Of T)&nbsp;objects from the data access layer the queries are not actually getting 'executed' until you use them later, for example when you enumerate over the IQueryable(Of T)&nbsp;data in your business or UI. So by returning&nbsp;List(Of T),&nbsp;IEnumerable(Of T) or an Array&nbsp;of entities you draw a fine line with what the data access layer handles vs. what the business layer or UI handles.</div> <div>&nbsp;</div> <div>I've played around with returning IQueryable(Of T), List(Of T), IEnumerable(Of T)&nbsp;and an Array of entities. Each has their own advantages or caveats. My research so far leads me to believe that IEnumerable(Of T) is the preferred approach.</div> <div>&nbsp;</div> <div><em>"The main design pattern that arises from LINQ is to <strong>prefer IEnumerable(Of T)</strong>. This is because LINQ operates on IEnumerable(Of T), and if you design your application around IEnumerable(Of T), you will find many places where a LINQ query will provide an elegant solution to your problem."</em></div> <div><em></em>&nbsp;</div> <div>Here's a couple articles that discuss IEnumerable(Of T)&nbsp;in more detail:</div> <div>&nbsp;</div> <div><a href="http://www.winterdom.com/weblog/2006/10/13/RediscoveringIEnumerableltTgt.aspx" target="_blank">http://www.winterdom.com/weblog/2006/10/13/RediscoveringIEnumerableltTgt.aspx</a></div> <div>&nbsp;</div> <div><a href="http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/" target="_blank">http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/</a></div> <div>&nbsp;</div> <div>It will be interesting to see how each developer decides to implement LINQ into their projects and how consistent it will be with what others are doing.</div> <div><em></em>&nbsp;</div> <div><em>"I hate it when developers have to make choices like that during routine development. Choosing takes time, and that&#8217;s not likely to improve productivity. But much worse is the fact that different developers will make different choices. Even a single developer may make different choices from one day to the next. That leads to inconsistencies in the code. Developers will spend more time trying to understand the code they&#8217;re reading, because it doesn&#8217;t always follow the same pattern. That&#8217;s bad for productivity. In the worst case scenario, developers start rewriting each other&#8217;s code, just so it matches their choice of the day. That kills productivity."</em></div> <div>&nbsp;</div> <div>I think having a nice set of standards before fully integrating LINQ into a project is going to be a smart move, especially in team environments.</div>Matt PaveyLINQhttp://www.pavey.net/?BlogID=4532008-03-02 11:48:02Extension Methodshttp://www.pavey.net/?BlogID=450<div><em>"Extension methods allow developers to add new methods to the public contract of an existing CLR&nbsp;type, without having to sub-class it or recompile the original type.&nbsp;&nbsp;Extension Methods help blend the flexibility of "duck typing" support popular within dynamic languages today with the performance and compile-time validation of strongly-typed languages."</em></div> <div>&nbsp;</div> <div><a href="http://weblogs.asp.net/scottgu/archive/2007/03/13/new-orcas-language-feature-extension-methods.aspx" target="_blank">http://weblogs.asp.net/scottgu/archive/2007/03/13/new-orcas-language-feature-extension-methods.aspx</a></div>Matt Pavey.Nethttp://www.pavey.net/?BlogID=4502008-02-26 16:42:50LINQ to XMLhttp://www.pavey.net/?BlogID=449<em>"LINQ to XML is a built-in LINQ data provider that is implemented within the "System.Xml.Linq" namespace in .NET 3.5."</em> <p><em>"LINQ to XML provides a clean programming model that enables you to read, construct and write XML data.&nbsp; You can use LINQ to XML to perform LINQ queries over XML that you retrieve from the file-system, from a remote HTTP URL or&nbsp;web-service, or from any in-memory XML content."</em></p> <p><em>"LINQ to XML provides much richer (and easier) querying and data shaping support than the low-level XmlReader/XmlWriter API in .NET today.&nbsp; It also ends up being much more efficient (and uses much less memory) than the DOM API that XmlDocument provides."</em></p> <p><a href="http://weblogs.asp.net/scottgu/archive/2007/08/07/using-linq-to-xml-and-how-to-build-a-custom-rss-feed-reader-with-it.aspx" target="_blank">http://weblogs.asp.net/scottgu/archive/2007/08/07/using-linq-to-xml-and-how-to-build-a-custom-rss-feed-reader-with-it.aspx</a></p>Matt PaveyLINQhttp://www.pavey.net/?BlogID=4492008-02-26 16:32:45LINQ to SQL Debug Visualizerhttp://www.pavey.net/?BlogID=448<em>"One of the nice development features that LINQ to SQL supports is the ability to use a "debug visualizer" to hover over a LINQ expression while&nbsp;in the VS 2008 debugger and inspect the raw SQL that the ORM will ultimately execute at runtime when evaluating the LINQ query expression."</em><br /> <div>&nbsp;</div> <div><a href="http://weblogs.asp.net/scottgu/archive/2007/07/31/linq-to-sql-debug-visualizer.aspx" target="_blank">http://weblogs.asp.net/scottgu/archive/2007/07/31/linq-to-sql-debug-visualizer.aspx</a></div>Matt PaveyLINQhttp://www.pavey.net/?BlogID=4482008-02-26 16:25:10LINQ to SQLhttp://www.pavey.net/?BlogID=446<div class="ExternalClass7293AF08783E406E9840DEB4D2005E59"><em>"Developers can use LINQ with any data source.&nbsp; They can&nbsp;express efficient query behavior in their programming language of choice, optionally transform/shape data query results into whatever format they want, and then easily&nbsp;manipulate the results.&nbsp;&nbsp;LINQ-enabled&nbsp;languages can provide full type-safety and&nbsp;compile-time checking of query expressions, and development tools can provide full&nbsp;intellisense, debugging, and rich refactoring&nbsp;support when writing LINQ code." </em> <div><em>&nbsp;</em></div> <div><em>"LINQ to SQL is an </em><a href="http://en.wikipedia.org/wiki/Object-relational_mapping" target="_blank"><em>O/RM</em></a><em> (object relational mapping) implementation that ships&nbsp;in the .NET Framework "Orcas" release, and which allows you to model&nbsp;a relational database&nbsp;using .NET classes.&nbsp; You can then query the database using LINQ, as well as update/insert/delete data from it."</em></div> <p><em>"LINQ to SQL fully supports transactions, views, and stored procedures.&nbsp; It also provides an easy way to integrate data validation and business logic rules into your data model."</em></p> <div> <li><a href="http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx" target="_blank">Part 1: Introduction to LINQ to SQL</a> <li><a href="http://weblogs.asp.net/scottgu/archive/2007/05/29/linq-to-sql-part-2-defining-our-data-model-classes.aspx" target="_blank">Part 2: Defining our Data Model Classes</a> <li><a href="http://weblogs.asp.net/scottgu/archive/2007/06/29/linq-to-sql-part-3-querying-our-database.aspx" target="_blank">Part 3: Querying our Database</a> <li><a href="http://weblogs.asp.net/scottgu/archive/2007/07/11/linq-to-sql-part-4-updating-our-database.aspx" target="_blank">Part 4: Updating our Database</a> <li><a href="http://weblogs.asp.net/scottgu/archive/2007/07/16/linq-to-sql-part-5-binding-ui-using-the-asp-linqdatasource-control.aspx" target="_blank">Part 5: Binding UI using the ASP:LinqDataSource Control</a> <li><a href="http://weblogs.asp.net/scottgu/archive/2007/08/16/linq-to-sql-part-6-retrieving-data-using-stored-procedures.aspx" target="_blank">Part 6: Retrieving Data Using Stored Procedures</a> <li><a href="http://weblogs.asp.net/scottgu/archive/2007/08/23/linq-to-sql-part-7-updating-our-database-using-stored-procedures.aspx" target="_blank">Part 7: Updating our Database using Stored Procedures</a> <li><a href="http://weblogs.asp.net/scottgu/archive/2007/08/27/linq-to-sql-part-8-executing-custom-sql-expressions.aspx" target="_blank">Part 8: Executing Custom SQL Expressions</a> <li><a href="http://weblogs.asp.net/scottgu/archive/2007/09/07/linq-to-sql-part-9-using-a-custom-linq-expression-with-the-lt-asp-linqdatasource-gt-control.aspx" target="_blank">Part 9: Using a Custom LINQ Expression with the &lt;asp:LinqDatasource&gt; control</a> </li> </div> </div> <br />Matt PaveyLINQhttp://www.pavey.net/?BlogID=4462008-02-26 13:37:35The ADO.NET Entity Framework Overviewhttp://www.pavey.net/?BlogID=445<em>"When one takes a look at the amount of code that the average application developer must write to address the impedance mismatch across various data representations (for example objects and relational stores) it is clear that there is an opportunity for improvement. Indeed, there are many scenarios where the right framework can empower an application developer to focus on the needs of the application as opposed to the complexities of bridging disparate data representations."</em> <p><em>"A primary goal of the upcoming version of ADO.NET is to raise the level of abstraction for data programming, thus helping to eliminate the impedance mismatch between data models and between languages that application developers would otherwise have to deal with. Two innovations that make this move possible are Language-Integrated Query and the ADO.NET Entity Framework. The Entity Framework exists as a new part of the ADO.NET family of technologies. ADO.NET will LINQ-enable many data access components: LINQ to SQL, LINQ to DataSet and LINQ to Entities."</em></p> <p><em>"This document describes the ADO.NET Entity Framework, what problem spaces it is targeting and how its various components address those problems."</em></p> <p><a href="http://msdn2.microsoft.com/en-us/library/aa697427(VS.80).aspx" target="_blank">http://msdn2.microsoft.com/en-us/library/aa697427(VS.80).aspx</a></p>Matt PaveyLINQhttp://www.pavey.net/?BlogID=4452008-02-26 13:27:44First Look at Silverlight 2http://www.pavey.net/?BlogID=444<div><em>"Silverlight 2 includes a cross-platform, cross-browser version of the .NET Framework, and enables a rich .NET development platform that runs in the browser.&nbsp; Developers can write Silverlight applications using any .NET language (including VB, C#, JavaScript, IronPython and IronRuby).&nbsp; We will ship Visual Studio 2008 and Expression Studio tool support that enables great developer / designer workflow and integration when building Silverlight applications."</em></div> <div>&nbsp;</div> <div><a href="http://weblogs.asp.net/scottgu/archive/2008/02/22/first-look-at-silverlight-2.aspx" target="_blank">http://weblogs.asp.net/scottgu/archive/2008/02/22/first-look-at-silverlight-2.aspx</a></div> <div>&nbsp;</div> <div>Silverlight 2 Tutorials: Building A Simple Digg Client</div> <div>&nbsp;</div> <div> <li><a href="http://weblogs.asp.net/scottgu/pages/silverlight-tutorial-part-1-creating-quot-hello-world-quot-with-silverlight-2-and-vs-2008.aspx" target="_blank">Part 1: Creating "Hello World" with Silverlight 2 and VS 2008</a> <li><a href="http://weblogs.asp.net/scottgu/pages/silverlight-tutorial-part-2-using-layout-management.aspx" target="_blank">Part 2: Using Layout Management</a> <li><a href="http://weblogs.asp.net/scottgu/pages/silverlight-tutorial-part-3-using-networking-to-retrieve-data-and-populate-a-datagrid.aspx" target="_blank">Part 3: Using Networking to Retrieve Data and Populate a DataGrid</a> <li><a href="http://weblogs.asp.net/scottgu/pages/silverlight-tutorial-part-4-using-style-elements-to-better-encapsulate-look-and-feel.aspx" target="_blank">Part 4: Using Style Elements to Better Encapsulate Look and Feel</a> <li><a href="http://weblogs.asp.net/scottgu/pages/silverlight-tutorial-part-5-using-the-listbox-and-databinding-to-display-list-data.aspx" target="_blank">Part 5: Using the ListBox and DataBinding to Display List Data</a> <li><a href="http://weblogs.asp.net/scottgu/pages/silverlight-tutorial-part-6-using-user-controls-to-implement-master-detail-scenarios.aspx" target="_blank">Part 6: Using User Controls to Implement Master/Details Scenarios</a> <li><a href="http://weblogs.asp.net/scottgu/pages/silverlight-tutorial-part-7-using-control-templates-to-customize-a-control-s-look-and-feel.aspx" target="_blank">Part 7: Using Templates to Customize Control Look and Feel</a> <li><a href="http://weblogs.asp.net/scottgu/pages/silverlight-tutorial-part-8-creating-a-digg-desktop-application-using-wpf.aspx" target="_blank">Part 8: Creating a Digg Desktop Version of our Application using WPF</a> </li> </div>Matt PaveySilverlighthttp://www.pavey.net/?BlogID=4442008-02-26 13:23:55GridView BoundField with "mailto" email addresshttp://www.pavey.net/?BlogID=443<font color="#0000ff" size="2"> <p>&lt;</font><font color="#a31515" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#a31515" size="2">BoundField</font><font size="2"> </font><font color="#ff0000" size="2">DataField</font><font color="#0000ff" size="2">="Email"</font><font size="2"> </font><font color="#ff0000" size="2">HeaderText</font><font color="#0000ff" size="2">="Email"</font><font size="2"> </font><font color="#ff0000" size="2">SortExpression</font><font color="#0000ff" size="2">="Email"</font><font size="2"> </font><font color="#ff0000" size="2">HtmlEncode</font><font color="#0000ff" size="2">="False"</font><font size="2"> </font><font color="#ff0000" size="2">ReadOnly</font><font color="#0000ff" size="2">="True"</font><font size="2"> </font><font color="#ff0000" size="2">DataFormatString</font><font color="#0000ff" size="2">="&amp;lt;a href='mailto:{0}'&amp;gt;{0}&amp;lt;/a&amp;gt;"</font><font size="2"> </font><font color="#0000ff" size="2">/&gt;</p> </font>Matt Pavey.Nethttp://www.pavey.net/?BlogID=4432008-02-05 15:27:49IE 8: On the Path to Web Standards Compliance - ACID 2 Test Pass Completehttp://www.pavey.net/?BlogID=441<div><em><strong>Wed, Dec 19, 2007 4:36 PM</strong><br /> "The </em><a href="http://blogs.msdn.com/ie/" target="_blank"><em>IE team</em></a><em> has been very hard at work on IE 8 for the past several months and they hit a huge milestone last Friday evening. The IE dev team checked in a bunch of code that included several new features implemented in the core rendering engine that enable IE to pass the </em><a href="http://www.webstandards.org/action/acid2/" target="_blank"><em>ACID 2 test</em></a><em>! This is great news for web developers: IE 8 is going to be our most standards compliant browser to date. Passing ACID 2 is really a combined side effect of all the new features that have been developed for IE 8."</em></div> <div>&nbsp;</div> <div><a href="http://channel9.msdn.com/showpost.aspx?postid=367207" target="_blank">http://channel9.msdn.com/showpost.aspx?postid=367207</a></div>Matt PaveyOtherhttp://www.pavey.net/?BlogID=4412008-01-24 01:01:10101 LINQ Sampleshttp://www.pavey.net/?BlogID=440<div>Visual Basic</div> <div><a href="http://msdn2.microsoft.com/en-us/vbasic/bb688088.aspx" target="_blank">http://msdn2.microsoft.com/en-us/vbasic/bb688088.aspx</a></div> <div>&nbsp;</div> <div>C#</div> <div><a href="http://msdn2.microsoft.com/en-us/vcsharp/aa336746.aspx" target="_blank">http://msdn2.microsoft.com/en-us/vcsharp/aa336746.aspx</a></div>Matt PaveyLINQhttp://www.pavey.net/?BlogID=4402008-01-23 16:20:52Is LINQ the future of database development?http://www.pavey.net/?BlogID=439<div><em>The LINQ (.NET Language Integrated Query) Project is an initiative to standardize data access across data sources and development.</em></div> <div>&nbsp;&nbsp;</div> <div>This is an interesting article by Arthur Fuller&nbsp;that explains why he's <strong>not</strong> convinced that LINQ will revolutionize database application development.</div> <div>&nbsp;</div> <div><a href="http://articles.techrepublic.com.com/5100-9592-5897968.html" target="_blank">http://articles.techrepublic.com.com/5100-9592-5897968.html</a></div> <div>&nbsp;</div> <div>I can't say I completely agree or disagree with all of the comments he makes in the article; nonetheless, I found it an interesting read. Be sure to read the "c<em>omments on this article"</em> to see how certain people have reacted to both sides of the argument.</div> <div>&nbsp;</div> <div>Like Arthur Fuller I've always been a strong proponent of <strong><em>Whatever the back end <u>can</u> do, the back end <u>should</u> do</em></strong>. This certainly has to be looked at on a project by project basis, but typically the projects I'm involved in and architect have benefited from a separate data layer with stored procedures for data access. So naturally I had skepticism as I began reading, researching, and testing LINQ.</div> <div>&nbsp;</div> <div>With that said - I don't necessarily look at LINQ as having to move all back end code to the front end. I think it ends up being strictly up to how the solution is architected and how the developer wants to utilize it. Unfortunately, with LINQ in its infancy almost every code-snippet, documentation or article has some misleading examples that make it appear that all the data access code must now be moved to the front end of an application. I have to admit with&nbsp;my first several examples it was simple enough for me to drop a <em>DBML</em> file in the web project and write some quick code to test it. But of course after I saw it worked I immediately created a "Data" layer and moved the <em>DBML</em> file there and continued testing. That way the data access layer did just that, access data, and the front end could use the data accordingly.</div> <div>&nbsp;</div> <div>This comment seemed to sum up exactly what I was thinking as I waded through all the pros and cons of how LINQ will affect the future of database development:</div> <div>&nbsp;</div> <div><em>LINQ is a tier neutral technology. On the front end one can use LINQ to query returned datasets, XML files etc and on the back end to query a database. IMHO the back end (data access tier - DAC) is the only tier that is allowed to access data storage like SQL Server. The front end can manipulate returned data from the back end but not retrieve or update it without using the DAC. LINQ is merely a uniform way of accessing different data sources. New functionality like LINQ does not force bad coding style, that is left up to the creativity of the developer.</em></div> <div><em></em>&nbsp;</div> <div>So although no conclusive agreement has been reached in the development community regarding the future of LINQ, I am optimistic and look forward to learning more about it over the next several weeks and months...</div>Matt PaveyLINQhttp://www.pavey.net/?BlogID=4392008-01-23 00:43:36System.Data.Linq.Table Add and Remove Method Name Changeshttp://www.pavey.net/?BlogID=438<div class="ExternalClass57690E37603E488FA5CEB8996DF5DCC9"> <div> <div>If you tested BETA releases of Visual Studio 2008 and the .Net 3.5 Framework you'll find that some minor changes were made for the final release.</div> <div>&nbsp;</div> <div>In particular one issue I ran into this evening was testing and writing sample code that I found in the MSDN documentation that used the <strong>Add</strong> and <strong>Remove</strong> methods of the System.Data.Linq.Table class.</div> <div>&nbsp;</div> <div>The <strong>Add </strong>method was changed to <strong>InsertOnSubmit </strong>and the <strong>Remove </strong>method was changed to <strong>DeleteOnSubmit</strong>.</div> <div>&nbsp;</div> <div><em>While more wordy, the change was made to make them more explicitly describe their behavior.</em></div> </div> </div>Matt PaveyLINQhttp://www.pavey.net/?BlogID=4382008-01-22 21:54:54Microsoft .NET Framework 3.5http://www.pavey.net/?BlogID=437<div>Microsoft .NET Framework 3.5 contains many new features building incrementally upon .NET Framework 2.0 and 3.0, and includes .NET Framework 2.0 service pack 1 and .NET Framework 3.0 service pack 1.</div> <div>&nbsp;</div> <div><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=333325FD-AE52-4E35-B531-508D977D32A6&amp;displaylang=en" target="_blank">http://www.microsoft.com/downloads/details.aspx?FamilyID=333325FD-AE52-4E35-B531-508D977D32A6&amp;displaylang=en</a></div> <div>&nbsp;</div> <div><span>.NET Framework 3.5 builds incrementally on the new features added in .NET Framework 3.0. For example, feature sets in Windows Workflow Foundation (WF), Windows Communication Foundation (WCF), Windows Presentation Foundation (WPF) and Windows CardSpace. In addition, .NET Framework 3.5 contains a number of new features in several technology areas which have been added as new assemblies to avoid breaking changes. They include the following: <br /> <ul> <li>Deep integration of Language Integrated Query (LINQ) and data awareness. This new feature will let you write code written in LINQ-enabled languages to filter, enumerate, and create projections of several types of SQL data, collections, XML, and DataSets by using the same syntax. <li>ASP.NET AJAX lets you create more efficient, more interactive, and highly-personalized Web experiences that work across all the most popular browsers. <li>New Web protocol support for building WCF services including AJAX, JSON, REST, POX, RSS, ATOM, and several new WS-* standards. <li>Full tooling support in Visual Studio 2008 for WF, WCF, and WPF, including the new workflow-enabled services technology. <li>New classes in .NET Framework 3.5 base class library (BCL) that address many common customer requests.</span></li> </ul> </div>Matt Pavey.Nethttp://www.pavey.net/?BlogID=4372008-01-22 12:22:46Visual Studio 2008 & LINQhttp://www.pavey.net/?BlogID=436<div>I started using Visual Studio 2008 today. So far I haven't ran into any problems. In fact, I've tried it on Vista and XP and both installations went very smooth.</div> <div>&nbsp;</div> <div>I've tested a few different scenarios, inluding working with one of my Visual Studio 2005 .Net 2.0 applications without upgrading to .Net 3.5. I didn't have any noticeable problems in doing so and was able to work with the application as it were 2.0 as expected. And I had all the benefits of Visual Studio 2008. The intellisense for JavaScript was very slick. I don't typically have to write a ton of JavaScript code, but the fact that it's going to be easier to work with and debug is a very nice feature.</div> <div>&nbsp;</div> <div>I also tested converting an existing 2.0 application to 3.5. Again, I saw no noticeable problems. And once converted to 3.5 I had all the additional benefits of the 3.5 framework at my disposable.</div> <div>&nbsp;</div> <div>And lastly I created a .Net 3.5 web application from scratch and had no problems. I did some very basic testing initially, and even got involved in writing my first lines of LINQ code. Quite remarkable!</div> <div>&nbsp;</div> <div>Here's a great link for Visual Studio 2008 samples that was helpful for me to get started, particularly with LINQ.</div> <div>&nbsp;</div> <div><a href="http://msdn2.microsoft.com/en-us/bb330936.aspx" target="_blank">http://msdn2.microsoft.com/en-us/bb330936.aspx</a></div> <div>&nbsp;</div> <div>The "Hands On Labs" are perfect if you are just getting started with the LINQ syntax and LINQ to SQL syntax. The documents are available for VB and C#.</div> <div>&nbsp;</div> <div>In a matter of minutes I had a connection to a database and&nbsp;fully generated classes by dragging and dropping tables to my "LINQ to SQL Classes" file.</div> <div>&nbsp;</div> <div>The only code I had to write was to query the data using&nbsp;LINQ and do some basic operations on it.</div> <div>&nbsp;</div> <div>Definitely looking forward to getting more involved with Visual Studio 2008 and LINQ!</div>Matt PaveyLINQhttp://www.pavey.net/?BlogID=4362008-01-22 00:10:54VS 2008 Multi-Targeting Supporthttp://www.pavey.net/?BlogID=435<div><a href="http://weblogs.asp.net/scottgu/archive/2007/06/20/vs-2008-multi-targeting-support.aspx" target="_blank">http://weblogs.asp.net/scottgu/archive/2007/06/20/vs-2008-multi-targeting-support.aspx</a></div>Matt Pavey.Nethttp://www.pavey.net/?BlogID=4352008-01-21 15:06:47SCOPE_IDENTITY() vs. @@IDENTITY - Retrieving IDENTITY value for most recently added row in a tablehttp://www.pavey.net/?BlogID=434<div>This one is one of the basics that all SQL programmers learn at some point... Sometimes the hard way.</div> <div>&nbsp;</div> <div><font face="Verdana"><font size="1"><strong>@@IDENTITY returns the most recently created identity for your current connection</strong>, not necessarily the identity for the recently added row in a table.&nbsp;You could have a situation where there is a trigger that inserts a new record in a <strong>Logs Table</strong>, for example, when your Stored Procedure or INSERT SQL Statement inserts a record in the <strong>Orders Table</strong>.&nbsp;If you use <strong>@@IDENTITY</strong> to retrieve the identity of the new order, you will actually get the identity of the record added into the <strong>Log Table</strong> and not the <strong>Orders Table</strong>, which will create a nasty, nasty bug in your data access layer.</font></font></div> <div>&nbsp;</div> <div><font face="Verdana" size="1">To avoid the potential problems associated with someone adding a trigger later on, always use <strong>SCOPE_IDENTITY() to return the identity of the recently added row in your INSERT SQL Statement or Stored Procedure</strong>.</font></div> <div>&nbsp;</div> <div><a href="http://davidhayden.com/blog/dave/archive/2006/01/17/2736.aspx" target="_blank">http://davidhayden.com/blog/dave/archive/2006/01/17/2736.aspx</a></div> <div>&nbsp;</div> <div>Luckily today when some strange behavior occurred during our QA testing this was the first thing that I thought of, and sure enough, the original developer used <strong><font size="1">@@IDENTITY </font></strong>to get the newly inserted identity value, which at the time was perfectly correct to do; however, we've recently added some trigger functionality, which caused this behavior to produce incorrect results. Switching to&nbsp;<strong><font size="1">SCOPE_IDENTITY()&nbsp;</font></strong> fixed the problem. But this one is definitely one you want to remember if you are using triggers in your code.</div>Matt PaveySQL Serverhttp://www.pavey.net/?BlogID=4342008-01-11 16:55:23Setting a variable from dynamic SQLhttp://www.pavey.net/?BlogID=433<div>I don't have to do this very often, but it definitely comes in handy in certain situations.</div> <div><font color="#008000" size="2"></font>&nbsp;</div> <div><font color="#008000" size="1">-- setting a variable from dynamic sql</font></div> <div><font size="1"><font color="#0000ff">DECLARE</font> @MyValue <font color="#0000ff">INT</font></font></div> <div><font size="1"><font color="#0000ff">EXEC</font> <font color="#800000">sp_executesql</font> N<font color="#ff0000">'SELECT @MyValue = 999'</font><font color="#808080">,</font> N<font color="#ff0000">'@MyValue INT OUTPUT'</font><font color="#808080">,</font> @MyValue <font color="#0000ff">OUTPUT</font></font></div> <div><font size="1"><font color="#0000ff">SELECT</font> @MyValue</font></div> <div><font size="1"></font>&nbsp;</div> <div><font color="#008000" size="1">-- setting output parameter from dynamic stored procedure call</font></div> <div><font size="1"><font color="#0000ff">DECLARE</font> @OutputParameter <font color="#0000ff">VARCHAR</font><font color="#808080">(</font>100<font color="#808080">)</font></font></div> <div><font size="1"><font color="#0000ff">DECLARE</font> @Error <font color="#0000ff">INT</font></font></div> <div><font size="1"><font color="#0000ff">DECLARE</font> @SPName <font color="#0000ff">VARCHAR</font><font color="#808080">(</font>128<font color="#808080">)</font></font></div> <div><font size="1"><font color="#0000ff">DECLARE</font> @SPCall <font color="#0000ff">NVARCHAR</font><font color="#808080">(</font>128<font color="#808080">)</font></font></div> <div><font size="1"><font color="#0000ff">DECLARE</font> @RC <font color="#0000ff">INT</font></font></div> <div><font color="#0000ff" size="1"></font>&nbsp;</div> <div><font size="1"><font color="#0000ff">SELECT</font> @SPCall <font color="#808080">=</font> <font color="#ff0000">'EXEC '</font> <font color="#808080">+</font> @SPName <font color="#808080">+</font> <font color="#ff0000">' @OutputParameter OUTPUT'</font></font></div> <div><font size="1"><font color="#0000ff">EXEC</font> @RC <font color="#808080">=</font> <font color="#800000">sp_executesql</font> @SPCall<font color="#808080">,</font> N<font color="#ff0000">'@OutputParameter VARCHAR(100) OUTPUT'</font><font color="#808080">,</font> @OutputParameter <font color="#0000ff">OUTPUT</font></font></div> <div><font size="1"><font color="#0000ff">SELECT</font> @Error <font color="#808080">=</font> <font color="#ff00ff" size="1">@@Error</div> </font></font> <div>&nbsp;</div> <div>One example where this was useful for me was for converting a demormalized set of horizontal data to a normalized set of vertical data.</div> <div>&nbsp;</div> <div>The denormalized data contained a series of column names such as "200701", "200702", "200703", etc. for each month of the year. The file changes month to month and to minimize re-writing code each time a new file comes in I am able to import the data generically, determine the columns that are in the file, and get the value by setting a variable using dynamic SQL.</div> <div><font color="#008000" size="2"></font>&nbsp;</div> <div><font color="#008000" size="1">-- declare variables</font></div> <div><font size="1"><font color="#0000ff">DECLARE</font> @Total <font color="#0000ff">FLOAT</font></font></div> <div><font size="1"><font color="#0000ff">DECLARE</font> @SqlStatement <font color="#0000ff">NVARCHAR</font><font color="#808080">(</font>1000<font color="#808080">)</font></font></div> <div><font size="1"></font>&nbsp;</div> <div><font color="#008000" size="1">-- set default values</font></div> <div><font size="1"><font color="#0000ff">SET</font> @Total <font color="#808080">=</font> 0</font></div> <div><font size="1"><font color="#0000ff">SET</font> @SqlStatement <font color="#808080">=</font> <font color="#ff0000">'SELECT @Total = ['</font> <font color="#808080">+</font> @ColumnName <font color="#808080">+</font> <font color="#ff0000">'] FROM RawData WHERE RecordID = '</font> <font color="#808080">+</font> <font color="#ff00ff">CONVERT</font><font color="#808080">(</font><font color="#0000ff">VARCHAR</font><font color="#808080">,</font> @RecordID<font color="#808080">)</font></font></div> <div><font size="1"></font>&nbsp;</div> <div><font color="#008000" size="1">-- get the specified column value for the current record</font></div> <div><font size="1"><font color="#0000ff">EXEC</font> <font color="#800000">sp_executesql</font> @SqlStatement<font color="#808080">,</font> N<font color="#ff0000">'@Total FLOAT OUTPUT'</font><font color="#808080">,</font> @Total <font color="#0000ff">OUTPUT</font></font></div> <div><font color="#0000ff" size="2"></font>&nbsp;</div> <div>Enjoy!</div>Matt PaveySQL Serverhttp://www.pavey.net/?BlogID=4332008-01-11 16:54:16SQL Server GetAge Functionhttp://www.pavey.net/?BlogID=432<font color="#0000ff"><font size="1">SET</font></font><font size="1"> <font color="#0000ff">ANSI_NULLS</font> </font><font size="1"><font color="#0000ff">ON<br /> </font>GO<br /> <font color="#0000ff">SET</font> <font color="#0000ff">QUOTED_IDENTIFIER</font> </font><font size="1"><font color="#0000ff">ON<br /> </font>GO</font><font color="#0000ff"> <p><font size="1">CREATE</font></font><font size="1"> <font color="#0000ff">FUNCTION</font> [dbo]<font color="#808080">.</font>[GetAge] <font color="#808080">(</font>@DOB <font color="#0000ff">DATETIME</font><font color="#808080">,</font> @Today <font color="#0000ff">DATETIME</font></font><font size="1"><font color="#808080">)<br /> </font><font color="#0000ff">RETURNS</font> </font><font size="1"><font color="#0000ff">INT<br /> AS</font> <br /> </font><font color="#0000ff" size="1">BEGIN<br /> &nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1"><font color="#008000">-- declare variables<br /> &nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#0000ff">DECLARE</font> @Age </font><font color="#0000ff" size="1">INT<br /> <br /> </font><font size="1"><font color="#008000">&nbsp;&nbsp;&nbsp;&nbsp; -- set defaults<br /> &nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#0000ff">SET</font> @Age <font color="#808080">=</font> <font color="#ff00ff">Year</font><font color="#808080">(</font>@Today<font color="#808080">)</font> <font color="#808080">-</font> <font color="#ff00ff">Year</font><font color="#808080">(</font>@DOB<font color="#808080">)</font></font></p> <p><font color="#808080" size="1">&nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1"><font color="#008000">-- if it is a previous month subtract one off the age<br /> &nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#0000ff">IF</font> <font color="#ff00ff">Month</font><font color="#808080">(</font>@Today<font color="#808080">)</font> <font color="#808080">&lt;</font> <font color="#ff00ff">Month</font><font color="#808080">(</font>@DOB<font color="#808080">)</font> <br /> &nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1"><font color="#0000ff">BEGIN<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#0000ff">SET</font> @Age <font color="#808080">=</font> @Age <font color="#808080">-</font>1<br /> &nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000ff">END</font></font></p> <p><font color="#0000ff" size="1">&nbsp;&nbsp;&nbsp;&nbsp; </font><font size="1"><font color="#008000">-- if it is the current month but a previous day subtract one off the age<br /> &nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#0000ff">IF </font><font color="#ff00ff">Month</font><font color="#808080">(</font>@Today<font color="#808080">)</font> <font color="#808080">=</font> <font color="#ff00ff">Month</font><font color="#808080">(</font>@DOB<font color="#808080">)</font>&nbsp;<font color="#808080">AND</font> <font color="#ff00ff">Day</font><font color="#808080">(</font>@Today<font color="#808080">)</font> <font color="#808080">&lt;</font> <font color="#ff00ff">Day</font><font color="#808080">(</font>@DOB</font><font size="1"><font color="#808080">)<br /> &nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#0000ff">BEGIN</font> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000ff">SET</font> @Age <font color="#808080">=</font> @Age <font color="#808080">-</font> 1<br /> &nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000ff">END</font></font>&nbsp;</p> <p><font size="1"><font color="#008000">&nbsp;&nbsp;&nbsp;&nbsp; -- return value<br /> &nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#0000ff">RETURN</font> @Age<br /> <font color="#0000ff">END</font></font></p> <p><font color="#000000" size="1"><strong>Usage</strong></font></p> <font color="#008000" size="2"> <p><font size="1">-- declare variables<br /> </font></font><font size="1"><font color="#0000ff">DECLARE</font> @Today <font color="#0000ff">AS</font> <font color="#0000ff">DATETIME</font></font></p> <p><font size="1"><font color="#008000">-- set default values<br /> </font><font color="#0000ff">SET</font> @Today <font color="#808080">=</font> <font color="#ff00ff">GetDate</font><font color="#808080">()</p> </font></font><font color="#0000ff"> <p><font size="1"><font color="#008000">-- get data<br /> </font></font><font size="1">SELECT&nbsp;&nbsp;&nbsp;</font></font><font size="1">ID</font><font size="1"><font color="#808080">,<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font>DOB</font><font size="1"><font color="#808080">,<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#ff0000">'Age'</font> <font color="#808080">=</font> dbo<font color="#808080">.</font>GetAge<font color="#808080">(</font>DOB<font color="#808080">,</font> @Today</font><font size="1"><font color="#808080">)<br /> </font><font color="#0000ff">FROM&nbsp;&nbsp;&nbsp;&nbsp; </font>MyTable</font></p>Matt PaveySQL Serverhttp://www.pavey.net/?BlogID=4322008-01-11 16:52:23Mapedithttp://www.pavey.net/?BlogID=423<em>"Mapedit is an imagemap-editing program. Mapedit adds client-side imagemaps to web pages, simply by opening the page, selecting the image, and drawing rectangles, polygons and other shapes. There is no easier way to make an imagemap, and zoom support allows easy detail work on large images."</em></p> <p><a href="http://www.boutell.com/mapedit/index.html" target="_blank">http://www.boutell.com/mapedit/index.html</a></p> <div>I used Mapedit for the first time today.&nbsp;It's a very simple application but it saved me alot of time today when doing some HTML image mapping on a regional map of the United States earlier today. In the past I've always just opened my image file up in a standard image editor such as Paint or Photoshop and mapped out the coordinates manually and created the image map manually, which isn't that hard to do; however, in some cases if you have a complex area to map, such as a polygon, it can become very cumbersome to record all of the (x, y) coordinates efficiently and accurately.</div> <div>&nbsp;</div> <div>Mapedit is a very simple interface that lets you open the image and map out multiple areas and generate the HTML code with little effort.</div> <div>&nbsp;</div> <div><em>"Mapedit is shareware. The copy you have downloaded is fully functional for 30 days or 100 saves, whichever comes first. When your time or your saves run out, you will need to unlock the product to continue using it."</em></div>Matt PaveyHTMLhttp://www.pavey.net/?BlogID=4232007-11-03 14:44:49Lorem Ipsum: Generating Dummy Texthttp://www.pavey.net/?BlogID=422<div>Here's a site that many of you are probably familiar with if you've ever had to quickly generate some placeholder text for prototyping, testing, etc.</div> <div>&nbsp;</div> <div><a href="http://www.lipsum.com/" target="_blank">http://www.lipsum.com</a></div>Matt PaveyOtherhttp://www.pavey.net/?BlogID=4222007-10-29 11:28:53Maximum Capacity Specifications for SQL Server 2005http://www.pavey.net/?BlogID=421The following link contains the maximum sizes and numbers of various objects defined in Microsoft SQL Server 2005 components. <p><a href="http://msdn2.microsoft.com/en-us/library/ms143432.aspx" target="_blank">http://msdn2.microsoft.com/en-us/library/ms143432.aspx</a></p>Matt PaveySQL Serverhttp://www.pavey.net/?BlogID=4212007-10-29 11:17:10