<?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/css" href="http://www.morrenth.com/Data/style/rss1.css" ?> <?xml-stylesheet type="text/xsl" href="http://www.morrenth.com/Data/xsl/rss1.xsl" ?>
<!--RSS generated by mojoPortal Blog Module V 1.0 on Monday, May 21, 2012-->
<rss version="2.0">
  <channel>
    <title>Beyond the boundaries of ASP.Net development</title>
    <link>http://www.morrenth.com/blog.aspx</link>
    <description />
    <copyright />
    <ttl>120</ttl>
    <managingEditor />
    <generator>mojoPortal Blog Module V 1.0</generator>
    <item>
      <title>Transaction and RetainSameConnection in SSIS OLE DB Connection Manager</title>
      <link>http://www.morrenth.com/transaction-and-retainsameconnection-in-ssis-ole-db-connection-manager.aspx</link>
      <pubDate>Tue, 01 May 2012 19:46:57 GMT</pubDate>
      <guid>http://www.morrenth.com/transaction-and-retainsameconnection-in-ssis-ole-db-connection-manager.aspx</guid>
      <comments>http://www.morrenth.com/transaction-and-retainsameconnection-in-ssis-ole-db-connection-manager.aspx</comments>
      <description><![CDATA[<p>Using MS Access DB is nearly always a pain. What really hurts is that you can't even use a distributed transaction in SSIS when utilizing an OLE-DB Connection accessing an MS Access file. EVEN IF YOU ONLY INTEND TO READ IT! WTF? What kind of transaction support is that?&#160; However, the good news is that you can set the <code>RetainSameConnection </code>property on the OLE DB Connection Manager to true, e.g. when writing to a SQL Server as seen <a href="http://consultingblogs.emc.com/jamiethomson/archive/2005/08/20/SSIS-Nugget_3A00_-RetainSameConnection-property-of-the-OLE-DB-Connection-Manager.aspx">here</a>. This in return enables you to write a BEGIN TRANSACTION in one Execute SQL Task and then choose to COMMIT or ROLLBACK in another one.</p>
<p>But Beware: <b>Avoid loose ends</b> as this will create multiple connections when running tasks parallel. You have to create a chain from BEGIN TRAN to COMMIT, otherwise it will fail.</p>
<p><img width="550" height="273" alt="SSIS manual transaction" src="http://www.morrenth.com/Data/Sites/1/ssistran.png" /></p>
<p>&#160;</p><br /><br /><a href='http://www.morrenth.com'>Florian Morrenth</a>&nbsp;&nbsp;<a href='http://www.morrenth.com/transaction-and-retainsameconnection-in-ssis-ole-db-connection-manager.aspx'>...</a>]]></description>
    </item>
    <item>
      <title>Drop all connections to a database in SQL Server</title>
      <link>http://www.morrenth.com/drop-all-connections-to-a-database-in-sql-server.aspx</link>
      <pubDate>Tue, 28 Feb 2012 08:29:58 GMT</pubDate>
      <guid>http://www.morrenth.com/drop-all-connections-to-a-database-in-sql-server.aspx</guid>
      <comments>http://www.morrenth.com/drop-all-connections-to-a-database-in-sql-server.aspx</comments>
      <description><![CDATA[<p>If you want to restore a database it can be a nasty hunt to find all connections to that database and close/kill them before they open up again...A quick and safe way is to set the database to single user mode like this:</p>
<p><code>alter database your_db set single_user with rollback immediate</code>when you're done restoring your db, just restore the original state with this statement:</p>
<p><code>alter database your_db set multi_user</code></p>
<p>&#160;</p>
<p>&#160;</p>
<p><b>However, if single_user is not an option for you</b>, you can still kill all connections with this script (which is not that safe btw):</p>
<p><code>DECLARE @dbname sysname<br />
SET @dbname = 'your_db'<br />
<br />
DECLARE @spid int<br />
SELECT @spid = min(spid) from master.dbo.sysprocesses where dbid = db_id(@dbname)<br />
WHILE @spid IS NOT NULL<br />
BEGIN<br />
EXECUTE ('KILL ' + @spid)<br />
SELECT @spid = min(spid) from master.dbo.sysprocesses where dbid = db_id(@dbname) AND spid &gt; @spid<br />
END</code><br />
&#160;</p><br /><br /><a href='http://www.morrenth.com'>Florian Morrenth</a>&nbsp;&nbsp;<a href='http://www.morrenth.com/drop-all-connections-to-a-database-in-sql-server.aspx'>...</a>]]></description>
    </item>
    <item>
      <title>check for SQLCMD mode in SQL Sever</title>
      <link>http://www.morrenth.com/check-for-sqlcmd-modein-sql-sever.aspx</link>
      <pubDate>Tue, 28 Feb 2012 08:23:37 GMT</pubDate>
      <guid>http://www.morrenth.com/check-for-sqlcmd-modein-sql-sever.aspx</guid>
      <comments>http://www.morrenth.com/check-for-sqlcmd-modein-sql-sever.aspx</comments>
      <description><![CDATA[<p>I haven't found a way to enable SQLCMD mode from inside a script, but you can CHECK for it and raise an error message before executing the script like this:</p>
<p><code>:setvar checkSQLCMD "checkSQLCMD" <br />
GO <br />
IF ('$(checkSQLCMD)' = '$' + '(checkSQLCMD)') RAISERROR ('This script must be run in SQLCMD mode.', 20, 1) WITH LOG <br />
GO <br />
SELECT 'This part executes only in SQLCMD mode!' </code></p><br /><br /><a href='http://www.morrenth.com'>Florian Morrenth</a>&nbsp;&nbsp;<a href='http://www.morrenth.com/check-for-sqlcmd-modein-sql-sever.aspx'>...</a>]]></description>
    </item>
    <item>
      <title>Validating a Custom Server Control</title>
      <link>http://www.morrenth.com/1validating-a-custom-server-control.aspx</link>
      <pubDate>Fri, 02 Dec 2011 13:06:40 GMT</pubDate>
      <guid>http://www.morrenth.com/1validating-a-custom-server-control.aspx</guid>
      <comments>http://www.morrenth.com/1validating-a-custom-server-control.aspx</comments>
      <description><![CDATA[<p><font size="2">If you need to make a custom server control target of ASP.NET Validation, just add the Attribute </font></p>
<p><code><i><font size="2">[<b>ValidationProperty("Text")</b>]</font></i><br />
<i>public class CustomControl : CheckboxList<br />
&#160;&#160;&#160; { yadayada... }</i></code></p>
<p><font size="2">to the class definiton</font> of the control to tell the ASP.Net validation framework what value to validate...simple, huh? Just replace the "Text" in the live above with the Property of your custom control to be validated.</p><br /><br /><a href='http://www.morrenth.com'>Florian Morrenth</a>&nbsp;&nbsp;<a href='http://www.morrenth.com/1validating-a-custom-server-control.aspx'>...</a>]]></description>
    </item>
    <item>
      <title>Script to Backup Zip and FTP SQL Server Database</title>
      <link>http://www.morrenth.com/script-to-backup-zip-and-ftp-sql-server-database.aspx</link>
      <pubDate>Thu, 22 Sep 2011 21:48:34 GMT</pubDate>
      <guid>http://www.morrenth.com/script-to-backup-zip-and-ftp-sql-server-database.aspx</guid>
      <comments>http://www.morrenth.com/script-to-backup-zip-and-ftp-sql-server-database.aspx</comments>
      <description><![CDATA[<p>Here is a sql server script that makes compressed backups and moves them to an FTP. Quick and drity solution for the paranoic lone developer who's system just crashed...</p>
<p>There are only 2 preconditions: <a href="http://www.7-zip.org/download.html">7-zip</a> installed and xp-cmdshell enabled (see <a href="http://www.sql-server-performance.com/2006/enable-xp-cmdshell-2005/">this</a>).</p>
<p>&#160;</p>
<p><code><i>USE MASTER</i></code></p>
<p><code><i>CREATE procedure spBackupAndFtpDB<br />
@FTPServer&#160;&#160; &#160;varchar(128) ,<br />
@FTPUser&#160;&#160; &#160;varchar(128) ,<br />
@FTPPWD&#160;&#160; &#160;&#160;&#160; &#160;varchar(128) ,<br />
@FTPPath&#160;&#160; &#160;varchar(128) = '/' ,<br />
@DBList&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;varchar(MAX),<br />
@Delimiter&#160;&#160; &#160;varchar(MAX) = ',',<br />
@ZipBackup&#160;&#160; &#160;bit = 1,<br />
@DelteLocalFiles bit = 1,<br />
@workdir&#160;&#160; &#160;varchar(128) = 'C:\Windows\Temp\', <br />
@7zipdir&#160;&#160; &#160;varchar(255) = 'C:\Program Files\7-zip\'<br />
<br />
as<br />
&#160;&#160; &#160;-- deal with special characters for echo commands<br />
&#160;&#160; &#160;select @FTPServer = replace(replace(replace(@FTPServer, '|', '^|'),'&lt;','^&lt;'),'&gt;','^&gt;')<br />
&#160;&#160; &#160;select @FTPUser = replace(replace(replace(@FTPUser, '|', '^|'),'&lt;','^&lt;'),'&gt;','^&gt;')<br />
&#160;&#160; &#160;select @FTPPWD = replace(replace(replace(@FTPPWD, '|', '^|'),'&lt;','^&lt;'),'&gt;','^&gt;')<br />
&#160;&#160; &#160;select @FTPPath = replace(replace(replace(@FTPPath, '|', '^|'),'&lt;','^&lt;'),'&gt;','^&gt;')<br />
&#160;&#160; &#160;<br />
&#160;&#160; &#160;declare&#160;&#160; &#160;@cmd varchar(1000)<br />
&#160;&#160; &#160;declare @workfilename varchar(128)<br />
&#160;&#160; &#160;<br />
&#160;&#160; &#160;DECLARE @SourceFile varchar(255)<br />
&#160;&#160; &#160;<br />
&#160;&#160; &#160;create table #a (id int identity(1,1), s varchar(1000))<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; <br />
<br />
&#160;&#160; &#160;--start loop<br />
&#160;&#160; &#160;DECLARE @CSVString varchar(MAX);<br />
&#160;&#160; &#160;SET @CSVString = @DBList<br />
<br />
&#160;&#160; &#160;DECLARE @pos INT;<br />
&#160;&#160; &#160;DECLARE @DB VARCHAR(MAX);<br />
<br />
&#160;&#160; &#160;SELECT @pos = 1;<br />
<br />
&#160;&#160; &#160;WHILE @pos!= 0<br />
&#160;&#160; &#160;BEGIN<br />
&#160;&#160; &#160;&#160;&#160;&#160; SET @pos = CHARINDEX(@Delimiter,@CSVString);<br />
&#160;&#160; &#160;&#160;&#160;&#160; IF @pos != 0<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; SET @DB = LTRIM(RTRIM(LEFT(@CSVString, @pos - 1)));<br />
&#160;&#160; &#160;&#160;&#160;&#160; ELSE<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; SET @DB = LTRIM(RTRIM(@CSVString));<br />
<br />
&#160;&#160; &#160;&#160;&#160;&#160; IF( LEN(@DB) &gt; 0)<br />
&#160;&#160; &#160;&#160;&#160;&#160; BEGIN<br />
<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; --backup&#160;&#160; &#160;<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; SET @SourceFile = @DB + CONVERT(VARCHAR(6), GETDATE(), 12) + '.bak'<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; SELECT @cmd = 'BACKUP DATABASE [' +&#160;&#160; @DB + '] TO&#160; DISK = N''' + @workdir + @SourceFile + ''' WITH NOFORMAT, INIT,&#160; NAME = N''' + @DB + '-Full Database Backup'', SKIP, NOREWIND, NOUNLOAD,&#160; STATS = 100'<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; EXEC (@cmd)<br />
<br />
<br />
<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; --compress<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; IF @ZipBackup = 1 BEGIN<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; SELECT @cmd = '"' + @7zipdir +'7z" a ' + @workdir + @SourceFile + '.7z ' + @workdir + @SourceFile<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; print @cmd<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; insert #a<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; exec master..xp_cmdshell @cmd<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; <br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; IF @DelteLocalFiles = 1<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; BEGIN<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; --remove backup<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; SELECT @cmd = 'del "' + @workdir + @SourceFile + '"'<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; print @cmd<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; insert #a<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; exec master..xp_cmdshell @cmd<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; END<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; <br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; --set zipped sourcefile<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; SELECT @SourceFile = @SourceFile + '.7z'<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; END<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; <br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; <br />
<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; --ftp<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; select @workfilename = 'ftpcmd.txt'<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; <br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; select&#160;&#160; &#160;@cmd = 'echo '&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;+ 'open ' + @FTPServer<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; + ' &gt; ' + @workdir + @workfilename<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; exec master..xp_cmdshell @cmd<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; select&#160;&#160; &#160;@cmd = 'echo '&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;+ @FTPUser<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; + '&gt;&gt; ' + @workdir + @workfilename<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; exec master..xp_cmdshell @cmd<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; select&#160;&#160; &#160;@cmd = 'echo '&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;+ @FTPPWD<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; + '&gt;&gt; ' + @workdir + @workfilename<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; exec master..xp_cmdshell @cmd<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; select&#160;&#160; &#160;@cmd = 'echo '&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;+ 'put ' + @workdir + @SourceFile + ' ' + @FTPPath + @SourceFile<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; + ' &gt;&gt; ' + @workdir + @workfilename<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; exec master..xp_cmdshell @cmd<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; select&#160;&#160; &#160;@cmd = 'echo '&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;+ 'quit'<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; + ' &gt;&gt; ' + @workdir + @workfilename<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; exec master..xp_cmdshell @cmd<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; <br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; print @cmd<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; select @cmd = 'ftp -s:' + @workdir + @workfilename<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; <br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; insert #a<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; exec master..xp_cmdshell @cmd<br />
<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; <br />
--Not logged in. <br />
--Login failed.<br />
--File not found <br />
<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; IF @DelteLocalFiles = 1<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; BEGIN<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; --remove backup<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; SELECT @cmd = 'del "' + @workdir + @SourceFile + '"'<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; print @cmd<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; insert #a<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; exec master..xp_cmdshell @cmd<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; END<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; <br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; <br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; --report results<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; SELECT id, ouputtmp = s FROM #a WHERE s IS NOT NULL<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; <br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; IF EXISTS(SELECT * FROM #a WHERE s LIKE '%Not logged in%' OR s LIKE '%Login failed%' OR s LIKE '%File not found%' OR s like '%WARNINGS for files%')<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; BEGIN<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; SET @cmd = 'An Error occured during Backup and FTP. Details: '<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; SELECT @cmd = @cmd + '; ' + ISNULL(s, '') FROM #a WHERE s IS NOT NULL<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; RAISERROR (@cmd, -- Message text.<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160; 16, -- Severity.<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160; 1 -- State.<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160; );<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; END<br />
&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; <br />
<br />
&#160;&#160; &#160;&#160;&#160;&#160; END<br />
<br />
&#160;&#160; &#160;&#160;&#160;&#160; SET @CSVString = RIGHT(@CSVString, LEN(@CSVString) - @pos);<br />
&#160;&#160; &#160;END<br />
&#160;&#160; &#160;<br />
&#160;&#160; &#160;<br />
&#160;&#160; &#160;RETURN 0<br />
&#160;&#160; &#160;<br />
go</i></code></p><br /><br /><a href='http://www.morrenth.com'>Florian Morrenth</a>&nbsp;&nbsp;<a href='http://www.morrenth.com/script-to-backup-zip-and-ftp-sql-server-database.aspx'>...</a>]]></description>
    </item>
    <item>
      <title>Custom SiteMapDataSource Menu</title>
      <link>http://www.morrenth.com/custom-sitemapdatasource-menu.aspx</link>
      <pubDate>Sat, 12 Mar 2011 07:47:18 GMT</pubDate>
      <guid>http://www.morrenth.com/custom-sitemapdatasource-menu.aspx</guid>
      <comments>http://www.morrenth.com/custom-sitemapdatasource-menu.aspx</comments>
      <description><![CDATA[<p>I just ran into a problem with a weird historically grown ASP.NET website that has been originally written in ASP. Therefore little of the markup and code was REAL ASP.NET. For example &lt;form runat="server"&gt; tags were only rudimentary implemented. &lt;asp:Menu&gt; Control wouldn't work outside a &lt;form&gt; tag. So before messing with the site (as messy as it was - it worked) I created my own &lt;ul&gt; based menu control which was apparently very easy:<br />
<code>&lt;asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" /&gt;<br />
&lt;asp:Repeater ID="Repeater1" runat="server" DataSourceID="SiteMapDataSource1" EnableViewState="false"&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;HeaderTemplate&gt;&lt;ul id="menu" class="menu"&gt;&lt;/HeaderTemplate&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;ItemTemplate&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;li&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;a class="menulink" href='&lt;%#Eval("url")%&gt;'&gt;&lt;span&gt;&lt;%#Eval("Title")%&gt;&lt;/span&gt;&lt;/a&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;ul&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;asp:Repeater ID="bar" DataSource='&lt;%#Container.DataItem.ChildNodes()%&gt;' runat="server"&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;ItemTemplate&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;li&gt;&lt;a class='&lt;%# String.Format("{0}", IIF(Container.DataItem.HasChildNodes(), "sub", String.Empty)) %&gt;' href='&lt;%#Eval("url")%&gt;'&gt;&lt;span&gt;&lt;%#Eval("Title")%&gt;&lt;/span&gt;&lt;/a&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;ul&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;asp:Repeater ID="bar" DataSource='&lt;%#Container.DataItem.ChildNodes()%&gt;' runat="server"&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;ItemTemplate&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;li&gt;&lt;a class='&lt;%# String.Format("{0}", IIF(Container.DataItem.PreviousSibling() IS Nothing, "topline", String.Empty)) %&gt;' href='&lt;%#Eval("url")%&gt;'&gt;&lt;span&gt;&lt;%#Eval("Title")%&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/ItemTemplate&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/asp:Repeater&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/ul&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/li&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/ItemTemplate&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/asp:Repeater&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/ul&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/li&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/ItemTemplate&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;FooterTemplate&gt;&lt;/ul&gt;&lt;/FooterTemplate&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/asp:Repeater&gt;</code></p>
<p>Note: No Codebehind needed! And jsut add a little .js and .css found <a href="http://www.noupe.com/tutorial/drop-down-menu-jquery-css.html">here</a> and my menu was able to render without a &lt;form&gt; tag. Hooray. That saved the day!</p><br /><br /><a href='http://www.morrenth.com'>Florian Morrenth</a>&nbsp;&nbsp;<a href='http://www.morrenth.com/custom-sitemapdatasource-menu.aspx'>...</a>]]></description>
    </item>
    <item>
      <title>Inline Select Comma Separated List (CSV) fom Table </title>
      <link>http://www.morrenth.com/inline-select-comma-separated-list-csv-fom-table-.aspx</link>
      <pubDate>Tue, 26 Oct 2010 09:44:12 GMT</pubDate>
      <guid>http://www.morrenth.com/inline-select-comma-separated-list-csv-fom-table-.aspx</guid>
      <comments>http://www.morrenth.com/inline-select-comma-separated-list-csv-fom-table-.aspx</comments>
      <description><![CDATA[<p>in SQL Server without using a function as seen on <a href="http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/">Sql Authority</a>...I just love it's simplicity</p>
<p><code><b>(SELECT STUFF((SELECT ', ' + Type FROM dbo.Reactor r FOR XML PATH('')),1,1,''))</b></code><b><br />
</b></p><br /><br /><a href='http://www.morrenth.com'>Florian Morrenth</a>&nbsp;&nbsp;<a href='http://www.morrenth.com/inline-select-comma-separated-list-csv-fom-table-.aspx'>...</a>]]></description>
    </item>
    <item>
      <title>"The custom tool 'MSLinqToSQLGenerator' failed. Unspecified error"</title>
      <link>http://www.morrenth.com/the-custom-tool-mslinqtosqlgenerator-failed-unspecified-error.aspx</link>
      <pubDate>Mon, 18 Oct 2010 08:26:11 GMT</pubDate>
      <guid>http://www.morrenth.com/the-custom-tool-mslinqtosqlgenerator-failed-unspecified-error.aspx</guid>
      <comments>http://www.morrenth.com/the-custom-tool-mslinqtosqlgenerator-failed-unspecified-error.aspx</comments>
      <description><![CDATA[<p><span>When you have a custom partial class attached to the LINQ2SQL file, Visual Studio will delete the corresponding ".designer.cs" file  for your data context and nothing will compile after that point. You can either rename that file every time you make changes or </span><span><br />
move the "<b>using</b>" statements of your <b>custom partial class INSIDE the namespace</b> declaration - and then it works!             </span></p>
<p><code><span>namespace Data<br />
{<br />
<b>&#160;&#160;&#160; using System.Data.Linq.Mapping;<br />
&#160;&#160;&#160; using System.Data.Linq;<br />
&#160;&#160;&#160; using System.Reflection;</b><br />
&#160;&#160;&#160; partial class MyDataContext<br />
&#160;&#160;&#160; {</span></code></p>
<p><code>...</code></p>
<p><code>}</code></p><br /><br /><a href='http://www.morrenth.com'>Florian Morrenth</a>&nbsp;&nbsp;<a href='http://www.morrenth.com/the-custom-tool-mslinqtosqlgenerator-failed-unspecified-error.aspx'>...</a>]]></description>
    </item>
  </channel>
</rss>
