Tag Archives | ASP.NET/C#

C#: Break vs. Continue in Foreach Loops

A C# Quick Tip: You’ve probably seen ‘break’ before in Switch Case statements, but it also plays an important role in Foreach Loops. To break completely out of a foreach loop (foregoing all the remaining loops), use: break; To go to the next iteration in the loop, use: continue; When is ‘break’ useful? It is […]

Continue Reading

C#: That Pesky DBNull Error in Datatables

Datatables and Tableadapters are one of the most beautiful things about C# and Visual Studio, until you’re processing rows in your datatable and you get something that reads like “The value for column ‘your_column’ in table ‘your_table’ is DBNull.”  If you go a little further, you may get:  “Exception Details: System.InvalidCastException: Specified cast is not […]

Continue Reading

C# – SQL Server Foreign Key, Unique constraints

I got tripped up today with a particularly nasty Join statement that worked perfectly form 90% of the queries, but was blowing up at times.  The error message was:  Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints. I looked and looked at this SQL code: It looked […]

Continue Reading

ASP.Net C# – PHP Equivalents

On this post, I will be collecting ASP.NET C# commands that I use frequently in PHP but I have to continually look up in the little bit of ASP.NET that I do.  PHP can be frustrating for its inconsistencies in syntax, but what is even more frustrating is when you’re trying to do something in […]

Continue Reading

ASP.NET/C#: Convert HTML Colors to System.Drawing.Color

HTML colors come in all sorts of flavors: hexadecimal (#0066ff), named colors (e.g. LightSkyBlue…here’s the link). Many people may be very comfortable with working with HTML colors, so if you’re in C# and needing to get the .Net equivalent, you can translate directly from HTML colors with System.Drawing.ColorTranslator.FromHtml(). Here’s the usage: System.Drawing.Color myColor = System.Drawing.ColorTranslator.FromHtml(“Red”); […]

Continue Reading

Powered by WordPress. Designed by Woo Themes