C# Ventures - Unable to convert MySQL date/time value to System.DateTime
So it's been a while since I wrote an article.
To jump everyone up to speed...
I got a job at Ipayment doing C# and thought it would be a great opportunity to blog about some of the problems I am already encountering as well as tricks I find useful along my way.
I was using the SQL Library
("Using System.Data.MySqlClient")
I was doing a connection and executing a query then populating a data grid.
Everything seemed to be working with what I was doing so I decided to switch over to Mysql.
This is when I received this bloody error.
"Unable to convert MySQL date/time value to System.DateTime"
So I did some research and found that this error occurs when you have a null datatime field.
Solution? Add to the connection string
Allow Zero Datetime=trueThis should remove the error and now null dates will show.
Simple Image Grab In Wordpress
I wrote a simple function that you can use in your functions.php file
(Located in your Theme Folder)
Size options: thumbnail, medium, large or fullfunction grab_img($id,$size)
{
//Get images attached to the post
$args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'numberposts' => -1,
'order' => 'ASC',
'post_status' => null,
'post_parent' => $id
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $attachment) {
$img = wp_get_attachment_image_src( $attachment->ID,$size );
break;
}
//Display image
return $img[0];
}
}Then in any theme file call the function
<img src="<?php grab_img(get_the_ID(),'thumbnail') ?>" alt="" />
Plomer - Creativity is the power to connect.
Creativity is the power to connect the seemingly unconnected.
— William Plomer
An Expert
An expert is a person who has made all the mistakes that can be made in a very narrow field.
— NIELS BOHR
Advice on Life
A little old but I think this is one of the greatest pieces of advice for anyone that has a passion for anything. I have it posted on my wall and I look to it for inspiration to actually do something. Thanks to Randall for all of his great stuff at xkcd.com

Tron Legacy
Anyone else excited? A new Tron movie is set to hit this year and apparently the previews are showing in theaters currently.
Who's your VPS provider?
A recent comparison of VPS providers by Eivind Uggedal makes a pretty clean cut case. The study shows that between Slicehost, Linode, Prgmr, Rackspace and Amazon EC2, one is the definate winner in all benchmarks. Linode is a XEN based provider which I do know has wiped the floor with other hypervisors for quite some time. I'll let you take a look at the data for yourself but pay attention to the notes at the foot of each graph. Some graphs measure a score(where higher is better) and some measure runtime(where lower times mean the process was faster in execution).
Unixbench single process score (higher is better).
Unixbench 4 parallel processes score (higher is better).
SQL-bench on PostgreSQL. Runtime in seconds (lower is better).
Django test suite on PostgreSQL. Runtime in seconds (lower is better).
Off URL Launched
Visit: http://url.2theleft.la/
Injecting jQuery into your WebBrowser Control
If you're working with the WebBrowser control in the .NET Framework you know how painful it is to have to select elements using standard methods. SelectElementById is convenient, however most elements do not have an id.

jQuery provides a relatively powerful element selector system. As a web developer, being without jQuery is annoying. Thats why we need to inject it into our WebBrowser control so we can play around with it.
The first thing you're going to need to do is add a reference to MSHTML.dll. Then, in the top of your source file, add this:
using mshtml;
First we need to inject the actual jQuery source. For this example, we're going to use Google's generous CDN to link the jQuery source.
HtmlElement head = WebBrowser1.Document.GetElementsByTagName("head")[0];
HtmlElement script_element = WebBrowser1.Document.CreateElement("script");
IHTMLScriptElement element = (IHTMLScriptElement)script_element.DomElement;
element.type = "text/javascript";
element.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js";
head.AppendChild(script_element);
Now, the key part is determining when to inject that code. I prefer the Document_Completed method, as this automatically injects the code with each page refresh. You're probably also wondering how we use it.
I prefer this method:
string js = "function Exec() { $(".rows").hide("fast"); }";
HtmlElement head = _omegleBrowser.Document.GetElementsByTagName("head")[0];
HtmlElement el = _omegleBrowser.Document.CreateElement("script");
IHTMLScriptElement element = (IHTMLScriptElement)el.DomElement;
element.text = js;
head.AppendChild(el);
WebBrowser1.Document.InvokeScript("Exec");Enjoy!
View of Augmented Reality Years from Now
He did it as a college product but it may be a view of the amazing and scary things to make it in to our daily lives.





