• 1/13/2010

    C# custom Attribute on an enum object

    posted by:Josh

    Today I was working with an enum on a class object and I wanted something more than just the default MyObject.MyEnum.ToString() (which returns the name of my enum as defined in code). Here was my enum:

    public enum ImportType
    {
    FullProduct = 1,
    ImageProduct = 2,
    PriceProduct = 3,
    Customer = 4
    }

    I wanted something more descriptive and readable than 'FullProduct' so I asked my good buddy Google. That lead me to this article. After adding in a couple classes my enum now looks like:

    public enum ImportType
    {
    [Description("Full Product Import")]
    FullProduct = 1,
    [Description("Product Image Import")]
    ImageProduct = 2,
    [Description("Product Price Import")]
    PriceProduct = 3,
    [Description("Customer Import")]
    Customer = 4
    }

    Now on my front end I can call

    <%# EnumHelper.GetDescription((ImportType)Eval("Type")) %>

    and get 'Full Product Import' instead of 'FullProduct'

  • 12/14/2009

    SqlDataAdapter.Fill method running slow

    posted by:Josh

    I ran into an issue today where I was using the SqlDataAdapter.Fill method and it was taking an unusually long time to return back. I ran the query in Management Studio and it was fast, as I expected. After a little googling I ran across this post where it was mentioned to run:

    DBCC DROPCLEANBUFFERS
    DBCC FREEPROCCACHE

    This clears out the memory buffers and procedure cache.

    After doing that my SqlDataAdapter.Fill method ran much faster!

  • 7/29/2009

    ASP.NET submit button double click

    posted by:Josh

    Just wanted to post up a quick page I found when I was looking to prevent double clicking on a submit button.

    http://dotnetchris.wordpress.com/2008/08/07/the-dreaded-aspnet-submit-button-double-click/

    This approach is fairly simple; just use two buttons and update the visibility to achieve the affect.

  • 7/21/2009

    ASP.NET 3.5's ListView Control

    posted by:Josh

    Here's a link to a 4 guys series (much like the famous 18 part series on the DataGrid) that goes over the ListView control. It's new to .net as of 3.5.

    It looks like it has the power of the DataGrid functionality, plus some, with the power to control the rendering like the Repeater (for you table haters).

    I'm just getting ready to use it for the first time so I'm anxious to see how it's going to come out in the end.

  • 6/29/2009

    SQL Stored Procedure for looping through rows

    posted by:Josh

    Here is some code for an sql stored procedure for looping through a result set of rows and then executing some code foreach row.

    ALTER PROCEDURE [dbo].[DeleteMilestone]
    -- Add the parameters for the stored procedure here
    @ApplicationId uniqueidentifier,
    @MilestoneId uniqueidentifier
    AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    DECLARE @rowcount int --Declared to number of records

    DECLARE @ProjectId uniqueidentifier
    DECLARE @TaskId uniqueidentifier
    DECLARE @OrderNum int

    -- get the ProjectId
    SELECT @ProjectId=ProjectId FROM Milestones WHERE ApplicationId=@ApplicationId AND MilestoneId=@MilestoneId

    -- get the number of MilestoneTasks that are open (open Tasks' OrderNum will not be 0)
    SELECT @rowcount=COUNT(TaskId) FROM MilestoneTasks WHERE MilestoneId=@MilestoneId AND OrderNum<>0

    WHILE @rowcount > 0
    BEGIN
    -- select tasks that are still open (open Tasks' OrderNum will not be 0)
    -- selecting the top 1 should give me the highest order milestone task
    SELECT TOP 1 @TaskId=TaskId FROM MilestoneTasks WHERE MilestoneId=@MilestoneId AND OrderNum<>0 ORDER BY OrderNum

    -- select max ordernum <>0 from ProjectTasks
    SELECT @OrderNum=MAX(OrderNum)+1 FROM ProjectTasks WHERE ProjectId=@ProjectId AND OrderNum<>0

    -- update the OrderNum of this Task in ProjectTasks
    UPDATE ProjectTasks SET OrderNum=@OrderNum WHERE ProjectId=@ProjectId AND TaskId=@TaskId

    -- update the OrderNum of this Task to 0 in MilestoneTasks
    UPDATE MilestoneTasks SET OrderNum=0 WHERE MilestoneId=@MilestoneId AND TaskId=@TaskId

    -- update the number of MilestoneTasks that are open (open Tasks' OrderNum will not be 0)
    SELECT @rowcount=COUNT(TaskId) FROM MilestoneTasks WHERE MilestoneId=@MilestoneId AND OrderNum<>0

    END

    DELETE FROM Milestones WHERE ApplicationId=@ApplicationId AND MilestoneId=@MilestoneId

    END
  • 4/30/2009

    Rowset string concatenation

    posted by:Josh

    I was looking for some info on making an concatenated string with SQL and ran across a great resource here: http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx.

    I was able to create a function just like in the article which saved me from have to make unnecessary database calls.

  • 4/13/2009

    Visual Studio 2008: The Project Location is Not Trusted

    posted by:Josh

    I ran into a situation today after formatting my computer where I opened a VS project on a mapped network drive and received the error about the project location not being trusted.

    After lots of researching I found an article that helped me a little bit: check it out here.

    Like I said, it helped me a little bit. I had to go further and experiment with different command line calls because what was in the link above did not work for me. I ended up using two commands before I finally got the warning message to go away. Here are those lines:

    caspol -rg 1.3.1
    caspol -m -ag 1.3 -allcode FullTrust

    The first line removes the policy at 1.3.1. Then I add a new policy in that gives the All Code group full trust. 1.3 is the Internet zone. I tried adding the same thing to the Intranet zone but that did not work for me.

    Hope this helps for anyone else running into this problem.

  • 3/25/2009

    Americans Expect Social Media

    posted by:Mike McTaggart

    Cone, a brand strategy consultancy in Boston, MA, recently released the results of a study on the use of social media. Here are some of the more interesting tidbits:

    • 60% of Americans use social media

    Of those,

    • 93% believe a company should have a presence in social media
    • 85% believe a company should also interact with its consumers via social media
    • 56% feel both a stronger connection with and better served by companies when they can interact in a social media environment

    Also worth noting, men are twice as likely as women to interact frequently (one or more times per week) with companies via social media, and one third of users age 18-34 believe companies should actively market to them via social networks. In fact, the same applies to the wealthiest households (income above $75k/yr).

    So, if you're not already integrating social media into your online marketing strategy, maybe it's time! We've created and managed successful campaigns for clients using social media sites like facebook. Contact us if you'd like to learn more!

  • 3/25/2009

    Website SEO

    posted by:Bryan

    SEO, now there's a magic word used frequently when talking about websites. SEO, search engine optimization, is an ongoing process we at NovelProjects provide to our clients in order to better market their business to the web. The problem with SEO exists where many techniques are speculation and there is not just one way to increase search performance.

    A Firefox add-on called SeoQuake makes this job a little bit easier. It provides statistics from different search engines such as: page rank, internal and external links, and other information pertinent to boosting your website in the search results. Having all this data on-hand and in one location allows us to track different optimizations and their effect on searching.

    One of my favorite features of this plug-in is the "density". This allows us to view the breakdown of how many times a word or phrase is used on a page. Words that are repeated often can be good candidates for targeted ad campaigns. Also we can see when certain words and phrases are not repeated enough, resulting in low keyword density. We can then go in and change the content of a page in order to make the content more relevant by optimizing it for search engines.

    This tool can greatly benefit and improve the amount of time to optimize websites for search engines. It allows us to to spend more time on optimization and less time on monitoring results because it handles the monitoring for us.

  • 3/23/2009

    SQL Server Management Studio and...IE8?

    posted by:Nate

    This definitely ranks high on the the WTF scale. Since Microsoft released IE8, I thought it would be a good idea to install it so I could make sure everything looks alright in it. So, I installed it. Sounds like a simple story.

    But wait, what is this? SQL Server Management Studio has now stopped working. What's the problem? It was very difficult to find out, but it looks like it had something to do with installing IE8. Yeah. Go figure.

    Here's the error I was getting:

    Unable to cast COM object of type 'System.__ComObject' to 
    interface type 'Microsoft.VisualStudio.OLE.Interop.IServiceProvider'.
    This operation failed because the QueryInterface call on the COM
    component for the interface with IID '{6D5140C1-7436-11CE-8034-00AA006009FA}'
    failed due to the following error: No such interface supported
    (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
    (Microsoft.VisualStudio.OLE.Interop)

    ------------------------------
    Program Location:

    at Microsoft.VisualStudio.OLE.Interop.IServiceProvider.QueryService(Guid& guidService, Guid& riid, IntPtr& ppvObject)
    at Microsoft.SqlServer.Management.UI.VSIntegration.ServiceProvider.GetService(Guid guid, Type serviceType)
    at Microsoft.SqlServer.Management.UI.VSIntegration.ServiceProvider.GetService(Type serviceType)
    at Microsoft.SqlServer.Management.UI.VSIntegration.ShellWindowPaneUserControl.GetService(Type svcClass)
    at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.ObjectExplorer.System.IServiceProvider.GetService(Type serviceType)
    at System.ComponentModel.Design.ServiceContainer.GetService(Type serviceType)
    at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.NavigableItem.GetService(Type serviceType)
    at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.NodeContext.GetService(Type serviceType)
    at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.NavigableItemBuilder.BuildDynamicItemWithQuery(IList nodes, INodeInformation source, INavigableItem sourceItem, String urnQuery, Boolean registerBuilder, Boolean registerBuiltItems)
    at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.NavigableItemBuilder.BuildDynamicItem(IList nodes, INodeInformation source, INavigableItem sourceItem, IFilterProvider filter)
    at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.NavigableItemBuilder.Build(INodeInformation source, INavigableItem sourceItem, IFilterProvider filter)
    at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.NavigableItem.GetChildren()
    at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.ExplorerHierarchyNode.BuildChildren()

    That's a whole lot of crap for telling me nothing. Just so it's clear what I'm running, I use Windows Vista 64-bit. This actually makes a difference in the end solution. Anyways, here's the quick and dirty solution. It sounds weird, just try and it see if it works for you.

    • Open a command-prompt (Run as administrator)
    • Navigate to C:\Windows\SysWOW64\
    • Run the following command: regsvr32 actxprxy.dll
    • Restart SQL Management Studio and try again

    I saw other solutions very similar to this, but my guess for why they didn't work is that I was going to the C:\Windows\System32\ folder instead of C:\Windows\SysWOW64\ folder. It makes a difference. If you are on a 32 bit machine, try the other folder and run the same command. Happy hunting. Oh, thanks a lot Microsoft.