Curtis Rutland's Profile User Rating: *****

Reputation: 4312 Guru
Active Posts:
7,593 (5.38 per day)
08-June 10
Profile Views:
Last Active:
User is online 3 minutes ago
Viewing Board Index

Previous Fields

OS Preference:
Favorite Browser:
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Your Car:
Dream Kudos:
Expert In:
C#, LINQ, Dynamics CRM 2011

Latest Visitors

Icon   Curtis Rutland has been promoted!

Posts I've Made

  1. In Topic: C# SQL Parameters

    Posted 18 Apr 2014

    Start working on it now. Keep SOLID principles in mind. Think of your methods as individual operations.

    Also, I want to mention a particular inefficiency I noticed. It looks like all you're doing the select for is to get a count of values that are returned. However, you're doing a SELECT * to do so. Think of how that works: the DB has to get every column and stream it out to you. SQL has built-in functionality for this, it's called aggregation. Things like Counting, Summing, stuff like that. That way, instead of having SQL return you a dataset that you have to count, you can tell it to just return you a count.

    SELECT COUNT(SomeIdColumn) FROM SomeTable WHERE SomeColumn = @SomeParameter

    You're calling ExecuteScalar first, then ExecuteReader. I'm not sure why. ExecuteScalar is for returning one value. As such, it's designed for aggregate queries (like Count). You can use ExecuteScalar to run your count query and not have to deal with the reader at all.

    Now, thinking with SOLID principles, you will want to break things up a bit. You'll probably want to have a class that can handle your data access. This class should manage its own connection objects, preferably by reading the conn string from the configs. It stands up and tears down its own connections on demand. The "public interface", or the public methods you expose, shouldn't need information about the connection or query itself. You should make a method for getting the count, then for inserting a row. And the second method should have parameters for the values to be inserted (not using a static object, which it appears Data is, not sure since I can't see the definition).

    Hope all this helps.
  2. In Topic: Add a Datagridview column to a listbox using a for loop

    Posted 18 Apr 2014

    Well, there are a few problems with your code. First things first: you're making the classic mistake of treating UI elements like they're data storage. They're not. They're designed to show data. They're backed by classes that handle storing data, such as the DataSet you fill in your Load event. You should be pulling data from that, not your UI control.

    Second, this code doesn't do what you think it does:

            for(int i = 0; i < dgvEnrollments.Columns.Count; i++)
                DataGridViewColumn column = dgvEnrollments.Columns[4];

    You say you want to get items from a single column, but you're looping through all your columns. Then, you use a magic number to reference a specific column, but since it's inside the loop, you'll repeat that code for however many columns you have. Then you're just calling column.ToString. That's not going to dump what's in a column out; it'll do whatever is defined for .ToString, which in this case is probably just returning the type name. On top of that, you have a block (the { } code) that's not attached to any block operation, like a conditional or loop. Remove the brackets, they do nothing but confuse the reader.

    My suggesting is to try this again, but use the enrollmentsDataSet object to pull your data from instead of the DataGridView.
  3. In Topic: Help - Conversion

    Posted 18 Apr 2014

    TryParse is the safe way to go. Of course, you'll have to handle the case of values that don't parse. Usually the best way to do this is to write a do-while loop. Do: get input from user and attempt to parse float; while: the conversion fails. If the conversion succeeds, move on to the next.

    The best way to implement this is a function, one that handles reading, converting, and looping if necessary.
  4. In Topic: A Unit System

    Posted 18 Apr 2014

    Agreed, I usually prefer explicit casting as well. I feel that implicit is occasionally appropriate, but it does make the code more readable with the cast operator being explicit.
  5. In Topic: A Unit System

    Posted 17 Apr 2014

    Very neat concept. I wonder if you could also do implicit casting, so assigning one unit to another (of the same "kind") would handle the conversion automatically?

My Information

Member Title:
(╯□)╯︵ (~ .o.)~
29 years old
August 29, 1984
San Antonio
Forum Leader:
Full Name:
Curtis Rutland
Years Programming:
Programming Languages:
C# -- Forms, WPF, Silverlight, WCF

Contact Information

Click here to e-mail me
Website URL:
Website URL
Skype  insertAlias_bytes


  • (2 Pages)
  • +
  • 1
  • 2
  1. Photo

    BenignDesign Icon

    03 May 2013 - 13:29
    I see you were staring at my profile. I also stare randomly at profiles. We have much in common. We should probably hook up sometime. Just sayin.
  2. Photo

    eric wallace Icon

    31 Jan 2013 - 02:53
    can you help for visual basic
  3. Photo

    no2pencil Icon

    06 Dec 2012 - 08:34
    It still isn't good enough.
  4. Photo

    ikram002p Icon

    27 Jun 2012 - 10:51
    "It Doesn't Work!" That's not good enough!
    It Still Doesn't Work!.
    I didnt undestand it ??
  5. Photo

    tlhIn`toq Icon

    18 Mar 2012 - 11:22
    Congrats on breaking 3000
  6. Photo

    Curtis Rutland Icon

    08 Sep 2011 - 14:13
    "Leveling up." I like that!
  7. Photo


    08 Sep 2011 - 13:55
    Yar ya see, i remember when yee wer purple!
    Anyways congrats! It's weird seeing people who've been one way so long "leveling up" :P.
  8. Photo

    Curtis Rutland Icon

    08 Sep 2011 - 12:59
  9. Photo

    Sergio Tapia Icon

    08 Sep 2011 - 12:29
    Congrats on becoming a mod. :D
  10. Photo

    Ace26 Icon

    15 Jun 2011 - 13:39
    Hi mate, interesting to see we are age mates. Nice work you do in the forums.
    Just dropped by to say hi, anyways.
  11. Photo

    RetardedGenius Icon

    20 Apr 2011 - 18:56
    Excellent C# tutorials, they've taught me a lot I didn't know. Please keep more of the good stuff coming! :D
  12. Photo

    Curtis Rutland Icon

    24 Mar 2011 - 14:55
    Yeah, felt like "professionalizing".
  13. Photo

    Dogstopper Icon

    23 Mar 2011 - 17:08
    Woah. Name switch! I took a double take...
  14. Photo

    CodingSup3rnatur@l-360 Icon

    01 Mar 2011 - 14:35
    No problem at all. Glad I could contribute :)
  15. Photo

    Curtis Rutland Icon

    22 Feb 2011 - 15:50
    Thanks for noticing! I was actually out of town away from a computer when it ticked over.
  • (2 Pages)
  • +
  • 1
  • 2