Write class instance to XML File and read file contents

You have a class and you need to save values to of the class to an xml file to be consumed later on  [code source=”C#”] public class TemplateInformation { public string StoredProcedure { get; set; } public List<string> Parameters { get; set; } public string TemplatePath { get; set; } public string TemplateName { get; … More Write class instance to XML File and read file contents

Writing Data From .Net to Excel Interrupted by User Opening Excel Window

Problem I have an application that generates financial reports in excel. After installing Office 2013, if a user opens excel while the application is running, the application returns a error: System.Runtime.InteropServices.COMException with HRESULT: 0x800AC472 which interrupts the data from being written to the spreadsheet. After some research according to Microsoft this was done by design, the … More Writing Data From .Net to Excel Interrupted by User Opening Excel Window

OAuth2 – Pass Access Token – C#

Now that you have your Access Token – in case you missed it, here is the link to how to get it OAuth2: Get an Access Token – C#, you can now pass your authorization token to interact with your API. Make sure to add a header to your request with your authorization token [code … More OAuth2 – Pass Access Token – C#

Handy C#, VB.Net & SQL Code Snippets

Date time – how to initialize a date [code language=”csharp”] DateTime value = new DateTime(2017, 1, 18); [/code] Concatenate string list into comma separated string [code language=”csharp”] List<string> message = new List<string>(); message.Add("Record exists"); message.Add("Invalid data format"); message.Add("Duplicated record"); string output = String.Join(", ", message.Where( m=> (m.Length != 0))); Console.WriteLine(output); [/code] Initialize a string list … More Handy C#, VB.Net & SQL Code Snippets

This Recordset is not Updateable

Problem I have a Microsoft Access database application. When updating a record from the screen, users kept getting the error: This recordset is not updateable The form datasource is a query with two tables Solution This query was not updatable, here is a list of reasons why a query would not be updatable By Allen … More This Recordset is not Updateable

Error The “GenerateResource” task failed unexpectedly.

Problem I was enhancing an application that I have been working with for years, without any trouble. This application was developed with Visual Studio and the solution has multiple projects. While I was working on the enhancements I did some refactoring and renamed some of the classes and files on the application. All of the “sudden” … More Error The “GenerateResource” task failed unexpectedly.

Refactoring IV – Finally There

On the previous post, we moved validation functionality to the Scraping object. The resulting function was this: [code language=”csharp”] private void btnStockSales_Click(object sender, RoutedEventArgs e) { TickerDataCollection = new ObservableCollection&amp;amp;amp;amp;lt;TickerData&amp;amp;amp;amp;gt;(); var stockList = ReadStockData(); foreach (var item in stockList) { Scraper y = new Scraper(); TickerData x = y.Scraping(item); TickerDataCollection.Add(new TickerData(x.Ticker) { High = x.High, … More Refactoring IV – Finally There

Refactoring III -Why is this here?

On the previous post I moved URL parsing code by extending the StockData class and creating a property called Url, now we are left with this code, but if you look at the highlighted code, there are way too many things happening here!. [code language=”csharp” highlight=”14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29″] private void btnStockSales_Click(object sender, RoutedEventArgs e) { TickerDataCollection = new ObservableCollection(); // … More Refactoring III -Why is this here?

Refactoring II- Encapsulating

On my previous post, I started refactoring a function that reads stock and dates, checks the data against Yahoo Finance and returns some data. In this function, I take the Stock Ticker and the data and parse the URL to be evaluated by our web scrapper object. [code language=”csharp” highlight=”13,14,15,16,17,18,19,20,21,22,23″] private void btnStockSales_Click(object sender, RoutedEventArgs … More Refactoring II- Encapsulating

Refactoring I -Convert Linq Anonymous Types to List

Refactoring is an important process to crafting readable and maintainable code. Functions should follow  the single responsibility principle – a function should do one thing and one thing only and should have few lines of code. Like with everything, you should apply this with measure and wisdom. I was asked to write a function that … More Refactoring I -Convert Linq Anonymous Types to List

Books every software developer should read in 2016 – if you have not done so

The obligatory reflection on what have we accomplished in 2015 … always a sticky question. But if keep it to my book, training and research, it does not look that bad, I managed to keep the momentum going. Software Development Cracking the coding Interview – Gayle Laakman This is a great book with brain teasers and … More Books every software developer should read in 2016 – if you have not done so