Programming

SqlDataReader Null Handling

SqlDataReader null handling When reading values from a SqlDataReader in .NET null SQL values will cause the reader to error. I used to have an explicit null check around each column, however as this involved quite a bit of code duplication I had a look for something better and found Read more…

Programming

SQL Stored Procedure In .NET

I generally end up forgetting how to return results from a SQL stored procedure within .NET so I figured I’d put it here for reference. public static List<Blog> GetBlogSummaries() { List<Blog> blogs = new List<Blog>(); using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings[“BlogDatabase”].ConnectionString)) { using (SqlCommand command = new SqlCommand(“sp__get_blog_summaries”)) { command.CommandType Read more…