Implicit conversion from data type sql_variant to uniqueidentifer is not allowed.

If you use guids (uniqueidentifiers) in your database in conjunction with ASP.NET SqlDataSource databinding, chances are you'll eventually run into this error "Implicit conversion from data type sql_variant to uniqueidentifer is not allowed. User the CONVERT function to run this query".

Here is a screenshot of the whole error:


The problem is Visual Studio sucks at picking up the fact that this error will occur EVERY SINGLE TIME and continues to let the error happen.

It's easy to fix though. Find your parameters (selectparameters, insertparameters, etc) for the particular statement you're running (select, update, delete, insert). You should see something like this:



The fix is just to remove the Type = "Object" from the parameter that is linked to the uniqueidentifer column in your table. In this case, the controlparameter "CompanyID"  is linked to the companyid column in my companies table. The resulting code should look like this:


Until Next Time...

Ok, So I neglected my blog

For the past couple of months I've neglected my blog. Although, I have been getting a lot of positive feedback for my previous post so at least I'm getting a decent amount of traffic. To be quite honest, I lost the drive to write for a while. I'm hoping that changes and I can get back into giving some decent content to everyone.

I've been mostly working on jumpstarttv.com which is in constant motion. I'm always doing something with it. The development is coming to a close by the end of the month with just minor updates here and there but it's mostly just going to be content development.

Until Next Time (Hopefully it's not six months!)...

Relaunch of JumpStartTV.com

A few months ago my company acquired jumpstarttv.com. One of our partners Brian Knight had started the project a few years ago but got busy and it was left in limbo. We decided that we could take it over and make it a really great site for tasked based videos. Our idea is to have very short (2-5 minute) videos that teach you how to do a specific task or explain a single subject. A couple of examples are "What is the index seek operator" and "Creating a database with SMO".

My part of the project was to spiff it up a little bit. So I've done a few things to the site to make it more user friendly. All the work has been done in visual studio 2008. There's even a little ajax thrown in as well (Part of the "Watch It Later" functionality). With that said there is still a lot of work we're doing to make the site even better.

Look for more updates from me as we goes through various iterations on the site. If you have any suggestions for the site, let me know. We are always looking for feedback!

I've pretty much given up on IE7

IE7 has been giving me a BUNCH of problems lately. Not just on one machine but ALL THREE OF MY MACHINES! It consistently freezes, crashes and continues to really irritate me. I'm using Firefox until they either fix the problem(s). I'll be loading up chrome this week as well.

I used to like IE6 on XP because I could login as a limited access user and use IE as a "shell" to open administrative windows using MakeMeAdmin. They took that away with IE7 and now I'm stuck learning all of the control panel command names. (compmgmt.msc = Computer Management). I'm not real sure what they were thinking with that unless they had only had Vista on the brain.

All in all I'm pretty disappointed with IE. I still *have* to use it while testing features on jumpstarttv.com but other than that, It's firefox for me!

Datatable to List of objects mapper.

In my previous blog post about mapping data rows to objects you saw how easy it was to use reflection to map a data row to an object. With a little extra effort you can map data tables to a list of those mapped objects. The code below builds on my previous blog and will not work unless you have the code from that blog entry.

Public Shared Function MapDataTableToList(Of T)(ByVal dt As DataTable) As IList(Of T)
        If dt Is Nothing Then
            Return Nothing
        End If
 
        Dim list As IList(Of T) = New List(Of T)
       
        For Each dr As DataRow In dt.Rows
            list.Add(MapDatarowToObject(Of T)(dr))
        Next
 
        Return list
    End Function
To explain how this works we’ll go line by line

Public Shared Function MapDataTableToList(Of T)(ByVal dt As DataTable) As IList(Of T)

I’m creating a method that needs to be called by defining a type for T. The only parameter is a data table. An example of calling this method looks like this:

Dim dt As DataTable = GetDataTableFromDb()
Dim usersList As IList(Of User) = MapDataTableToList(Of User)(dt)
 
This would convert a data table to a generic list (IList) of user objects.

If dt Is Nothing Then
Return Nothing
End If

These lines of code make sure that the data table parameter has a value.

Dim list As IList(Of T) = New List(Of T)
 
Create a generic list of objects based on T. T is the generic type specified when calling the method. In the example usage above the T parameter would be of type User.
 
 
For Each dr As DataRow In dt.Rows
list.Add(MapDatarowToObject(Of T)(dr))
Next

Iterate through each data row in the data table and call MapDatarowToObject (from the previous blog entry) and add the mapped object to the list.


Return list
 
Return the list of objects from the method.

So there you go, An easy to use data table to object mapper.

Until next time.

So I can add trainer to my resume...

It's been about a month since I last posted. I have a good excuse although I could have taken 5 minutes over the last month to at least say hi. In any case over the last month I've been busy with two big projects.

The first is the relaunch of JumpStartTV.com. It's was a site developed by Brian Knight with the intentions of a different kind of video site. Along the way it was forgotten. Andy decided to revive the project and I was the one tasked with the revival. I haven't done too much work to it yet as we just wanted to get it up and running with a few minor changes. I added a tag cloud and added some admin tools for automatically processing videos but that's about it. Look for some very nice updates over the next few weeks with a major push of content. We're currently planning 1 new video per day 4 days a week for the SQL channel. The .NET channel will start adding content in October. We have a lot of different authors contributing content which should make for a very cool technical video site. By the way, all of the content is free.

The second project is the one with which I can add trainer to my resume. I successfully put together a Beginning ASP.NET course and delivered it to 7 students last week. It went well in most places but needs a little work to get it totally right. I would say that the students were pretty happy with the content and enjoyed their time training with me. I even had one student buy a $50 gift card as a thank you.

Andy and I are going to be developing two more courses that will be available next year. Advanced ASP.NET and .NET for DBA's. There will be more information on those courses to come.

I'm really excited about the work that I'm doing and this next year should be a really good for me both professionally and personally.

My next blog should be the one I promised a few months ago about mapping a data table to list objects.

Until next time.

Recap of the Central Florida .NET Users Group

Last tuesday I went to speak at the Central Florida .NET Users group. My session covered some of the new features in C# and VB.NET using Visual Studio 2008. I want to thank Roy and Charlie for inviting me to speak. It was my first users group session.

I had a good time with this group. There were a lot of really good questions and suggestions. I've never had such a huge response. Where were these attendees at my last SQL Saturday session?

After the session was over I got to hang out with a couple of the attendees at Chili's. Had a beer, some food and some really interesting conversations. One in particular about Project Euler. I had never heard about it before. It's a really cool site for nerds!

One of the most surprising things I heard that night was the number of employees that attended the users group from a local company. Out of approximately 1000 developers, 2 from the company showed up. 2 out of 1000.... That's just staggering to me. However it's not that surprising. A good number developers do not want to do anything outside of work. I think the reasoning I've heard behind that is if they aren't being paid for it, then why should they do it? The 2 people that showed up were really smart and I enjoyed talking with them.

All in all it was a good night. I got some great feedback, had a good time and enjoyed everything about it. Ok, maybe the two hour drive home at 10:30 P.M. wasn't all that fun but it was worth it...

Sorry for my lack of posts recently. I've been really busy with a few projects that you'll be hearing about shortly.

Minuteman!

No, that's not what my wife calls me. Ok, maybe it is, but that's not the point of this post.

The SQL Saturday "inbetween" this weekend event went pretty well. Lot of old friends and some new ones. I had lunch with a few new speakers which is a rarity that day of the event. As usual got to meet a few new people. I had to remind Joe Healy of our bet. All in all it was a pretty good day. If you're looking for the session files, visit SQLSaturday.com.

Now back to the subject at hand here. The night before my presentation I went over my session. I used the "Use Rehearsed Timings" in powerpoint. The total time (without questions) was about 35 minutes. The last time I did this session I had about 15 minutes of question and answers. I didn't realize until I got to the event that the sessions were 1 hour 15 minutes long. No big deal I would just let them go early and stick around for any private questions.

I started my session at 3:00... It was over at 3:15...

At around 3:14 I thought "Oh sh**, I'm finished?". I tried to remember if I was missing anything. Nothing came to mind. I was at a complete loss. So my total presentation was 15 minutes long. Hence the term "minuteman".

Luckily at that time, Andy walked in and saved the session. He started questioning the audience about triggers . He brought Kendall Van Dyke on stage and we did an impromptu panel session. That went over pretty well.

After the session was over I knew what was coming. I got the "That was a huge screw up!" from Andy. Which, of course, it was. The problem I have this time was I had no idea what happened except to say I rushed the presentation. I'm not sure where I lost all of that time though. Surely I was talking like the micro machines dude. No one complained about anything else except to say my presentation was too short.

So the lesson from all of this is have enough content to cover your session... or talk really slow and take pauses if you don't. Just another lesson along the way for me.

I WON!

Ok... So it didn't come in a package marked "Fragile" (must be italian) but never the less, I did win a prize from community-credit.com. A pair of usp soft monkey speakers (pictures below).

It's an interesting site if you never been to it before. Basically if you do something for the community (teach at an event, help on forums, write a blog post, etc) you get points for it.

I ended up with the 13th most points in March and won a pretty cool set of monkey speakers. My youngest daughter wanted to chew on them but I ended up taking them to work.

Here is the package:



Here they are at my desk at work.



Close up



Pretty cool eh? Thank you to David Silverlight over at community-credit.com!

Upcoming events

I have some upcoming events I'd like everyone to know about.

1) I'm speaking at the "Tweener" SQL Saturday event in Orlando on June 7th. My session will cover using DDL Triggers in development. Tweener has many different meanings so let me clarify. The event occurs between the two TechEd events in Orlando. Hence the name "Tweener". It doesn't have anything to do with a particular sub-culture...

2) I'm speaking at the June 17th Central Florida .NET Users group in Lakeland. Roy Lawson extended an invitation for me to speak after he saw me at the Orlando Code Camp.

3) I'm teaching a course on ASP.NET July 21-24th. I had to start somewhere. I had a dream of teaching development on some level. Now it's becoming a reality. This is first of many courses I plan on developing. A side benefit from writing a course about ASP.NET is that you learn a few things along the way that you didn't know.

4) Last but not least, I turn 30 on June 6th. I feel pretty good about where I'm at in life at 30. I don't feel 30. Obviously I don't look 30 because I cannot buy any alcohol without being carded... But that's a good thing. I was carded for lottery tickets a few months ago. Seriously... I don't look 18? Maybe the cashier was being nice...

In any case, the next few years is where I will make my mark! The last couple were just a start. I'm gearing up for a whole bunch of good stuff...

So this is the reason last blog posts have been spaced so far apart.

Until next time...

«July»
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678