Using SQL Server Management Objects (SMO) in C# with Setup

First Add References. Mine are located:

C:\Program Files (x86)\Microsoft SQL Server\110\SDK\Assemblies
- Microsoft.SqlServer.Smo.dll
- You may have to add more than just this DLL.  Try adding one at a time until it works.

Then, you should be able to access the includes:

using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;

After this, you should be setup to transfer databases and script them out from one place to another like you are using SQL Server Management Studio. All the options should be available.

ServerConnection sourceConnection = new ServerConnection("SOURCEPATH");
Server sourceServer = new Server(sourceConnection);
//sourceServer.ConnectionContext.LoginSecure = false;
//sourceServer.ConnectionContext.Login = "3tier";
//sourceServer.ConnectionContext.Password = "3tier";
Database sourceDatabase = sourceServer.Databases["SourceDB"];
ServerConnection destinationConnection = new ServerConnection("localhost");
Server destinationServer = new Server(destinationConnection);
Database destinationDatabase;
if (destinationServer.Databases.Contains("SourceDB"))
    //destinationServer.ConnectionContext.LoginSecure = false;
    //destinationServer.ConnectionContext.Login = "3tier2";
    //destinationServer.ConnectionContext.Password = "3tier2";
    destinationDatabase = destinationServer.Databases["SourceDB"];
    destinationDatabase = new Database(destinationServer, "SourceDB");
Transfer transfer = new Transfer(sourceDatabase);
transfer.CopyAllObjects = false; //turn off because we just want tables and sp
transfer.CopyAllTables = true;
transfer.CopyAllStoredProcedures = true;
transfer.DropDestinationObjectsFirst = true;
transfer.UseDestinationTransaction = true;
transfer.CopyAllTables = true;
transfer.Options.Indexes = true;
transfer.Options.WithDependencies = true;
transfer.Options.ContinueScriptingOnError = true;
transfer.CopySchema = true;
transfer.Options.WithDependencies = true;
transfer.Options.DriAll = true;
transfer.Options.AnsiFile = true;
transfer.Options.SchemaQualify = true;
transfer.Options.WithDependencies = false;
transfer.Options.ScriptDrops = true;
transfer.CreateTargetDatabase = true;
transfer.CopySchema = true;
transfer.CopyData = false;
transfer.DestinationServer = destinationServer.Name;
transfer.DestinationDatabase = destinationDatabase.Name;
//transfer.DestinationLoginSecure = false;
//transfer.DestinationLogin = "3tier2";
//transfer.DestinationPassword = "3tier2";
transfer.Options.IncludeIfNotExists = true;

Be sure to double and triple check because it can wipe out the destination databases without you realizing it.

I hope this helps you out!

How To Know If CloudFlare Is Working

  1. Login to your Cloudflare console
  2. Click the gear on the url and set “Page Rules”
  3. Check “Forwarding”
  4. Url Patern:
  5. Destination:
  6. Add Rule and wait a few minutes.
  7. Go to your url, and you should be redirected to your “ison” url.


GTD with Evernote

I read Getting Things Done by David Allen last summer around this time and have been using many of his methods ever since.

I am not going to go into details into GTD, but here are the 5 Principles:

Principle 1: Use your brain for processing not storage.
Principle 2: All items must be processed.
Principle 3: Master Workflow.
Principle 4: Five Steps of Project Planning.
Principle 5: The Power of the Next-Action Decision.

Evernote Setup:

Bookmark it on your desktop computers
Download the app for your smartphone
Install Evernote widgets (android) to be able to quickly insert items into evernote.

Create Notebooks:
@@Inbox (where items will await processing)
@Active (where items will stay till complete)
@Inactive (or closed/complete)

Create Custom Searches:
@Active tag:web
@Active tag:home
@Active tag:call

I have yet to transform every aspect of my life with GTD, but I have taken control of the smaller to-do list type items. Here are the principles I focus on:

Principle 1: Use your brain for processing and not storage.

As soon as I think of an item, I will insert a very brief reminder into an Evernote notebook called @@Inbox.
The @ symbol is so it will appear first in the list and is default.

This allows me to never have a moment when I have to say to myself “What was it I wanted to do/lookup/read/errand/remind someone?”

The items in @@Inbox will be processed later when I am not at the store or driving.

Principle 2: All items must be processed.

I open my @@Inbox notebook and go through each and every item

Then I tag. Examples : home, web, errand, call.

Add reminders to anything you plan on doing at a later date.

Move the item notebook called @Active
- Note: complete any items that take less than two minutes.

Principle 3: Master Workflow

This step is a lot more involved than I use it for, but for simple to-do list activities this is what I do:

Get reminders that I set in Principle 2

Or, Process Backlog:

If I am at home, I will pull up the Custom Search “@Active tag:home” first. This will give me all the backlog items at home.

You can bookmark this custom search so it will show up in the app at all times or you can add it to the widget.

If I just want to go through all items, I pull up @Active and look for items.
When finished, move the items to @Inactive.

This is how I successfully GTD for a year. Even though I don’t do some of the bigger items like doing large projects or scanning every document and putting it into a folder. I still feel very accomplished when I crank through small items and close them and set them to @Inactive.

New Domain:

I went ahead and took the plunge! Our family has a new domain!

I purchased and setup subdomains for: and

If you go to, I just made a pretty lame looking landing page.

I debated doing, but I wanted micaela and all of our other children and animals to have the ability to have subdomains. So, I look forward to making a fat cat homepage at


I setup a free account with CloudFlair too! It should increase speed and reduce server load. I need this because all of this is hosted on a free hosting account at Freehostia (I love Freehostia).

Get a Server’s IP that is Always Changing

So, my server at home’s IP address is always changing. Sometimes it’s sitting there broadcasting my development server’s website to the world on an IP that I don’t know.

So, when this happens, I have to go get physical access and bring up or something like it.

There are a few solutions to this problem:

  • DynDNS – A good solution, but I hate that they will cancel your service when you don’t login.
  • Get a static IP from your ISP – Costs extra money
  • Somehow, get the server to broadcast it’s address to a static place

I went with the last option. You could do this in a multitude of ways. You could have your server send it’s address in an email to you periodically or on boot. You could FTP it to a free FTP server. You get the idea.

I did this:
* : that keeps it’s IP. It has PHP.
* : that changes it’s IP.

I setup a cron job on to run every 8 hours and open a PHP page:

0 */8 * * * /usr/bin/curl ""

The page on will record the last 50 IPs sent to it in a logfile:

	$file = 'log/file.txt';
	$max = 50;
	$content = "\n<br/>" . date("Y-m-d H:i:s") . " " . $_SERVER['REMOTE_ADDR'] . "";
	$filecontents = file_get_contents($file);
	$filecontents = $content . $filecontents;
	$filecontents = implode("\n<br/>", array_slice(explode("\n<br/>", $filecontents),0, $max));
	echo $filecontents;
	file_put_contents($file, $filecontents);

So, if my server’s IP ever changes, there will be a nice little record of the last known IPs. I can go into my DNS settings for and set them to the new IP.

<!-- Log File -->
<br/>2013-07-30 12:56:09
<br/>2013-07-30 04:56:10
<br/>2013-07-29 20:56:21
<br/>2013-07-29 20:56:19
<br/>2013-07-29 20:56:15
<br/>2013-07-29 20:56:12
<br/>2013-07-29 20:55:48
<br/>2013-07-29 20:55:32
<br/>2013-07-29 20:50:04

Quick Weather App in Your URL

I wanted to make a good little weather app for myself for Richmond, VA.

I couldn’t find what I wanted, but I was able to write a little bookmarklet using Chrome and Firefox’s ability to have data:text urls.

Here is the URL:

data:text/html,<html><head><style>body,img {white-space:nowrap;float:left;}</style></head><body><img src = "!1!1&dd=0&bw=0&hrspan=48&pqpfhr=6&psnwhr=6" /><img src = "!1!1&dd=0&bw=0&hrspan=48&pqpfhr=6&psnwhr=6" /><img src = "!1!1&dd=0&bw=0&hrspan=48&pqpfhr=6&psnwhr=6" /></body></html>

Just put that in your URL and you will get a good Richmond Weather Graph.

The pictures are taken from:

Android – Large File Transfer – Samsung Galaxy S3 SGS

This is one way transfer large files to android when other methods do not work:

  • Turn on Developer Mode and Debugging Tools
  • Install Android SDK on your computer
  • Plug in phone and open the command prompt and type:
  • More ADB info

    PATH-TO\android-sdk-windows\platform-tools\adb.exe push PATH-TO\ /mnt/sdcard/
  • This usually takes a second.  I would first try transferring a small file to make sure you have the correct path.

Note: The ‘/mnt/sdcard’ may be specific to my device.  If you can’t seem to find a writable folder do this:

PATH-TO\android-sdk-windows\platform-tools\adb.exe shell

then, using ls and cd commands, you can move around and try and find the path to your writable directory.


Hope this helps someone!

Teaching Kids to Code –

My friend Eric is a technology teacher at a school in the Richmond area and I were discussing the importance of teaching kids to code.  The website goes into it.

I thought I should write up a quick tutorial on ways for kids (or grown ups) to code while:

  • Having fun
  • Creating
  • Learning
  • Sharing their work
  • Building off of each others work

My tutorial utilizes two technologies:

jsfiddle : This web platform allows you to program in javascript and see your results.  You can share and build off existing code. : This javascript library allows you to cool stuff like: this, this, or this.  It is a powerful library that has great documentation.

So, here are my basic first instructions:


So, in this example, you can change the line of code:
to be:

Hit RUN, and you will get a red background.

Then, you can use the SHARE button and you can see options to use Twitter or just send a link without any code:


So, I think you could learn a whole lot from these two things combined.

Hope this helps!


MailChimp – Pass Email to Form

mail chimp logo

I wanted to use a basic email field and send the information to a mailchimp form.  I could not find the solution anywhere, so I decided to see if I could hack a solution.

When you go to MailChimp > For Your Website > Signup Form Link Code
You will get something like:, which will take you to something like:;id=XXXXXXXXXXX

If you look at the source on this page, you will see that the form elements are called: MERGE0, MERGE1…

On my form, the email field is MERGE0, so on my website, I was able to create a javascript link that will automatically fill in email by using this link:;id=XXXXXXXXXXX&amp;

You can fill in more than one field by adding more merge fields in the url:;id=XXXXXXXXXXX&amp;;MERGE1=Daniel Folkes

Then, you can use this jquery to auto open a new window on enter key press:

            $("#ea").keypress(function (e) {
                if (e.which == 13) {
                    var url = "//";
                    url += "&MERGE0=" + $("#ea").val(); // ea is my email input text box.
          , "mywindow", "status=1,toolbar=1,resizable=1,width=1000,height=600");