Tag Archives | c#

C# / VSTO – Using Excel Ranges

Using Visual Studio Tools for Office (VSTO) with Excel lets you use C# (or your other favorite .NET language to leverage the power of Excel. But you will have to learn how the syntax for the Excel object model as opposed to just using VBA syntax. This post shows you how to use Excel ranges […]

Continue Reading

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
datatable

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
relax_constraints

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

Powered by WordPress. Designed by Woo Themes