Executing a SQL Server stored procedure in C#

Are you kidding me? I’m a major amatuer at anything .NET, and after some Googling and about 15 minutes of coding, this works. How ridiculously easy.

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6.  
  7. namespace ExecuteStoredProcedure
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. SqlConnection conn;
  14. try
  15. {
  16. conn = new SqlConnection("server=server;database=db;Trusted_Connection=yes");
  17. conn.Open();
  18. Console.WriteLine("Connection successful…");
  19. }
  20. catch (Exception ex)
  21. {
  22. Console.WriteLine(ex.Message);
  23. return;
  24. }
  25.  
  26. SqlCommand db_cmd = new SqlCommand("dbo.usp_c_sharp_test",conn);
  27. db_cmd.CommandType = CommandType.StoredProcedure;
  28.  
  29. SqlDataReader data_reader;
  30. data_reader = db_cmd.ExecuteReader();
  31. data_reader.Close();
  32. conn.Close();
  33. }
  34. }
  35. }

I’m published in ArcUser!

My (hopefully first of many) article on GIS and Python has been published in the Spring 2008 edition of ESRI’s ArcUser magazine. You can get the pdf here , and the code listings here .

flickruploadr.py now in svn

I finally got around to getting a Subversion repository setup, so the latest development version of my flickuploadr.py can be checked out:

svn co http://svn.super-cooper.com/flickruploadr/trunk

or you can just get it at:

http://svn.super-cooper.com/flickruploadr/trunk

I ate it

I just turned the corner from the kitchen to the dining room, and met up with our three year old son, and he hit me with this:

Son:
There was a booger in my nose.
Me:
And…what did you do with it?
Son:
I ate it.

Oh, the brutal honesty that is childhood.

Converation Viewer now an official WordPress plugin

I finally got around to getting Conversation Viewer into the WordPress plugins SVN repository. Been meaning to do that for a while. Version 1.0.0 can be had from the trunk at:

http://svn.wp-plugins.org/conversation-viewer/trunk/

The writeup and instructions/examples of usage can be found here .

Flickr Uploadr for Mac sucks, Python and the Flickr API to the rescue!

I’ve attempted to use the Flickr Uploadr for the last few years, and it never has impressed me. It always fails, usually after only about 10 pictures, which really sucks when you are trying to upload hundreds of pictures, which I usually do. So last night, I had over 300 shots to upload, and after several attempts, the Flickr Uploadr just kept on failing to upload for me. I’ve been working on my own upload script (most of which is hacked from other peoples code, I must admit) for months now off and on, so I decided to give it a shot - and of course, it uploaded over 100 pics in one shot, without a single blip. As soon as I get a Subversion repository setup on my host server, I’ll get the code in there.

OOPs

Generally, when most people learn that I am a geologist by training, they are surprised. Maybe I just give off some sort of geeky aura, or maybe they are surprised that I’m not "using my degree" (actually I am in a way, but that is too convoluted a story to get into here). At any rate, the point is that I am not a programmer by training. I’d say that at least 75%+ of what I know about programming I taught myself through the ole School of Hard Knocks. I’ve had my share of training courses, but the vast majority of my experience has been just sitting down and cranking out code over the last eight years or so. But I digress. Today was a good day. Today I wrote my first object-oriented Python script from scratch . And it works. It’s not much, about a 100-line geoprocessing script; but it works. And I understand it and now realize how much easier this makes programming in Python. Look out.

Move to WebFaction

Finding the right Web host isn’t easy. Google "<web host name> review" for virtually any host out there, and you will find a plethora of both positive and negative feedback. Chances are, you’re going to find more negative feedback than positive just about every time. A month or so ago, when I was looking for a Web host for super-cooper.com, I spent alot, and I mean alot of time researching Web hosts. Apparently I didn’t do that great of a job the first time around. I chose AN Hosting , mostly because they were recommended by WordPress (although rumor has it that the WP folks get a kickback from those recommendations, which would not surprise me at all) and also because the number of negative reviews I found about them was small. Don’t get me wrong, the service was OK, and their plans are well-stocked, but the reliability and the speed just weren’t there. So last week, when I came across Brian’s post where he asked for options on a new host, I realized from the comments that I had to look into WebFaction - almost everyone who commented on his post recommended them. So I decided to switch. What a charm. Sign up was a breeze, and boy is this site faster. WebFaction claims to not "max out" their servers, and so far, I believe them. The list of what they provide is unique, so go check it out . I’m really dyin’ to get my GeoDjango on…

Retro - It’s all about the donuts

Kids are amazing little buggers, especially when they are your amazing little buggers. One of the most amazing things about having kids is that you can actually learn from them. Yeah, imagine that. Something I have learned from our boys is that it really is the little things in life that make it all worth while. Take for example, donuts. Last summer, we flew from our humble little home in northwest Arkansas to Seattle to visit the wife’s sister and boyfriend, and we took the boys. We stayed in this crappy little motel downtown right near the Space Needle (location, location, location). It was cheap, and we figured “Hey, all we’re going to do is sleep there, right. How bad can it be?” When we got there, the little one was asleep in the car so the wife and the big one went in to “check it out”. Upon return, the wife said that “…it’s not that bad”. I later realized that it was one room barely large enough to hold the king size bed all four of us were to sleep in for a week. Oh, and the bathroom only had a shower, no tub to give the boys a bath in (although they found showers to be quite a novelty that week). Now, if I was going to go back to Seattle, I probably would choose another place to stay. Granted, it wasn’t that bad; it was clean, the staff was friendly and helpful, and did I mention the donuts? No? Well, if you asked our boys if they wanted to go to Seattle tomorrow, they would INSIST on staying in that hotel. Why, you ask? Well, the donuts, of course. Every morning the staff would put out this huge spread of donuts, pastries, muffins, and bagels, and once the boys found out about this, they would shoot out of bed every, yes every morning and want to go get donuts. At 6 AM. So we would go to the lobby, my wife or myself barely awake, the boys still in their pajamas, and get donuts. Lots of donuts. Way too many donuts. About an hour later, our room looked like a donut factory where some sort of explosion had taken place. Sprinkles here, frosting there, donut detritus everywhere (hey, that rhymed). Yeah, if we go back to Seattle with the boys, I think we all know where we will be staying.

Mapping point locations with Python and Microsoft Live Search Maps

This article was first published in the February 2008 issue of Python Magazine . It is being reproduced here with the permission of Marco Tabini and Associates .

Requirements

Python 2.4+
pyExcelerator module (http://sourceforge.net/projects/pyexcelerator/ )
Anthony Tuininga’s ceODBC module (http://sourceforge.net/html/ceODBC.html )
John Machin’s xlrd module (http://www.lexicon.net/sjmachin/xlrd.htm )
Michael Foord’s cgiutils module (http://www.voidspace.org.uk/python/cgiutils.html )

Lets face it, using Python, we can pull data from virtually anywhere in the corporate enterprise - databases, text files, or other documents. But how can we easily visualize data that has place associated with it? Well, we turn to Python and the API of a popular web-mapping application, that’s how.

Read more »

Next Page »