Archive for category C#
Using a Custom IDataReader to Stream Data Into a Database
Posted by Michael Bowersox (Admin) in .NET, C#, SQL Server on December 22, 2011
In a previous post, I discussed how to use the SqlBulkCopy class along with a SqlDataReader to quickly stream data from one database to another. The reason that you can use a SqlDataReader as a parameter in the WriteToServer method of SqlBulkCopy is because it implements the IDataReader interface. The great thing about this, is [...]
Streaming Data Between Databases using SqlBulkCopy and SqlDataReader
Posted by Michael Bowersox (Admin) in .NET, C#, SQL Server on December 1, 2011
One little known fact about SqlBulkCopy is that not only can the WriteToServer method use a DataTable, but it can also use any object that implements IDataReader. Since the SqlDataReader object implements the IDataReader interface, it is a perfect candidate for use with a SqlBulkCopy object. One instance where I found this extremely useful, is [...]
Converting From WPF Foreground to Windows Forms ForeColor
Posted by Michael Bowersox in .NET, C#, WPF on February 18, 2011
I recently had the need to read the foreground color of a WPF control to assign to the foreground color of a Windows Forms control that I had hosted in a Windows Forms Host control. Once I started investigating, I realized that this wasn’t going to be as straight forward as I planned since the [...]
Semaphores in C#
Posted by Michael Bowersox in .NET, C# on January 16, 2011
A short while ago I had a need to limit simultaneous requests to a web service from a multi-threaded application to prevent timeouts. I learned about semaphores in school and knew this was the right approach, but I have never used one in a real-world application before. Luckily, the .NET framework makes it rather easy [...]