<feed version="0.3" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns="http://purl.org/atom/ns#" xml:lang="en-US"><title>Salt Lake City ASP.NET C# SQL Therapy</title><link rel="alternate" type="text/html" href="http://www.dotnetjunkies.com/WebLog/dacevedo/default.aspx" /><tagline type="text/html">Daniel Acevedo blogs on Salt Lake City ASP.NET, C#, SQL Server, Reporting Services, and ADO.NET.</tagline><id>http://www.dotnetjunkies.com/WebLog/dacevedo/default.aspx</id><author><url>http://www.dotnetjunkies.com/WebLog/dacevedo/default.aspx</url></author><generator url="http://communityserver.org" version="1.0.1.50214">Community Server</generator><modified>2006-02-16T11:07:00Z</modified><entry><title>Documentation Basics 1 (motivation)</title><link rel="alternate" type="text/html" href="http://www.dotnetjunkies.com/WebLog/dacevedo/archive/2007/10/09/333386.aspx" /><id>58df7014-fd75-437c-9641-150997716d1c:333386</id><created>2007-10-09T16:02:00Z</created><content type="text/html" mode="escaped">&lt;P&gt;&lt;STRONG&gt;Assumption1&lt;/STRONG&gt;: The software is developed by more than one person. &lt;BR&gt;&lt;STRONG&gt;Assumption2&lt;/STRONG&gt;: Testing is foundational to a good quality product. &lt;/P&gt;
&lt;P&gt;Software is complicated so whenever you introduce any change it is most dificult to wrap your arms around the possible repercussions. I wholeheartedly submit to you that the quality of the product is directly proportional to how much you can put your arms around the possible repercussions of making a change. Understanding the relationships between components leads to more complete testing and to a better product. This is the thrust behind documentation. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;An example&lt;/STRONG&gt;: You have five components, A, B, C, D, &amp;amp; E. Two people do their best to put their arms around these components (understand their relationship to one another) and they come up with two separate understandings. &lt;/P&gt;&lt;CODE&gt;
&lt;P&gt;&lt;STRONG&gt;1)&lt;/STRONG&gt; &lt;BR&gt;A affects B&lt;BR&gt;E affects A&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2)&lt;BR&gt;&lt;/STRONG&gt;A affects B and D&lt;BR&gt;B affects C&lt;BR&gt;E affects A&lt;/P&gt;
&lt;P&gt;Consequently, when I introduce a change to A, each person will proceed to test differently, based on their understanding. Here are the tests performed by each person. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1)&lt;BR&gt;&lt;/STRONG&gt;test A&lt;BR&gt;test B&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2)&lt;BR&gt;&lt;/STRONG&gt;test A&lt;BR&gt;test B&lt;BR&gt;test D&lt;BR&gt;test C&lt;/P&gt;&lt;/CODE&gt;
&lt;P&gt;If we assume that each test catches one bug, and if we define quality by how many bugs are found in the resulting product, then we can see that the product produced by the second person has twice the quality as the product produced by the first person.&lt;/P&gt;
&lt;P&gt;By the example above we can see that our understanding of how components relate to one another directly leads to the quality of our product. If the first person is given the task of testing the software, then only two tests will be performed. If the second person is given the task of testing the software, then four tests will be performed. This happens because their understanding varies. Hence, the quality of the product will vary.&lt;/P&gt;
&lt;P&gt;When the understanding is limited to what is in the individual's brains, you cannot do anything but accept the quality variations. How can we solve the problem of varying quality? We can do this by sharing the level of understanding. Practically, sharing understanding is carried out through documentation. What is documented and available to all is what is understood.&lt;/P&gt;
&lt;P&gt;Below are two documentation scenarios. &lt;/P&gt;
&lt;TABLE&gt;

&lt;TR&gt;
&lt;TD&gt;&lt;CODE&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Scenario 1:&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1) Learns the product and documents centrally that&lt;/STRONG&gt;&lt;BR&gt;A affects B&lt;BR&gt;E affects A&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1) performs tests&lt;/STRONG&gt;&lt;BR&gt;test A&lt;BR&gt;test B&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Software has 40% quality.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2) Learns the product from 1's documentation and adds to it. The document now becomes&lt;/STRONG&gt;&lt;BR&gt;A affects B and D&lt;BR&gt;B affects C&lt;BR&gt;E affects A&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2) performs tests&lt;/STRONG&gt;&lt;BR&gt;test A&lt;BR&gt;test B&lt;BR&gt;test D&lt;BR&gt;test C&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Software has 80% quality.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1) Learns the product some more from existing documentation and adds to the documentation.&lt;BR&gt;&lt;/STRONG&gt;A affects B and D and F&lt;BR&gt;B affects C&lt;BR&gt;E affects A&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1) performs tests&lt;BR&gt;&lt;/STRONG&gt;test A&lt;BR&gt;test B&lt;BR&gt;test D&lt;BR&gt;test C&lt;BR&gt;test F&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Software has 100% quality.&lt;/STRONG&gt; &lt;/P&gt;&lt;/CODE&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;CODE&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Scenario 2:&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2) Learns the product and documents centrally that&lt;/STRONG&gt;&lt;BR&gt;A affects B and D&lt;BR&gt;B affects C&lt;BR&gt;E affects A&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2) performs tests&lt;/STRONG&gt;&lt;BR&gt;test A&lt;BR&gt;test B&lt;BR&gt;test D&lt;BR&gt;test C&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Software has 80% quality.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1) Learns the product from 2's documentation and adds to it. The document now becomes.&lt;BR&gt;&lt;/STRONG&gt;A affects B and D and F&lt;BR&gt;B affects C&lt;BR&gt;E affects A&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1) performs tests&lt;/STRONG&gt;&lt;BR&gt;test A&lt;BR&gt;test B&lt;BR&gt;test D&lt;BR&gt;test C&lt;BR&gt;test F&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Software has 100% quality.&lt;/STRONG&gt; &lt;/P&gt;&lt;/CODE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;
&lt;P&gt;&lt;BR&gt;The point here is that no matter what the scenario is, the quality of the software will increase with the increase of documentation (or shared understanding). At first, it may seem that sharing the level of understanding will not help the quality (this is true in the first step). However, as the sharing (documenting) continues, quality can only increase.&lt;/P&gt;
&lt;P&gt;Ignoring documentation will lead to software of poor quality (at worst) or to software with varying quality (at best). Developers who document what they learn and share the documentation can only help an organization to produce a higher quality product.&lt;/P&gt;&lt;img src="http://www.dotnetjunkies.com/WebLog/aggbug.aspx?PostID=333386" width="1" height="1"&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://www.dotnetjunkies.com/WebLog/dacevedo/commentrss.aspx?PostID=333386</wfw:commentRss></entry><entry><title>SQL Interview Question</title><link rel="alternate" type="text/html" href="http://www.dotnetjunkies.com/WebLog/dacevedo/archive/2007/03/01/204273.aspx" /><id>58df7014-fd75-437c-9641-150997716d1c:204273</id><created>2007-03-01T15:03:00Z</created><content type="text/html" mode="escaped">&lt;P&gt;-- Sample: A table of Employees with their ID, Name, &lt;BR&gt;-- and Manager ID(which is itself the ID of one of the employees).&lt;/P&gt;
&lt;P&gt;declare @Employee table (ID int NOT NULL, Name varchar(30), MID int NULL)&lt;BR&gt;insert @Employee values(20, 'Wei', 22)&lt;BR&gt;insert @Employee values(21, 'Brad', 22)&lt;BR&gt;insert @Employee values(22, 'Jeremy', NULL)&lt;BR&gt;insert @Employee values(23, 'Daniel', 22)&lt;/P&gt;
&lt;P&gt;SELECT * from @Employee&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;-- How do you get a list of Managers with their employees?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;SELECT Managers.Name, Employees.Name&lt;BR&gt;from @Employee Employees&lt;BR&gt;inner join @Employee Managers&lt;BR&gt;on Employees.MID = Managers.ID&lt;/P&gt;
&lt;P&gt;A&amp;nbsp;few years ago when I was asked this question , I didn't know the answer but I said, "some sort of self-join". That was good enough for my interviewer.&lt;/P&gt;&lt;img src="http://www.dotnetjunkies.com/WebLog/aggbug.aspx?PostID=204273" width="1" height="1"&gt;</content><slash:comments>1</slash:comments><wfw:commentRss>http://www.dotnetjunkies.com/WebLog/dacevedo/commentrss.aspx?PostID=204273</wfw:commentRss></entry><entry><title>Backup GoDaddy DotNetNuke database</title><link rel="alternate" type="text/html" href="http://www.dotnetjunkies.com/WebLog/dacevedo/archive/2007/02/27/203154.aspx" /><id>58df7014-fd75-437c-9641-150997716d1c:203154</id><created>2007-02-27T12:50:00Z</created><content type="text/html" mode="escaped">&lt;P&gt;GoDaddy is one of the cheapest ASP.NET hosts. They have DNN preinstalled for you if you want it. They make it nearly impossible to access the DNN database through their control panel, though,&amp;nbsp;so backup is very hard.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;C A U T I O N: The following advice is too powerful. You can break DNN or delete or corrupt data if you're not careful. By reading this post and/or using its advice, you agree to NOT hold Daniel Acevedo or DotNetJunkies responsible in any way for any changes, damages, or loss incurred.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;1) To achieve a backup, you can login to your portal as host&lt;BR&gt;username: host&lt;BR&gt;password: [same as admin pwd]&lt;/P&gt;
&lt;P&gt;2) Then, from the host tab, select SQL. Copy something like the following:&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;select dnn_Tabs.TabName, m.Moduletitle, t.DesktopHtml, dnn_Tabs.TabID, m.ModuleID&lt;BR&gt;from dnn_HtmlText t&lt;BR&gt;inner join dnn_Modules m&lt;BR&gt;on t.ModuleID = m.ModuleID&lt;BR&gt;inner join dnn_TabModules tm&lt;BR&gt;on m.ModuleID = tm.ModuleID&lt;BR&gt;inner join dnn_Tabs&lt;BR&gt;on tm.TabID = dnn_Tabs.TabID&lt;BR&gt;where m.ModuleDefID = 100&lt;BR&gt;order by 1, 2 &lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;3) Then click "Execute"&lt;/P&gt;
&lt;P&gt;4) Finally, copy the results that appear on the web page to Excel or whatever you want and save it somewhere. You've now got a rough backkup of your website. (only the contents of the Text/HTML modules - for now)&lt;/P&gt;
&lt;P&gt;You can explore the DNN database and write up your own SQL scripts to get the data you want (AT YOUR OWN RISK). Here's another helpful SQL script to get you started:&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;select name from sysobjects where type = 'U'&lt;BR&gt;and name like 'dnn%'&lt;BR&gt;order by 1 &lt;/CODE&gt;&lt;/P&gt;&lt;img src="http://www.dotnetjunkies.com/WebLog/aggbug.aspx?PostID=203154" width="1" height="1"&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://www.dotnetjunkies.com/WebLog/dacevedo/commentrss.aspx?PostID=203154</wfw:commentRss></entry><entry><title>SQL Cursor Quick Reference, and coffee</title><link rel="alternate" type="text/html" href="http://www.dotnetjunkies.com/WebLog/dacevedo/archive/2007/02/14/196208.aspx" /><id>58df7014-fd75-437c-9641-150997716d1c:196208</id><created>2007-02-14T12:23:00Z</created><content type="text/html" mode="escaped">&lt;P&gt;The SQL Team has this excellent cursor quick reference. It is in plain english and straightforward:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.sqlteam.com/item.asp?ItemID=553"&gt;http://www.sqlteam.com/item.asp?ItemID=553&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I don't think I've ever learned this much about cursors in just one minute of reading (I also drank coffee for the first time in a year this morning--that was delicious CAFE SELLO ROJO from Colombia. Boy, it really speeds me up in everything I do)!&lt;/P&gt;&lt;img src="http://www.dotnetjunkies.com/WebLog/aggbug.aspx?PostID=196208" width="1" height="1"&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://www.dotnetjunkies.com/WebLog/dacevedo/commentrss.aspx?PostID=196208</wfw:commentRss></entry><entry><title>SQL Server 2005: INSERT INTO from a stored procedure</title><link rel="alternate" type="text/html" href="http://www.dotnetjunkies.com/WebLog/dacevedo/archive/2006/12/21/177157.aspx" /><id>58df7014-fd75-437c-9641-150997716d1c:177157</id><created>2006-12-21T12:52:00Z</created><content type="text/html" mode="escaped">&lt;P&gt;&lt;STRONG&gt;You could&amp;nbsp;NOT do this with SQL server 2000.&lt;BR&gt;&lt;/STRONG&gt;You were only able to assign to a simple variable from a stored procedure that returned an output parameter or a single column.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;With 2005, you CAN now do the following:&lt;BR&gt;&lt;/STRONG&gt;INSERT INTO @MyTableVariable EXEC myStoredProcedure&lt;/P&gt;
&lt;P&gt;Thanks to &lt;A href="http://blog.devstone.com/aaron/archive/2006/12/14/2098.aspx"&gt;R. Aaron Zupancic&lt;/A&gt; for his "coolness" blog post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR&gt;&lt;img src="http://www.dotnetjunkies.com/WebLog/aggbug.aspx?PostID=177157" width="1" height="1"&gt;</content><slash:comments>2</slash:comments><wfw:commentRss>http://www.dotnetjunkies.com/WebLog/dacevedo/commentrss.aspx?PostID=177157</wfw:commentRss></entry><entry><title>C#.NET: InvalidCastException: Specified cast is not valid</title><link rel="alternate" type="text/html" href="http://www.dotnetjunkies.com/WebLog/dacevedo/archive/2006/12/19/175858.aspx" /><id>58df7014-fd75-437c-9641-150997716d1c:175858</id><created>2006-12-19T15:44:00Z</created><content type="text/html" mode="escaped">&lt;P&gt;&lt;STRONG&gt;I needed to populate a textbox on a web page with a value from the database but I was getting an error.&lt;BR&gt;&lt;/STRONG&gt;InvalidCastException: Specified cast is not valid&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;The following line returns the error:&lt;/STRONG&gt;&lt;BR&gt;return (string)ds.Tables[0].Rows[0]["Adjustment"];&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;This is because the type of Adjustment in SQL Server is decimal(7,2).&amp;nbsp; The following line first converts the &lt;BR&gt;value to a .NET Double and then to a String.&lt;BR&gt;&lt;/STRONG&gt;return Convert.ToDouble(ds.Tables[0].Rows[0]["Adjustment"]).ToString() ;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;That fixed the problem!&lt;/STRONG&gt;&lt;/P&gt;&lt;img src="http://www.dotnetjunkies.com/WebLog/aggbug.aspx?PostID=175858" width="1" height="1"&gt;</content><slash:comments>4</slash:comments><wfw:commentRss>http://www.dotnetjunkies.com/WebLog/dacevedo/commentrss.aspx?PostID=175858</wfw:commentRss></entry><entry><title>Reporting Services Line Break in a Textbox</title><link rel="alternate" type="text/html" href="http://www.dotnetjunkies.com/WebLog/dacevedo/archive/2006/12/18/174934.aspx" /><id>58df7014-fd75-437c-9641-150997716d1c:174934</id><created>2006-12-18T14:40:00Z</created><content type="text/html" mode="escaped">&lt;P&gt;&lt;STRONG&gt;vbCrLf &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Example (The following expression returns two fields, each on a separate line in the same text box):&lt;/P&gt;
&lt;P&gt;=Fields!FirstName.Value &amp;amp; vbCrLf &amp;amp; Fields!LastName.Value &lt;/P&gt;
&lt;P&gt;This example is found in: &lt;A href="http://msdn2.microsoft.com/en-gb/library/ms157328.aspx"&gt;Expression Examples in Reporting Services&lt;/A&gt;, an excellent article with many examples to use as a reference.&lt;/P&gt;&lt;img src="http://www.dotnetjunkies.com/WebLog/aggbug.aspx?PostID=174934" width="1" height="1"&gt;</content><slash:comments>4</slash:comments><wfw:commentRss>http://www.dotnetjunkies.com/WebLog/dacevedo/commentrss.aspx?PostID=174934</wfw:commentRss></entry><entry><title>ASP.NET: programmatically save file to network shared folder</title><link rel="alternate" type="text/html" href="http://www.dotnetjunkies.com/WebLog/dacevedo/archive/2006/11/08/154446.aspx" /><id>58df7014-fd75-437c-9641-150997716d1c:154446</id><created>2006-11-08T12:30:00Z</created><content type="text/html" mode="escaped">&lt;P&gt;&lt;STRONG&gt;Albeit with unmanaged code...&lt;BR&gt;&lt;/STRONG&gt;By default, the account under which your asp.net application runs is a local account on the machine running your application. You could create a domain account with the same login and password and then give that account permission to read and write on the network folder.&amp;nbsp; If that is not the solution you want, create an account like the one below on the domain with minimal priveledges and give it access to read and write on the network folder. Then use the following code-behind to programmatically impersonate and save onto that folder.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Assume the following:&lt;BR&gt;&lt;/STRONG&gt;account login: foo&lt;BR&gt;account passw: bar&lt;BR&gt;domain: mydomain&lt;/P&gt;
&lt;P&gt;using System;&lt;BR&gt;...&lt;/P&gt;
&lt;P&gt;using System.Security.Principal;&lt;BR&gt;using System.Runtime.InteropServices;&lt;/P&gt;
&lt;P&gt;namespace testapp&lt;BR&gt;{&lt;/P&gt;
&lt;P&gt;public class WebForm2 : System.Web.UI.Page&lt;BR&gt;{&lt;BR&gt;protected System.Web.UI.WebControls.Button Button1;&lt;BR&gt;&amp;nbsp;protected System.Web.UI.WebControls.Label Label1;&lt;BR&gt;&amp;nbsp;protected System.Web.UI.WebControls.Label lbShow;&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&amp;nbsp;[DllImport("advapi32.dll", SetLastError=true)]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;public static extern bool LogonUser(String lpszUsername, String &lt;BR&gt;lpszDomain, String lpszPassword, int dwLogonType, int &lt;BR&gt;dwLogonProvider, ref IntPtr phToken);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;[DllImport("kernel32.dll", &lt;BR&gt;CharSet=System.Runtime.InteropServices.CharSet.Auto)]&lt;BR&gt;&amp;nbsp;&lt;BR&gt;private unsafe static extern int FormatMessage(int dwFlags, ref &lt;BR&gt;IntPtr lpSource, int dwMessageId, int dwLanguageId, ref &lt;BR&gt;String lpBuffer, int nSize, IntPtr *Arguments);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;[DllImport("kernel32.dll", CharSet=CharSet.Auto)]&lt;BR&gt;&amp;nbsp;&lt;BR&gt;public extern static bool CloseHandle(IntPtr handle);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;[DllImport("advapi32.dll", CharSet=CharSet.Auto, &lt;BR&gt;SetLastError=true)]&lt;BR&gt;&amp;nbsp;&lt;BR&gt;public extern static bool DuplicateToken(IntPtr &lt;BR&gt;ExistingTokenHandle, int SECURITY_IMPERSONATION_LEVEL, ref &lt;BR&gt;IntPtr DuplicateTokenHandle);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;private void Page_Load(object sender, System.EventArgs e)&lt;BR&gt;&amp;nbsp;{&amp;nbsp;&lt;BR&gt;&amp;nbsp;...&lt;BR&gt;&amp;nbsp;}&lt;/P&gt;
&lt;P&gt;private string SaveRequest(string filename)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;IntPtr tokenHandle = new IntPtr(0);&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;const int LOGON32_PROVIDER_DEFAULT = 0;&lt;BR&gt;&amp;nbsp;&amp;nbsp;//This parameter causes LogonUser to create a primary &lt;BR&gt;token.&lt;BR&gt;&amp;nbsp;&amp;nbsp;const int LOGON32_LOGON_INTERACTIVE = 2;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;tokenHandle = IntPtr.Zero;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;// Call LogonUser to obtain a handle to an access token.&lt;BR&gt;bool returnValue = LogonUser("foo", "mydomain", "bar", &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;ref tokenHandle);&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;WindowsIdentity newId = new WindowsIdentity(tokenHandle);&lt;BR&gt;WindowsImpersonationContext impersonatedUser = &lt;BR&gt;newId.Impersonate();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;Request.SaveAs(filename, true);&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;impersonatedUser.Undo();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;return “success”;&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;private void Button1_Click(object sender, System.EventArgs e)&lt;BR&gt;{&lt;BR&gt;string message = SaveRequest("&lt;A&gt;\\\\comp\\folder\\&lt;/A&gt; &lt;BR&gt;request.txt");&lt;BR&gt;&amp;nbsp;&amp;nbsp;Label1.Text = message;&lt;BR&gt;}&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;I think the best way to implement this is to throw all the extra interop code into its own class (UserImpersonate) which implements the IDisposable interface and simply use the class.&lt;BR&gt;&lt;STRONG&gt;So that it's something like this:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;using ( new UserImpersonate ( "foo", "mydomain", "bar" ) )&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;Request.SaveAs(filename, true);&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;references:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/system.security.principal.windowsimpersonationcontext(VS.80).aspx"&gt;&lt;STRONG&gt;Microsoft's documentation for WindowsImpersonationContext Class&lt;/STRONG&gt;&lt;/A&gt;. 
&lt;LI&gt;&lt;A href="http://support.microsoft.com/default.aspx?scid=kb;en-us;Q306158"&gt;&lt;STRONG&gt;How to implement impersonation in an ASP.NET application&lt;/STRONG&gt;&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://www.dotnetjunkies.com/WebLog/aggbug.aspx?PostID=154446" width="1" height="1"&gt;</content><slash:comments>6</slash:comments><wfw:commentRss>http://www.dotnetjunkies.com/WebLog/dacevedo/commentrss.aspx?PostID=154446</wfw:commentRss></entry><entry><title>Windows Mobile 5 Programming</title><link rel="alternate" type="text/html" href="http://www.dotnetjunkies.com/WebLog/dacevedo/archive/2006/03/31/136490.aspx" /><id>58df7014-fd75-437c-9641-150997716d1c:136490</id><created>2006-03-31T10:43:00Z</created><content type="text/html" mode="escaped">&lt;P&gt;Speaking of Windows Mobile 5 and the T-Mobile MDA, Microsoft has made available much help for developers and hobbyests to dive into programming for the new platform. &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/aa454909.aspx"&gt;&lt;U&gt;Working with Pictures, Video, and Cameras in Windows Mobile 5.0&lt;/U&gt;&lt;/A&gt; - &lt;B&gt;awesome&lt;/B&gt; 
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/mobility/windowsmobile/howto/ehowtos/default.aspx"&gt;&lt;U&gt;Mobile Application Development eHow-tos and Tutorials&lt;/U&gt;&lt;/A&gt; - Webcasts&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;And... &lt;/P&gt;
&lt;P&gt;I'm having a hard time finding the MDA in Salt Lake City. I'm probably going to have to go to Chicago to upgrade from my Nokia 3650 to the MDA. In the meantime, I'll enjoy the 3650.&lt;/P&gt;&lt;/U&gt;&lt;/U&gt;&lt;img src="http://www.dotnetjunkies.com/WebLog/aggbug.aspx?PostID=136490" width="1" height="1"&gt;</content><slash:comments>1</slash:comments><wfw:commentRss>http://www.dotnetjunkies.com/WebLog/dacevedo/commentrss.aspx?PostID=136490</wfw:commentRss></entry><entry><title>Reporting Services Web Services Authentication in C#</title><link rel="alternate" type="text/html" href="http://www.dotnetjunkies.com/WebLog/dacevedo/archive/2006/03/28/136416.aspx" /><id>58df7014-fd75-437c-9641-150997716d1c:136416</id><created>2006-03-28T14:47:00Z</created><content type="text/html" mode="escaped">&lt;P&gt;The Web Services API that allows you to programmatically connect to a report server requires authentication. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Here's how I generally do it in C#:&lt;BR&gt;&lt;/STRONG&gt;&lt;CODE&gt;&lt;FONT&gt;rs.Credentials = System.Net.CredentialCache.DefaultCredentials;&lt;/FONT&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;The ins and outs of getting authenticated by the Report Server are explained in this &lt;A href="http://www.odetocode.com/Articles/216.aspx"&gt;&lt;U&gt;great article&lt;/U&gt;&lt;/A&gt;.&lt;/P&gt;&lt;img src="http://www.dotnetjunkies.com/WebLog/aggbug.aspx?PostID=136416" width="1" height="1"&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://www.dotnetjunkies.com/WebLog/dacevedo/commentrss.aspx?PostID=136416</wfw:commentRss></entry><entry><title>Reporting Services Therapy: Index was out of range</title><link rel="alternate" type="text/html" href="http://www.dotnetjunkies.com/WebLog/dacevedo/archive/2006/03/09/135836.aspx" /><id>58df7014-fd75-437c-9641-150997716d1c:135836</id><created>2006-03-09T14:49:00Z</created><content type="text/html" mode="escaped">&lt;P&gt;&lt;STRONG&gt;I got this strange error when exporting to Excel from the designer or from the Report Manager:&lt;BR&gt;&lt;CODE&gt;&lt;FONT&gt;"Index was out of range. Must be non-negative and less than the size of the collection."&lt;/FONT&gt;&lt;/CODE&gt;&lt;/STRONG&gt; 
&lt;P&gt;&lt;/P&gt;&lt;STRONG&gt;After pulling my hair out for a while, and after Googling the problem, I found a couple of solutions, (1) Worked for me - it came from my Salt Lake City coworker:&lt;/STRONG&gt; 
&lt;P&gt;&lt;/P&gt;&lt;STRONG&gt;(1)&lt;/STRONG&gt; One Detail Cell in my table contained a number like #.#########. Aparently this freaked out Excel. I converted it to a string like this:&lt;BR&gt;&lt;CODE&gt;&lt;FONT&gt;&lt;STRONG&gt;=Convert.ToString(Format((ReportItems!ValueOne.Value / ReportItems!ValueTwo.Value), "#.#########"))&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/CODE&gt; 
&lt;P&gt;&lt;/P&gt;&lt;STRONG&gt;(2)&lt;/STRONG&gt; As per &lt;A href="http://www.mbawizards.com/sql_server/index_was_out_of_range_depending_on_parameters_0000106330.htm"&gt;this blog&lt;/A&gt;, disabling the Document Map Labels has the same effect and cures the problem. 
&lt;P&gt;&lt;/P&gt;&lt;img src="http://www.dotnetjunkies.com/WebLog/aggbug.aspx?PostID=135836" width="1" height="1"&gt;</content><slash:comments>1</slash:comments><wfw:commentRss>http://www.dotnetjunkies.com/WebLog/dacevedo/commentrss.aspx?PostID=135836</wfw:commentRss></entry><entry><title>ASP.NET Therapy: Super Concise Demos</title><link rel="alternate" type="text/html" href="http://www.dotnetjunkies.com/WebLog/dacevedo/archive/2006/03/02/135705.aspx" /><id>58df7014-fd75-437c-9641-150997716d1c:135705</id><created>2006-03-02T12:43:00Z</created><content type="text/html" mode="escaped">&lt;P&gt;These &lt;B&gt;&lt;I&gt;How do I&lt;/I&gt;&lt;/B&gt; videos are brought to you by the &lt;A href="http://msdn2.microsoft.com/en-us/asp.net/aa336576.aspx"&gt;Microsoft ASP.NET Developer Center&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;&lt;B&gt;Common Tasks Covered:&lt;/B&gt;&lt;BR&gt;
&lt;OL&gt;
&lt;LI&gt;Data Access - &lt;B&gt;I recommend this one!&lt;/B&gt; 
&lt;LI&gt;Form Building for a "Contact Us" Page 
&lt;LI&gt;Master Pages and Site Navigation 
&lt;LI&gt;Membership and Roles 
&lt;LI&gt;Profiles and Themes 
&lt;LI&gt;Create a Full-Featured Customer Login Portal 
&lt;LI&gt;Caching (Part 1) 
&lt;LI&gt;Caching (Part 2) 
&lt;LI&gt;Web Parts and Personalization 
&lt;LI&gt;Localization 
&lt;LI&gt;Tips and Tricks &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;These demos are also a &lt;I&gt;Featured News&lt;/I&gt; item on &lt;A href="http://www.asp.net"&gt;www.asp.net&lt;/A&gt;.&lt;/P&gt;&lt;img src="http://www.dotnetjunkies.com/WebLog/aggbug.aspx?PostID=135705" width="1" height="1"&gt;</content><slash:comments>1</slash:comments><wfw:commentRss>http://www.dotnetjunkies.com/WebLog/dacevedo/commentrss.aspx?PostID=135705</wfw:commentRss></entry><entry><title>T-Mobile MDA - a great phone for .NET apps.</title><link rel="alternate" type="text/html" href="http://www.dotnetjunkies.com/WebLog/dacevedo/archive/2006/02/21/135464.aspx" /><id>58df7014-fd75-437c-9641-150997716d1c:135464</id><created>2006-02-21T15:05:00Z</created><content type="text/html" mode="escaped">&lt;P&gt;&lt;STRONG&gt;Out today!&lt;/STRONG&gt;&lt;BR&gt;It's out today! If you go to T-Mobile's website, Go to Phones. Then select the Tab labeled Handhelds and Sidekick. I check the site every day and today I checked it again. The MDA did not show up until I refreshed the browser.&lt;/P&gt;
&lt;P&gt;It'll cost me $349.99 to upgrade to this phone with a two-year extension and no rebates. New subscribers have to pay $399 and wait for their $50 rebate.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Why I'm so interested in the T-Mobile MDA&lt;BR&gt;&lt;/STRONG&gt;I've been waiting for this Windows Mobile 5 Phone to come out, and now it has! I can't wait to start developing apps for this phone with Visual Studio 2005. I can use the .NET compact framework!&amp;nbsp; My wife already has a Dell Axim X50 and I jut don't want to carry two devices so I was waiting for the best PDA-Phone for the price, the T-Mobile MDA. &lt;/P&gt;
&lt;P&gt;I hear that a 300 Mhz version of the MDA will be out in the summer, but I don't think I'll wait. Mainly because I won't be using Skype and because I can monitor my open apps and performance and keep it finely tuned.&lt;/P&gt;&lt;img src="http://www.dotnetjunkies.com/WebLog/aggbug.aspx?PostID=135464" width="1" height="1"&gt;</content><slash:comments>2</slash:comments><wfw:commentRss>http://www.dotnetjunkies.com/WebLog/dacevedo/commentrss.aspx?PostID=135464</wfw:commentRss></entry><entry><title>SQL Therapy: SQL Server 2005 Installation problem</title><link rel="alternate" type="text/html" href="http://www.dotnetjunkies.com/WebLog/dacevedo/archive/2006/02/18/135405.aspx" /><id>58df7014-fd75-437c-9641-150997716d1c:135405</id><created>2006-02-18T19:46:00Z</created><content type="text/html" mode="escaped">&lt;P&gt;&lt;STRONG&gt;I tried installing SQL Server 2005 With the Windows XP Administrator account.&lt;/STRONG&gt; At the begining of the installation I got an error that would not let me continue:&lt;BR&gt;Could not find ASPNET account. (summarized)&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;I had previously installed Visual Web Developer, SQL Server Express, and Visual Studio 2005.&lt;/STRONG&gt;&lt;BR&gt;The next thing I did was realize that I didn't have IIS installed. I installed IIS and tried to install SQL 2005 again to no avail.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Then I uninstalled the following:&lt;/STRONG&gt;&lt;BR&gt;SQL Server Express,&lt;BR&gt;All SQL Server associated applications&lt;BR&gt;Visual Studio 2005&lt;BR&gt;VWD&lt;BR&gt;.NET 2.0 Framework&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Then I installed VS 2005 which did the trick and allowed me to install SQL Server 2005&lt;/STRONG&gt;. (I did not install VWD this time). I believe that the culprit was my not having installing IIS before everything else. That step is crucial!&lt;/P&gt;&lt;img src="http://www.dotnetjunkies.com/WebLog/aggbug.aspx?PostID=135405" width="1" height="1"&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://www.dotnetjunkies.com/WebLog/dacevedo/commentrss.aspx?PostID=135405</wfw:commentRss></entry><entry><title>ASP.NET Therapy: Salt Lake City ASP.NET 2.0 training Report</title><link rel="alternate" type="text/html" href="http://www.dotnetjunkies.com/WebLog/dacevedo/archive/2006/02/16/135348.aspx" /><id>58df7014-fd75-437c-9641-150997716d1c:135348</id><created>2006-02-16T10:07:00Z</created><content type="text/html" mode="escaped">&lt;P&gt;(Note: There were about 8 inches of snow on my driveway this morning. I had a little &lt;A href="http://www.corerehabcenter.com/rehabilitation"&gt;&lt;U&gt;back ache&lt;/U&gt;&lt;/A&gt; after shoveling but after doing a few &lt;A href="http://www.corerehabcenter.com/rehabilitation"&gt;&lt;U&gt;McKenzie exercises&lt;/U&gt;&lt;/A&gt;, I'm all better. Thanks &lt;A href="http://www.corerehabcenter.com/rehabilitation"&gt;&lt;U&gt;Irene&lt;/U&gt;&lt;/A&gt;!) &lt;/P&gt;
&lt;P&gt;&lt;B&gt;ASP.NET 2.0 Training Report&lt;/B&gt; &lt;A href="http://www.grokdev.com/Blogs/Scott/default.aspx"&gt;Scott Golightly &lt;/A&gt;taught a class on ASP.NET 2.0 in the Microsoft offices in Salt Lake City on February 14 &amp;amp; 15. I went and got the best ASP.NET 2.0 therapy that I've ever gotten. One word to describe my overall experience: &lt;EM&gt;&lt;STRONG&gt;Equipping&lt;/STRONG&gt;&lt;/EM&gt;. &lt;/P&gt;
&lt;P&gt;&lt;B&gt;More than Gleenings:&lt;/B&gt; &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Dynamic Profile Properties. I can throw these into the web.config file and they're stored and available for my use with zero code! 
&lt;LI&gt;SQL 2005 Auto-Notification versus 2000's polling. I now understand and appreciate this much more! (insight: Can I use this to build a tool that notifies team members when stored procedures are edited? Is there something out there that does this already?) 
&lt;LI&gt;Custom Cache Dependencies. Because the Cache Dependency class is no longer sealed, What could have been rocket science to some, is now easy to implement. I can think of many uses for this. 
&lt;LI&gt;And, although Master pages fail to excite me too much, I still learned alot about them. One limitation I found (correct me if I'm wrong) is that you cannot go into design mode in Visual Studio when using nested Master pages. 
&lt;LI&gt;I really like being able to "View in Browser" from Visual Studio without compiling the entire project. In fact, I can open a single aspx file, make changes to it, and "View in Browser". .NET 2.0 takes care of JIT compiling other necessary files. &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;B&gt;I received three great books at the training:&lt;/B&gt; &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Introducing ASP.NET 2.0 (I found one minor inconsistency: The attributes in the @Page Directive that control code-beside don't work as explained in the book. This may be due to a difference between ASP.NET 2.0 Beta and final release. The consequence of this is that the code in the ASPX file and its .CS counterpart don't gel perfectly as partial classes. Private members are not shared.) 
&lt;LI&gt;The official course book (contains all slides, demos, exercises, and code snippets presented in the training). 
&lt;LI&gt;Application Architecture for .NET (I already have this book. It is excellent for enterprise-level developers) &lt;/LI&gt;&lt;/OL&gt;&lt;img src="http://www.dotnetjunkies.com/WebLog/aggbug.aspx?PostID=135348" width="1" height="1"&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://www.dotnetjunkies.com/WebLog/dacevedo/commentrss.aspx?PostID=135348</wfw:commentRss></entry></feed>