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

Reputation: 4577 Guru
Group:
Moderators
Active Posts:
8,149 (4.9 per day)
Joined:
08-June 10
Profile Views:
77,544
Last Active:
User is offline Today, 09:21 AM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Who Cares
Favorite Gaming Platform:
PC
Your Car:
Chevrolet
Dream Kudos:
1000
Expert In:
C#, LINQ, Dynamics CRM 2011

Latest Visitors

Icon   Curtis Rutland has been promoted!

Posts I've Made

  1. In Topic: Changing database values

    Posted 19 Dec 2014

    View PosttlhIn`toq, on 14 December 2014 - 01:10 PM, said:

    Quote

    string strSQL = "UPDATE tblUsers SET Locked=true WHERE UserID=?";
    


    Just a thought... But I doubt the userId is a question mark. Maybe you have to actually supply the ID such as 1, 2, 3 ... So the db knows which user to update.


    FYI, in Access, ? is a parameter. You can include named parameters, but they won't be applied that way; they'll be applied in the order in which they were sent.
  2. In Topic: SQL Class - with parameters?

    Posted 18 Dec 2014

    rgfirefly24 is correct. You need to flip your logic a bit. You seem to want a single class, single method that can execute any arbitrary query using parameters. Well, you could do that, but it would be difficult and bad design. It would mean that everywhere you had to do the query, that part of the code would have to know what its own query is. If you ever changed databases, you'd have to go to every single query in your code and fix it.

    On the other hand, if you designed your "Data Layer" like an API (the things calling into it don't care how the data is gotten, just that it is), you make maintenance much easier.

    Here's the long and short of it. Instead of passing datareaders or datatables around, you should make Models of your objects. For instance, if you have a table called Person, you could have a class that matches.

    In your data layer, you would have a method called "GetPerson" (perhaps) that would take an integer parameter, and return the Person record who's ID matches the provided value. You would perform the query entirely inside that method, and then create a new Person object and fill it, then return that.

    That way, the calling code doesn't have to know SQL. All it has to do is say "give me the person who's ID = 10".
  3. In Topic: Expression difference?

    Posted 18 Dec 2014

    Well, I'm not sure then. I would suggest to not try to parse out the date for each iteration (you're doing a lot of extra comparisons on something that won't change, and parsing a date for each one), but I'd suggest that for both snippets, to be honest.

    Can you try something like this and see if the LINQ gives you the desired output:

    var ed = DateTime.Now.Year >= 2015 ? DateTime.Parse("3000-01-01") : DateTime.Parse("2014-01-01");
    var cp = m.historicalProviderChoices.FirstOrDefault(p => p.endDate == ed);
    
  4. In Topic: C# Client Was Not Authenticated Error

    Posted 18 Dec 2014

    The C# Advanced Discussion forum is for discussions, not help Q&A. I've moved your topic into the standard C# forum.

    From what I've seen online, providing a username/password should work. You should verify that the account that you're trying to use is not locked or expired.

    Otherwise, there are some suggestions here:
    http://stackoverflow...fice-365-in-net
  5. In Topic: Expression difference?

    Posted 18 Dec 2014

    Well, the LINQ version will return the first match. Your loop will return the last match, because you're not breaking once you've found an item.

My Information

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

Contact Information

E-mail:
Click here to e-mail me
Website URL:
Website URL  http://curtisrutland.com
Skype:
Skype  insertAlias_bytes
Twitter:
curtisrutland

Comments

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

    NewRandomUsername Icon

    06 Jun 2014 - 20:59
    Did you get my messages(emails) sir?
  2. 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.
  3. Photo

    eric wallace Icon

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

    no2pencil Icon

    06 Dec 2012 - 08:34
    It still isn't good enough.
  5. 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 ??
  6. Photo

    tlhIn`toq Icon

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

    Curtis Rutland Icon

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

    MATTtheSEAHAWK Icon

    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.
  9. Photo

    Curtis Rutland Icon

    08 Sep 2011 - 12:59
    Thanks!
  10. Photo

    Sergio Tapia Icon

    08 Sep 2011 - 12:29
    Congrats on becoming a mod. :D
  11. 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.
    Cheers.
  12. 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
  13. Photo

    Curtis Rutland Icon

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

    Dogstopper Icon

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

    CodingSup3rnatur@l-360 Icon

    01 Mar 2011 - 14:35
    No problem at all. Glad I could contribute :)
  • (2 Pages)
  • +
  • 1
  • 2