Insert Code Feature

So maybe everyone has this feature in their blog software, but this is the first time I have seen this since I am new to the blogging scene.  There is a feature in BlogEngine that allows you to insert code  into your post.  It parses out C#, J#, VB.NET, T-SQL and ASPX.  Pretty Sweet!  So testing this, I have posted a method to data access class in a current personal project I am working on.


public BaseCollection ExecuteDataReader(string proc, ObjectPopulate populate, BaseCollection collection)
{
   SqlConnection connection =new SqlConnection(_connectionString);
   SqlCommand command =new SqlCommand(proc, connection);
   command.CommandType = CommandType.StoredProcedure;
   SqlDataReader dr =null;
   try
   {
      connection.Open();
      dr = command.ExecuteReader(CommandBehavior.Default);
      while (dr.Read())
      {
         collection.Add(populate(dr));
      }

      return collection;
   }
   finally
   {
      if (dr !=null && !dr.IsClosed)
      {
         dr.Close();
      }
      connection.Dispose();
      command.Dispose();
   }
}

 

Trackback URL

No Comments on "Insert Code Feature"

Hi Stranger, leave a comment:

ALLOWED XHTML TAGS:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to Comments