Just for Fun

2010 March 8
by r.claypool

My name:

robert-claypool-barcode

Create your bar code at http://www.barcoding.com/upc/

T-SQL: Cannot drop the index because it does not exist or you do not have permission.

2010 February 1
by r.claypool

database

Quick tip:   The table name and index name are required to drop an index, otherwise SQL Server will return an error.

e.g.

DROP INDEX [dbo].[IX_MyIndex]

fails with …

Msg 3701, Level 11, State 6, Line XX
Cannot drop the index 'dbo.IX_MyIndex', 
because it does not exist or you do not have permission.

However,

DROP INDEX [dbo].[MyTable].[IX_MyIndex]

will work fine if it exists and you have sufficient permissions. (Use Select user_name() to determine your user context, which will help to verify the permissions being used.)

Intellisense for NAnt Build Files (VS 2005 and 2008)

2010 January 17
by r.claypool

nant

Step 1. Make VS recognize a .build file as an XML file.

  1. Right-click a .build file in the “Solution Explorer” and select “Open With …”
  2. In the “Open With” dialog, select “XML Editor” and “Set as Default”

vs-2005-2008-open-with-dialog

Step 2: Enable intellisense for .build files.

Get the schema file for NAnt:

Copy it to the “xml\Schemas” subdirectory of your VS installation:

  • Note that you can check this path via Tools > Options > Text Editor > XML > Miscellaneous

schema-location-option

Specify the schema to use within Visual Studio:
  • Open the file so that it appears in a Visual Studio editor window.
  • Click the file’s editor window (to activate it) and specify the schema to use (within the “Properties” window).
    change-schema-properties
  • Note that this dialog has changed from VS 2005 to 2008:

Visual Studio 2005
(VS 2005)

Visual Studio 2008
(VS 2008)

If all of that is not enough,  make sure to enter an xmlns and make sure it is equal to the xmlns specified in the XSD schema

!!!!! Even though the schema is available at http://nant.sf.net/release/0.86-beta1/nant.xsd and http://nant.sourceforge.net/release/0.86-beta1/nant.xsd, you must reference the former url in your build file because it is the one referenced in nant.xsd. !!!!!

Here is an example of what I mean:

<?xml version="1.0" ?>
<project xmlns="http://nant.sf.net/release/0.86-beta1/nant.xsd" name="MyProject">
  <!-- stuff here -->
</project>

Hope that helps someone.  Happy Programming!


Attribution: The ant photo in this post is used with permission (CC BY-SA 2.0) by Jeff Kubina

Getting DataTables to work with ASP.Net MVC

2009 December 3
by r.claypool

Want to get jQuery DataTables to work in an ASP.Net MVC project ???

Here is a demo project in C# that should get you started.  If I find the time, I’ll post details on how this was put together (but I think most developers will benefit more from running and stepping through the source code anyway).

Hope this helps someone.  Happy Programming!

Viewing the Activity Log for VS 2010

2009 November 1
tags:
by r.claypool

Are you repeatedly getting a less than helpful error dialog in Visual Studio 2010?

Go to the command line and run devenv.exe with logging, reproduce the error in the IDE and then open ActivityLog.xml:

devenv

C:\>cd "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE"
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE>devenv /Log
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE>cd %APPDATA%
C:\Documents and Settings\username\Application Data>cd "Microsoft\VisualStudio\10.0"
C:\Documents and Settings\username\Application Data\Microsoft\VisualStudio\10.0>dir ActivityLog.xml /B ActivityLog.xml
C:\Documents and Settings\username\Application Data\Microsoft\VisualStudio\10.0>notepad ActivityLog.xml

Look for entries with type=Error, e.g.

<entry>
<record>263</record>
<time>2009/10/24 22:50:09.218</time>
<type>Error</type>
<source>Editor or Editor Extension</source>
<description>System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.VisualStudio.Editor.Implementation.VsFontsAndColorsInformation.GetEditorFontForItem(IVsColorTable colorTable, Int32 itemIndex, FONTCOLORPREFERENCES2 fontColorPreferences)
at Microsoft.VisualStudio.Editor.Implementation.VsFontsAndColorsInformation.TryGetItemValue(String itemKey, ResourceDictionary& itemValue)
at Microsoft.VisualStudio.Text.Classification.Implementation.EditorFormatMap.CreateResourceDictionaryFromProvision(String key)
at Microsoft.VisualStudio.Text.Classification.Implementation.EditorFormatMap.GetProperties(String key)
at Microsoft.VisualStudio.Text.Classification.Implementation.ClassificationFormatMap.GetDefaultProperties()
at Microsoft.VisualStudio.Text.Classification.Implementation.ClassificationFormatMap..ctor(ICollection`1 formats, IClassificationTypeRegistryService classificationTypeRegistry, IEditorFormatMap formatMap)
at Microsoft.VisualStudio.Text.Classification.Implementation.ClassificationFormatMapService.GetClassificationFormatMap(String category)
at Microsoft.VisualStudio.Text.Classification.Implementation.ViewSpecificFormatMap.AttachToFormatMaps()
at Microsoft.VisualStudio.Text.Classification.Implementation.ViewSpecificFormatMap..ctor(IClassificationFormatMapService classificationFormatMapService, IEditorFormatMapService editorFormatMapService, ITextView textView)
at Microsoft.VisualStudio.Text.Classification.Implementation.EditorFormatMapService.<>c__DisplayClass1.<GetEditorFormatMap>b__0()
at Microsoft.VisualStudio.Utilities.PropertyCollection.GetOrCreateSingletonProperty[T](Object key, Func`1 creator)
at Microsoft.VisualStudio.Text.Classification.Implementation.EditorFormatMapService.GetEditorFormatMap(ITextView textView)
at Microsoft.VisualStudio.Text.Editor.Implementation.OutliningAdornmentManagerFactory.CreateTagger[T](ITextView textView, ITextBuffer buffer)
at Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator`1.GatherTaggers(ITextBuffer textBuffer)</description>
</entry>
Creative Commons Attribution 3.0 United States
Creative Commons Attribution 3.0 United States