<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SandboxM</title>
	<atom:link href="http://www.sandboxm.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sandboxm.com</link>
	<description>From one fellow developer to another</description>
	<lastBuildDate>Sun, 13 Sep 2009 15:44:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>jQuery and Google Maps with KML</title>
		<link>http://www.sandboxm.com/jquery-and-google-maps-with-kml/</link>
		<comments>http://www.sandboxm.com/jquery-and-google-maps-with-kml/#comments</comments>
		<pubDate>Sat, 13 Jun 2009 21:23:55 +0000</pubDate>
		<dc:creator>Mufaddal</dc:creator>
				<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[kml]]></category>
		<category><![CDATA[maps]]></category>

		<guid isPermaLink="false">http://www.sandboxm.com/?p=126</guid>
		<description><![CDATA[Marc Grabanski has written a great tutorial on how to spice up Google Maps using JQuery. What I have done is a slight variation of his tutorial.
Instead of placing ten random markers on the map, we will generate driving directions from point A to B and use the KML data from Google Maps to render [...]]]></description>
			<content:encoded><![CDATA[<p>Marc Grabanski has written a great <a href="http://marcgrabanski.com/article/jquery-google-maps-tutorial-basics">tutorial</a> on how to spice up Google Maps using JQuery. What I have done is a slight variation of his tutorial.</p>
<p>Instead of placing ten random markers on the map, we will generate driving directions from point A to B and use the KML data from Google Maps to render the markers.<br />
Appending &#8220;&#038;output=kml&#8221;, Google Maps will return a KML document which we can then parse to get the marker information.</p>
<pre class="brush: javascript">
var geoXml;
var urlKML = &quot;http://maps.google.com/maps?saddr=&quot;;
urlKML += fromAddress.val();
urlKML += &quot;&amp;amp;amp;daddr=&quot;;
urlKML += toAddress.val();
urlKML += &quot;&amp;amp;amp;output=kml&quot;;
geoXml = new GGeoXml(urlKML);
</pre>
<p>We can now create an XMLDOM object using the KML and parse the nodes to get all the marker coordinates and its description.</p>
<pre class="brush: javascript">
var doc = new ActiveXObject(&quot;Microsoft.XMLDOM&quot;);
doc.async = false;
doc.load(urlKML);
if (doc.parseError.errorCode != &#039;0&#039;) {
errordiv.innerHTML = &quot;Error generating KML! Probably an invalid address...&quot;;
return false;
} else errordiv.innerHTML = &quot;&quot;;
var coords = doc.documentElement.selectNodes(&quot;Document/Placemark/Point/coordinates&quot;);
var places = doc.documentElement.selectNodes(&quot;Document/Placemark/name&quot;);
</pre>
<p>We can now loop through each and add the markers to the map.</p>
<pre class="brush: javascript">
for (var i = 0; i &lt; coords.length; i++) {
var pts = [];
pts = coords[i].text.replace(&quot;,0&quot;, &quot;&quot;).split(&quot;,&quot;);
var point = new GLatLng(pts[1], pts[0]);
marker = new GMarker(point);
map.addOverlay(marker);
markers[i] = marker;
}
</pre>
<p>And append the description to each marker using the .html property:</p>
<pre class="brush: javascript">
$(markers).each(function(i, marker) {
$(&quot;&lt;li /&gt;&quot;)
.html(places[i].text)
.click(function() {
displayPoint(marker, i);
});
GEvent.addListener(marker, &quot;click&quot;, function() {
displayPoint(marker, i);
$(&quot;#myInfoWindow&quot;)
.html(places[i].text)
});
});
</pre>
<p>You can view the final demo <a href="http://www.sandboxm.com/examples/DirectionsGmapJQuery.html">here</a>.<br />
Its still work-in-progress so feel free to chime in with your suggestions. Next I am going to add to the map are lines connecting the markers with each other.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-7751726290657945";
/* BlueMixBanner468x60 */
google_ad_slot = "6850902170";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.sandboxm.com%2Fjquery-and-google-maps-with-kml%2F';
  addthis_title  = 'jQuery+and+Google+Maps+with+KML';
  addthis_pub    = 'sandboxm';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.sandboxm.com/jquery-and-google-maps-with-kml/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Excel and ASP.NET: Converting from HTML, Gridlines, etc.</title>
		<link>http://www.sandboxm.com/excel-and-aspnet/</link>
		<comments>http://www.sandboxm.com/excel-and-aspnet/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 02:22:20 +0000</pubDate>
		<dc:creator>Mufaddal</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[excel]]></category>

		<guid isPermaLink="false">http://www.sandboxm.com/?p=114</guid>
		<description><![CDATA[Here&#8217;s how to generate Excel (xls\xlsx) files on-the-fly. 
All search results talked about setting the Page.Content-Type to &#8220;vnd.xls&#8221; or &#8220;vnd.ms-excel&#8221; and using the obsolete &#8220;content-disposition&#8221; meta tag. But I just wanted to save the data without popping up the confirmation dialog. Luckily Excel can read HTML tables very well, so all I had to do [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s how to generate Excel (xls\xlsx) files on-the-fly. </p>
<p>All search results talked about setting the Page.Content-Type to &#8220;vnd.xls&#8221; or &#8220;vnd.ms-excel&#8221; and using the obsolete &#8220;content-disposition&#8221; meta tag. But I just wanted to save the data without popping up the confirmation dialog. Luckily Excel can read HTML tables very well, so all I had to do is take the HTML buffer and save it to disk with an XLS file extension. </p>
<pre class="brush: c#">

protected void Page_Load(EventArgs e)
{
string strData = GetDataFromWhereEver();
ExportToExcel(strData, &quot;C:\ExcelFiles&quot;, &quot;MyExcelFile.xls&quot;);
}

private void ExportToExcel(string strHTMLbuffer, string path, string filename)
{
Byte[] bytes = System.Text.Encoding.ASCII.GetBytes(strHTMLbuffer);
FileStream fs = new FileStream(path + &quot;\\&quot; + filename, (FileMode)FileAccess.Write);
fs.Write(bytes, 0, bytes.Length);
fs.Close();
}
</pre>
<p>But once converted, I didn&#8217;t like the whitespace in Excel. So using the VBA code that I found <a href='http://www.nickhodge.co.uk/pre2007/gui/toolsmenu/options/view.htm'>here</a> and <a href='http://msdn.microsoft.com/en-us/library/aa214512(office.11).aspx'>here</a>, I managed to turn on the Gridlines in the Excel file. </p>
<p>Here you go:</p>
<pre class="brush: c#">

Excel.ApplicationClass  app = new Excel.ApplicationClass();
app.Visible = false;
Excel.Workbook workbook = app.Workbooks.Open(Filename, 0, false, 5, &#039;&#039;, &#039;&#039;, false, Excel.XlPlatform.xlWindows, &#039;&#039;, true, false, 0, true, false, false);

Excel.Worksheet worksheet = (Excel.Worksheet)workbook.ActiveSheet;
worksheet.Activate();
app.ActiveWindow.GridlineColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic;
app.ActiveWindow.DisplayGridlines = true;
worksheet.PageSetup.Draft = false;
workbook.Save();
app.Workbooks.Close();
app.Quit();
</pre>
<p>Make sure you&#8217;ve added a reference to the Office 11.0 Object Library.</p>
<p>That&#8217;s it!</p>
<p>Comments\Suggestions always welcome.</p>
<p><!--adsense --></p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.sandboxm.com%2Fexcel-and-aspnet%2F';
  addthis_title  = 'Excel+and+ASP.NET%3A+Converting+from+HTML%2C+Gridlines%2C+etc.';
  addthis_pub    = 'sandboxm';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.sandboxm.com/excel-and-aspnet/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Backup and Zip files automatically</title>
		<link>http://www.sandboxm.com/backup-and-zip-files-automatically/</link>
		<comments>http://www.sandboxm.com/backup-and-zip-files-automatically/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 01:40:21 +0000</pubDate>
		<dc:creator>Mufaddal</dc:creator>
				<category><![CDATA[VBScript]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[vbs]]></category>

		<guid isPermaLink="false">http://www.sandboxm.com/?p=90</guid>
		<description><![CDATA[Couple of days ago, my Access database (mdb) got corrupted. I kept getting the &#8220;Invalid bookmark&#8221; error whenever I ran a select against one of my tables. To make it worse, the last time I had backed up my database was 4 days ago, so in other words, in one snap I had nothing to [...]]]></description>
			<content:encoded><![CDATA[<p>Couple of days ago, my Access database (mdb) got corrupted. I kept getting the &#8220;Invalid bookmark&#8221; error whenever I ran a select against one of my tables. To make it worse, the last time I had backed up my database was 4 days ago, so in other words, in one snap I had nothing to show for my week&#8217;s worth of work. That&#8217;s when I decided to come up with an automated way of backing up my data because apparently I couldn&#8217;t trust myself to do the job regularly.<br />
I looked around for sample VB code or a bat file that would backup my files at regular intervals. But backing up the files wouldn&#8217;t be enough, I also wanted to zip them up together so that would a) save space and b) keep them all together. I found lots of snippets that required WinZip or 7-zip (I know it&#8217;s free) but I didn&#8217;t want to rely on a specific 3rd party program. Finally I found 2 pieces of code <a href="http://social.msdn.microsoft.com/forums/en-US/windowsgeneraldevelopmentissues/thread/d3e347cc-f4dc-44a6-8f84-977f958d89c6/">here </a>and <a href="http://www.mvps.org/dmcritchie/excel/gridline.htm">here</a> which I converted into a VBS file.</p>
<p>Here&#8217;s the code:</p>
<pre class="brush: vb">
strDBName = &quot;myAccessDB&quot;
strFolderLocation = &quot;C:\Databases\&quot;
strDate = Right(&quot;00&quot; &amp; DatePart(&quot;M&quot;, Date),2) &amp; Right(&quot;00&quot; &amp; DatePart(&quot;D&quot;, Date),2) &amp; DatePart(&quot;YYYY&quot;, Date)
strTime = Right(&quot;00&quot; &amp; DatePart(&quot;H&quot;, Time),2) &amp; Right(&quot;00&quot; &amp; DatePart(&quot;N&quot;, Time),2) &amp; Right(&quot;00&quot; &amp; DatePart(&quot;S&quot;, Time),2)
zipfilename = strFolderLocation &amp; strDate &amp; &quot;_&quot; &amp; strAppName &amp; &quot;.zip&quot;
filename = strFolderLocation &amp; strAppName &amp; &quot;.mdb&quot;
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
&#039;Zip it only if the MDB file is found
IF fso.FileExists(filename) THEN
&#039;If a file with the same name exists, append Time to the Zip file name.
IF fso.FileExists(zipfilename) THEN
zipfilename = strFolderLocation &amp; strDate &amp; strTime &amp; &quot;_&quot; &amp; strAppName &amp; &quot;.zip&quot;
END IF
strZIPHeader = Chr(80) &amp; Chr(75) &amp; Chr(5) &amp; Chr(6) &amp; String(18, 0)
Set tf = fso.CreateTextFile(zipfilename)
tf.Write(strZIPHeader)
tf.Close()
With CreateObject(&quot;Shell.Application&quot;)
.NameSpace(zipfilename).CopyHere(filename)
End With
wScript.Sleep 1000
Wscript.Echo(strAppName &amp;  &quot; zipped and saved to &quot; &amp; zipfilename)
ELSE
WScript.Echo(&quot;Could not find database: &quot; &amp; filename)
END IF
</pre>
<p>Finally for the automation part, I set up a Scheduled Task in Windows&#8217; Task Scheduler to execute the VBS file every day at 9pm so my work is backed up a few hours after I have left the office.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-7751726290657945";
/* BlueMixBanner468x60 */
google_ad_slot = "6850902170";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.sandboxm.com%2Fbackup-and-zip-files-automatically%2F';
  addthis_title  = 'Backup+and+Zip+files+automatically';
  addthis_pub    = 'sandboxm';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.sandboxm.com/backup-and-zip-files-automatically/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Top 5 Free WebEx alternatives</title>
		<link>http://www.sandboxm.com/top-5-free-webex-alternatives/</link>
		<comments>http://www.sandboxm.com/top-5-free-webex-alternatives/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 00:33:20 +0000</pubDate>
		<dc:creator>Mufaddal</dc:creator>
				<category><![CDATA[Freebies]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[gotomeeting]]></category>
		<category><![CDATA[webex]]></category>

		<guid isPermaLink="false">http://www.sandboxm.com/?p=59</guid>
		<description><![CDATA[WebEx is one of the best web conferencing solutions out there. But it comes at a price. So if you&#8217;re looking for the same functionality (or almost the same functionality) for FREE, keep reading. 
1. Dimdim &#8211; my personal favorite. Feature-rich and very stable.
2. Yugma -  a close second, comes with a Skype add-in.
3. Yuuguu &#8211; Free for [...]]]></description>
			<content:encoded><![CDATA[<p>WebEx is one of the best web conferencing solutions out there. But it comes at a price. So if you&#8217;re looking for the same functionality (or almost the same functionality) for FREE, keep reading. </p>
<p>1. <a href="http://www.dimdim.com">Dimdim</a> &#8211; my personal favorite. Feature-rich and very stable.</p>
<p>2. <a href="http://www.yugma.com">Yugma</a> -  a close second, comes with a Skype add-in.</p>
<p>3. <a href="http://www.yuuguu.com">Yuuguu</a> &#8211; Free for use for up to 30 participants! </p>
<p>4. <a href="http://www.mikogo.com">Mikogo</a> &#8211; super-fast, it&#8217;s a snap to install. But the yellow giraffe doesn&#8217;t look professional when I use it with my clients.</p>
<p>5. <a href="http://www.vyew.com">Vyew</a> &#8211; yet to try this one out for myself, but my friends recommend it highly.</p>
<p> </p>
<p>Disclaimer: Above links are direct links to the websites and not affiliate links so I am not making a dime off of this. </p>
<p> <br />
<!--adsense--></p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.sandboxm.com%2Ftop-5-free-webex-alternatives%2F';
  addthis_title  = 'Top+5+Free+WebEx+alternatives';
  addthis_pub    = 'sandboxm';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.sandboxm.com/top-5-free-webex-alternatives/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to remove null or empty columns from a GridView</title>
		<link>http://www.sandboxm.com/how-to-remove-null-or-empty-columns-from-a-gridview/</link>
		<comments>http://www.sandboxm.com/how-to-remove-null-or-empty-columns-from-a-gridview/#comments</comments>
		<pubDate>Sat, 08 Nov 2008 15:30:06 +0000</pubDate>
		<dc:creator>Mufaddal</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[gridview]]></category>

		<guid isPermaLink="false">http://www.sandboxm.com/?p=63</guid>
		<description><![CDATA[Recently, I created a dashboard which displays, let&#8217;s say account balances, by month. I wrote a query that pivoted the data in the format that I wanted (totals by month). My SQL query returned 12 columns, one for each month, but the database contains data for only the past 6 months. Since my 12 columns [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I created a dashboard which displays, let&#8217;s say account balances, by month. I wrote a query that pivoted the data in the format that I wanted (totals by month). My SQL query returned 12 columns, one for each month, but the database contains data for only the past 6 months. Since my 12 columns were fixed or &#8220;non-dynamic&#8221;, the result was that the GridView showed 6 empty columns.</p>
<p>I googled a lot to remove the null columns but all results referenced the column by name or ID but I had to do this dynamically. Lot of results talked implementing the logic in the GridView_RowDataBound method but after a lot of head-scratching, it hit me! I was trying to fix the problem at the GridView end. Why not deal with the problem when the columns are returned from the database and before the datatable is attached to GridView&#8217;s data source? And so that&#8217;s what I did. Looped thru each column and subsequently looped thru each row one by one, if any of the rows contain a valid value, do not remove the column. Simple.</p>
<p>Here&#8217;s the C# code:</p>
<pre class="brush: c#">

protected void Page_Load(object sender, EventArgs e)
{
GridView GridView1 = new GridView();
DataTable myDataTable = GetDatafromDB();
myDataTable = RemoveNullColumns(myDataTable);
GridView1.DataSource = myDataTable;
GridView1.Databind();
}

private DataTable RemoveNullColumns(DataTable dt)
{
for (int c = 0; dc &lt; dt.Columns.Count; c++)
{
string colName = dt.Columns[c].ColumnName;
bool allRowsempty = true;
for (int r = 0; r &lt; dt.Rows.Count; r++)
{
string tempVal = dt.Rows[r][c].ToString();
if (tempVal != &quot;&quot;) //Can also use Convert.DbNull here
{
allRowsempty = false;
}
}
if (allRowsempty)
{
dt.Columns.Remove(colName);
c--;
}
}
return dt;
}
</pre>
<p>Hope this saves you some time and effort!</p>
<p><!--adsense--></p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.sandboxm.com%2Fhow-to-remove-null-or-empty-columns-from-a-gridview%2F';
  addthis_title  = 'How+to+remove+null+or+empty+columns+from+a+GridView';
  addthis_pub    = 'sandboxm';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.sandboxm.com/how-to-remove-null-or-empty-columns-from-a-gridview/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Migrating from Wordpress.com</title>
		<link>http://www.sandboxm.com/migrating-from-wordpress/</link>
		<comments>http://www.sandboxm.com/migrating-from-wordpress/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 03:32:13 +0000</pubDate>
		<dc:creator>Mufaddal</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[migration]]></category>

		<guid isPermaLink="false">http://www.sandboxm.com/?p=54</guid>
		<description><![CDATA[I had initially set up this blog on WordPress.com to kick the tires and understand how WordPress worked etc. Once I was comfortable with it, I decided to host my blog at this domain. I would recommend this approach for all new bloggers-to-be out there.
When I searched for &#8220;migrate wordpress&#8221;, I got a lot of results [...]]]></description>
			<content:encoded><![CDATA[<p>I had initially set up this blog on <a title="WordPress" href="http://www.wordpress.com">WordPress.com</a> to kick the tires and understand how WordPress worked etc. Once I was comfortable with it, I decided to host my blog at this domain. I would recommend this approach for all new bloggers-to-be out there.</p>
<p>When I searched for &#8220;migrate wordpress&#8221;, I got a lot of results that talked about downloading plugins that can backup\restore your blog etc. But if your blog is hosted on wordpress.com they are of no use.</p>
<p>So, you have set up your blog at xyzblogname.wordpress.com, written a few posts, tried a few different themes, test-driven a handful plugins and now you&#8217;re all set to take off the training wheels.  You have secured the www.xyzblogname.com domain name and installed WordPress and are ready to migrate your blog to its new home.</p>
<p>1. Log in to your Wordpress.com blog: www.xyzblogname.wordpress.com\wp-admin\</p>
<p>2. Click on Manage and then Export.</p>
<p>3. Select &#8216;All Authors&#8217; in the Restrict Author drop-down.</p>
<p>4. Click on Download Export File.</p>
<p>5. Save the xml file somewhere on your computer.</p>
<p>6. Login to the Admin console of your new blog at www.xyzblogname.com/wp-admin/</p>
<p>7. Click on Manage and then Import.</p>
<p>8. From the list of systems, click on Wordpress.</p>
<p>9. Click on Browse to select the xml file you saved on Step 5.</p>
<p>10. Click on Upload File and Import and let Wordpress handle the rest.</p>
<p>You&#8217;re all set!</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.sandboxm.com%2Fmigrating-from-wordpress%2F';
  addthis_title  = 'Migrating+from+Wordpress.com';
  addthis_pub    = 'sandboxm';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.sandboxm.com/migrating-from-wordpress/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Truncate all tables in a SQL database</title>
		<link>http://www.sandboxm.com/truncate-all-tables-in-a-sql-database/</link>
		<comments>http://www.sandboxm.com/truncate-all-tables-in-a-sql-database/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 03:05:05 +0000</pubDate>
		<dc:creator>Mufaddal</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[storedprocedures]]></category>

		<guid isPermaLink="false">http://www.sandboxm.com/?p=51</guid>
		<description><![CDATA[This is a handy script that I use regularly. You may wonder why I need to truncate all my tables so frequently but that&#8217;s a different story.
When I was searching for this script, almost all results had the &#8216;exec&#8217; command in the loop to truncate the tables as it looped through each. But I modified it slightly [...]]]></description>
			<content:encoded><![CDATA[<p>This is a handy script that I use regularly. You may wonder why I need to truncate all my tables so frequently but that&#8217;s a different story.</p>
<p>When I was searching for this script, almost all results had the &#8216;exec&#8217; command in the loop to truncate the tables as it looped through each. But I modified it slightly and have replaced the &#8216;exec&#8217; with the &#8216;print&#8217; command. What I would like the script to do is generate truncate statements for each table which I can review and in case I want to remove a few tables from it, I can comment them out and execute the rest of the block.</p>
<p>So here we go:</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>DECLARE @tableName VARCHAR(1024)<br />
DECLARE table_cur CURSOR FOR <br />
SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = &#8216;BASE TABLE&#8217;</p>
<p>OPEN table_cur</p>
<p>FETCH NEXT FROM table_cur INTO @tableName</p>
<p>WHILE @@FETCH_STATUS = 0<br />
BEGIN<br />
PRINT (&#8216;TRUNCATE TABLE &#8216;+ @tableName)<br />
FETCH NEXT FROM table_cur INTO @tableName<br />
END</p>
<p>CLOSE table_cur<br />
DEALLOCATE table_Cur</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Please feel free to chime in with any suggestions\recommendations!</p>
<p><!--adsense--></p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.sandboxm.com%2Ftruncate-all-tables-in-a-sql-database%2F';
  addthis_title  = 'Truncate+all+tables+in+a+SQL+database';
  addthis_pub    = 'sandboxm';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.sandboxm.com/truncate-all-tables-in-a-sql-database/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Run Command Prompt on a Mobile Device</title>
		<link>http://www.sandboxm.com/command-prompt-on-mobile-device/</link>
		<comments>http://www.sandboxm.com/command-prompt-on-mobile-device/#comments</comments>
		<pubDate>Sat, 27 Sep 2008 18:49:15 +0000</pubDate>
		<dc:creator>Mufaddal</dc:creator>
				<category><![CDATA[Registry]]></category>
		<category><![CDATA[registry commandprompt]]></category>

		<guid isPermaLink="false">http://sandboxm.wordpress.com/?p=24</guid>
		<description><![CDATA[The Command Prompt is not available on a Windows Mobile device out-of-the-box. So if you want to do some command-line compiling or registering a DLL on the mobile device you&#8217;ll have to install the PPC Command Shell Power Toy. You can download it here. Follow the instructions in the ReadMe file to set it up.

However, [...]]]></description>
			<content:encoded><![CDATA[<p>The Command Prompt is not available on a Windows Mobile device out-of-the-box. So if you want to do some command-line compiling or registering a DLL on the mobile device you&#8217;ll have to install the PPC Command Shell Power Toy. You can download it <a title="PPC Command Shell" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=74473fd6-1dcc-47aa-ab28-6a2b006edfe9&amp;DisplayLang=en" target="_blank">here</a>. Follow the instructions in the ReadMe file to set it up.</p>
<div id="attachment_25" class="wp-caption alignnone" style="width: 258px"><a href="http://sandboxm.com/wp-content/uploads/2008/09/ppccommandshell.gif"><img class="size-full wp-image-25" title="PPC Command Shell" src="http://sandboxm.com/wp-content/uploads/2008/09/ppccommandshell.gif" alt="PPC Command Prompt" width="248" height="374" /></a><p class="wp-caption-text">PPC Command Prompt</p></div>
<p><!--adsense--><br />
However, a few of my colleagues have come across the following problem:</p>
<p>When you double-click the cmd.exe on the mobile device, it does not launch the Command Prompt window.</p>
<p>The solution was quite simple yet hard to find. Edit the mobile device&#8217;s Registry and change the OutputTo DWORD value to &#8220;0&#8243; under the HKEY_LOCAL_MACHINE \ Drivers \ Console folder.</p>
<div id="attachment_28" class="wp-caption alignnone" style="width: 310px"><a href="http://sandboxm.com/wp-content/uploads/2008/09/regeditor2.gif"><img class="size-medium wp-image-28" title="Editing the Registry" src="http://sandboxm.com/wp-content/uploads/2008/09/regeditor2.gif?w=300" alt="Editing the Registry" width="300" height="224" /></a><p class="wp-caption-text">Editing the Registry</p></div>
<p>If you have Visual Studio 2005 installed, you can access the Remote Registry Editor under Visual Studio Remote Tools. Or there are a bunch of Registry Editors out there for mobile devices that you can use e.g. <a title="CeRegEditory" href="http://ceregeditor.mdsoft.pl/index.php?lang=en" target="_blank">CeRegEditor </a>and <a title="PHM Registry Editor" href="http://www.phm.lu/products/PocketPC/RegEdit/" target="_blank">PHMRegEditor</a>.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.sandboxm.com%2Fcommand-prompt-on-mobile-device%2F';
  addthis_title  = 'Run+Command+Prompt+on+a+Mobile+Device';
  addthis_pub    = 'sandboxm';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.sandboxm.com/command-prompt-on-mobile-device/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enable FILECTL ActiveX component on Mobile Devices</title>
		<link>http://www.sandboxm.com/enabling-filectl-on-devices/</link>
		<comments>http://www.sandboxm.com/enabling-filectl-on-devices/#comments</comments>
		<pubDate>Mon, 15 Sep 2008 04:31:42 +0000</pubDate>
		<dc:creator>Mufaddal</dc:creator>
				<category><![CDATA[VBScript]]></category>
		<category><![CDATA[filectl]]></category>

		<guid isPermaLink="false">http://sandboxm.wordpress.com/?p=17</guid>
		<description><![CDATA[Earlier I wrote about how you could use the FILECTL component to write files on a mobile device.
A few people emailed me to tell me that they were getting the &#8220;ActiveX cannot create object CreateObject&#8221; error. So this time I&#8217;m going to go into more detail about how you first prepare the mobile device before [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier I wrote about how you could <a href="http://www.sandboxm.com/write-files-using-filectl/">use the FILECTL component to write files</a> on a mobile device.</p>
<p>A few people emailed me to tell me that they were getting the &#8220;ActiveX cannot create object CreateObject&#8221; error. So this time I&#8217;m going to go into more detail about how you first prepare the mobile device before you can use the FILECTL component.</p>
<p>Let&#8217;s get to it:</p>
<ol>
<li>Download and copy the regsvrce.exe and MSCEFile.dll to the /Windows folder on the device. There are a couple of different versions of MSCEFile.dll out there, make sure you have the correct one based on your device OS\version.</li>
<li>Enable Command Prompt on the device. You can download the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=74473FD6-1DCC-47AA-AB28-6A2B006EDFE9&amp;displaylang=en">PPC Command Shell</a> powertoy to do this.<br />
NOTE: If you keep double-clicking the cmd.exe and nothing happens, here&#8217;s what you do:<br />
a. Access the Registry and change the &#8220;OutputTo&#8221; DWORD value to 0 (zero) under HKEY_LOCAL_MACHINE\Drivers\Console.</li>
<li>Launch the Command Prompt window, and type &#8220;regsvrce.exe MSCEFile.dll&#8221; and press Enter.</li>
<li>A pop-up message will appear saying the DLL was registered successfully.</li>
<li>You&#8217;re done!</li>
</ol>
<p>Now run your VBScript again and it should not throw any CreateObject-related errors.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.sandboxm.com%2Fenabling-filectl-on-devices%2F';
  addthis_title  = 'Enable+FILECTL+ActiveX+component+on+Mobile+Devices';
  addthis_pub    = 'sandboxm';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.sandboxm.com/enabling-filectl-on-devices/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Writing Files on a Mobile Device using FILECTL</title>
		<link>http://www.sandboxm.com/writing-files-on-a-mobile-device-using-filectl/</link>
		<comments>http://www.sandboxm.com/writing-files-on-a-mobile-device-using-filectl/#comments</comments>
		<pubDate>Sun, 14 Sep 2008 03:06:47 +0000</pubDate>
		<dc:creator>Mufaddal</dc:creator>
				<category><![CDATA[VBScript]]></category>
		<category><![CDATA[filectl]]></category>
		<category><![CDATA[pocketpc]]></category>

		<guid isPermaLink="false">http://sandboxm.wordpress.com/?p=12</guid>
		<description><![CDATA[If you want to write files on a mobile device, this can be easily accomplished using a little VBScript.
I was trying to use the FileSystemObject component to write files. However, the file storage component is managed differently on PocketPC 2002/03, Windows CE 4.2 (and above) devices such as the HP iPAQ, Symbol 9090 etc. Instead [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to write files on a mobile device, this can be easily accomplished using a little VBScript.</p>
<p>I was trying to use the FileSystemObject component to write files. However, the file storage component is managed differently on PocketPC 2002/03, Windows CE 4.2 (and above) devices such as the HP iPAQ, Symbol 9090 etc. Instead of FileSystemObject, the FILECTL component needs to be called. FileCtl is the FSO equivalent for Windows CE.</p>
<p>Following is the VBScript code:</p>
<p>Dim objTextFile, strText<br />
strText = &#8220;This is my string of data&#8221;</p>
<p>&#8216; objTextFile.Open needs the following Const values:<br />
&#8216; ForAppending, fsAccessWrite, fsLockReadWrite<br />
Const ForAppending = 8<br />
Const fsAccessWrite = 2<br />
Const fsLockReadWrite = 0</p>
<p>Const objFilePath = &#8220;\Temp\MyFile.txt&#8221;</p>
<p>Set objTextFile = CreateObject(&#8220;FILECTL.File&#8221;)<br />
objTextFile.Open objFilePath, ForAppending, fsAccessWrite, fsLockReadWrite</p>
<p>&#8216; Writes strText every time you run this VBScript<br />
objTextFile.LinePrint(strText)</p>
<p>objTextFile.Close<br />
set objTextFile = nothing</p>
<p>For reference, you can go to:  <a href="http://msdn2.microsoft.com/en-us/library/ms860108.aspx">http://msdn2.microsoft.com/en-us/library/ms860108.aspx</a></p>
<p>If you know of a better way accomplishing this, feel free to share!</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.sandboxm.com%2Fwriting-files-on-a-mobile-device-using-filectl%2F';
  addthis_title  = 'Writing+Files+on+a+Mobile+Device+using+FILECTL';
  addthis_pub    = 'sandboxm';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.sandboxm.com/writing-files-on-a-mobile-device-using-filectl/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
