Wednesday, October 7, 2015

Using Web Essentials 2015 Color Palette

One of the most popular Visual Studio extensions is Web Essentials. One of my favorite features is the extra stylesheet support WE gives Visual Studio. Making sure that the numbers of colors in a web site doesn't get out of control can be a big deal. Having a consistent color palette makes a real difference in the overall feel of a web application.

After you install the extension you should see a new menu in the toolbar called Web Essentials. It will look like this.

If you click "Create color palette" you'll add a css file to the Solution Items. This file is named specifically "WE-Palette.css". Do not rename it or move it. If you happen to remove it, but do not delete it then you'll be stuck. The file might still be in the solution folder but hidden from the project. You will have to delete it or Visual Studio won't be able to create it. You'll be stuck in a state of color palette limbo.

In this example I created a solution settings file and a color palette already. The extension sees the existing files and does not let you write over them.

So what does a color palette file look like?

It's nothing to complicated. It's just a list of colors. The trick is that the order matters. When you now type "#" in a CSS or LESS file, Visual Studio's IntelliSense feature gives you a wonderful picker that shows your color palette.

Hit #

It is that easy. It's also easy to extend. So lets add an orange color to the WE-Palette.css file and save the file.

It kind of fits our color scheme. I like it. Let's go add it in our style.css file by hitting #.

Yep. This Web Essentials (WE) Visual Studio extension is pretty darn cool. More stylesheet features can be found at:

Thursday, October 1, 2015

SQL Code Guard Review

Pro Tip: Don't Trust Yourself

I had not used this product for a while but recently installed it again.  When I'm focused on frontend work and other developers are handling the backend, I don't write any SQL.  It's nice to work on teams that have brilliant database developers that you can count on to use best practices.
I'm currently back to being a full stack developer on a project and the database is not my own.  I don't want to make mistakes that might slow up the team.  So I need all the help I can get.  I'm not saying that I'm a bad developer.  In fact, I get a lot of props from other developers on my SQL skills.  But I'm not perfect.
SQL Code Guard is a free add-in for SQL Server Management Studio and Visual Studio.  Sorry, there isn't a VS 2015 build yet that I can find.  That could change by the time you read this.  I use it with SSMS the most. ( You should also install Red Gates SQL Search.  I like it also. )


What does SQL Code Guard do?

The add-in does four different things:
  • Code issues  - my favorite feature
  • Object dependencies - helps solve that oops when Visual Studio missed it
  • Code complexity - Bad SQL is not job security.  It's what should get you fired.
  • Code outline - great for understanding complex stored procedures 


"I have Visual Studio, I don't need anything more."

Visual Studio database projects use msbuild when you build them.  Building your database, parsing it and making sure certain dependencies are checked, is wonderful.  It's probably not enough.  Just take one of your databases that builds fine in VS and use the Code Issues tool in SQL Code Guard once.  I bet it will find something you forgot.  Maybe there is a SELECT *, or a missing ELSE?
You can also add SQL Code Guard to your build.  It even has a Check-in Policy so databases don't get into Team Foundation Server without at least a minimum standard to quality.

My Humble Opinion

The tool is free and is light weight.  I don't see any reason why you shouldn't try it out or give it to other developers.  You might be good enough that the supported issues are just second nature, but maybe a free tool could help.  If it does, then the developers like me who have to work in your database later will thank you for using something.
Whatever you do, please don't leave BP017 out there in your databases.  It's a killer.  See what I did there?  I just dropped a teaser.  Now you have to go and find out what BP017 is. :-)

Wednesday, September 16, 2015

Resolve associated work items on check in.. Finally!

In Visual Studio 2015, Microsoft has fixed that default setting everyone hates.  Well, I bet the majority of developers hate it.  No? Just keep reading anyway.

By default, when you relate a work item to a check in, if the work item is not resolved or closed, it tries to resolve the work item for you.  Why?  I don't know. It's always been that way.

This, for me, is a real pain.  I don't, by default, want to do that.  I (usually) want to associate the work item.  So how do I change the default?  Prior to VS 2015 you had to edit your registry and restart Visual Studio.  Doesn't that sound like a great user experience?

Here is how to do that if you have not upgraded or need to use another version other than 2015:  I think it still works.  I only have Visual Studio 2015 now so I don't care.

Thanks to user input the team at Microsoft has created a new setting. It only received 845 votes.  It should have received a lot more.

The setting is under Tools > Options > Source Control > Visual Studio Team Foundation Server.

This isn't worded the best but that is the setting we have been asking for.  If you un-check the box, from then on the default will be associate for open work items.  You don't have to restart or anything but you will need to re-add your work item to see the affect.

Happy programming!

Tuesday, August 18, 2015

Data-driven subscriptions cannot be created

So you get this wonderful error from SQL Server Reporting Services when you try to add a data driven subscription to your report:

Data-driven subscriptions cannot be created because the credentials used to run the report are not stored, the report is using user-defined parameter values, or if a linked report, the link is no longer valid.
You look and you are using a shared data source that has saved credentials.  So that's not it.

You check and the report is not linked to any other report.  So that's not it.

You go ahead and remove all the parameters and publish.  So that's not it.

Is SSRS a liar?  Dumb Microsoft goofed again right.  Not so fast.  This is still something you can fix.  I came across something that could help.  Check on the Variables section.

In the rdl file's xml there is a <Variables></Variables> section.  Remove it and publish.  The error will go away.  You can also see it in the Report Properties.

You'll see a variable there that needs to be deleted, if this solution is a solution to your problem.

Good luck and I hope this helped.

Thursday, July 9, 2015


This one is new for me. It might be something you have to consider all the time. I do not.

Stored procedures in SQL may have defaults for certain options set only at creation. So you can't override them or even alter them. You have to drop and recreate them if those options have an affect on your query.

This probably doesn't affect 99% of your queries. It doesn't affect mine too much. Today I had to so a bit of XML in my stored procedure though. It worked in dev fine because of course my options are set differently than in another server. When I gave the script to someone else to try... whammo!
SELECT failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'

What the hell does that mean? Is this Office Space? PC LOAD LETTER!

No it's not a movie. This is real life and SQL has this cool table called sys.sql_modules. It can store options that you have set when you created that bloody stored procedure that isn't working now.

SELECT name = OBJECT_NAME([object_id]), uses_quoted_identifier
FROM sys.sql_modules
WHERE OBJECT_NAME([object_id]) IN (N'sproc1', N'spoc2');

In this example our stored procedure is called sproc1. The columns we can look for are:
  • object_id
  • definition
  • uses_ansi_nulls
  • uses_quoted_identifier
  • is_schema_bound
  • uses_database_collation
  • is_recompiled
  • null_on_null_input
  • execute_as_principal_id

For this example our results prove that we do have a problem.

name uses_quoted_identifier
---- ---------------
sproc1 0
sproc2 1

So how do we fix this. We can't do an alter. We have to recreate the stored procedure. Yep, what a pain in the butt.  It's because of the darn XML and STUFF() that we are doing to put some rows all together into a delimited string.  Please don't focus on that.. it's the QUOTED_IDENTIFIER ON that is the bug.

--drop the sp and recreate with the correct set options.

IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[
sproc1]') AND type in (N'P', N'PC'))



-- important


-- important for xml queries



-- important for mapping in Entity Framework

-- SELECT an existing row from the table.

[Id] INT,
[Description] VARCHAR (200),

Things(Id, Description, Date)
SELECT ID, Description, Date
TableB ON TableB.ID = TableA.ID

SELECT ', ' + b.Description
TableA b
WHERE (b.Id = a.Id)
FOR XML PATH(''),TYPE).value('(./text())[1]','VARCHAR(MAX)')
,1,2,'') AS
Things a




Wednesday, February 25, 2015

Recruiters should not call or email me.

I have changed positions over the years. It does happen. I do answer my phone and read my email. I like talking to other developers and entrepreneurs about technology. Sometimes that might involve me coding for them or with them.

I don't like it when a recruiter calls me up looking to place someone they know or wanting to fill a role they have. Please don't bother me. I won't be nice to you when you call and I'll block your email.

You can contact me on LinkedIn if you want. That is what LinkedIn is for. Calling me up at all hours of the day and night isn't going to help you, at all.

Saturday, February 7, 2015

Agile Database Development

SQL Saturday Cleveland - Feb  7, 2015

In this talk Aaron will introduce users to some techniques and tools for developing and maintaining SQL code inside an Agile SDLC. Aaron will use test driven development techniques and commit his code changes to Team Foundation Services and schedule a build. He'll also demonstrate some custom solutions and go over all of the different databases that a DBA might support in an on-premise TFS install.