Thursday, August 07, 2008 #

resharper and auto-property gotcha

Be very careful when allowing Resharper to convert properties to auto-properties.  In some cases it will re-initialize fields that were already initialized earlier on in the constructor.

 

http://www.jetbrains.net/jira/browse/RSRP-75137;jsessionid=D915EE10CA08D52D70BCAD44AE37447B?page=com.atlassian.jira.plugin.system.issuetabpanels:changehistory-tabpanel

posted @ Thursday, August 07, 2008 11:10 AM | Feedback (0)

Wednesday, August 06, 2008 #

generic typing and scope_identity()

I recently ran into an interesting problem.  I had created a data access method that used generic typing to execute a scalar SQL Server stored procedure (below), and in the stored procedure was returning SCOPE_IDENTITY() for an integer identity column.  I was passing in a type of "int" to the method (as <T>) since that's what I was expecting back, but I kept getting back null.  After some frustration and bewilderment I discovered that SCOPE_IDENTITY() always returns a decimal, and C# doesn't want to convert the decimal to an integer automatically.  I worked around it by using CAST in the stored procedure so that I didn't have to modify the method.

 

        private static T? ExecuteScalarStoredProcedure  (string sprocName, SqlParameter[] parameters) where T : struct {

            SqlConnection conn = new SqlConnection(GetConnectionString());

            conn.Open();
            object retValue;
            try {
                SqlCommand command = new SqlCommand(sprocName, conn);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddRange(parameters);

                retValue = command.ExecuteScalar();
            }
            finally {

                try {

                    conn.Close();

                }
                catch (Exception) {
                    //Ignore close exception
                }
            }
            return retValue as T?;
        }

posted @ Wednesday, August 06, 2008 5:38 AM | Feedback (0)

Friday, June 27, 2008 #

best quote ever

"So they told me that using the download page to download something was not something they anticipated."

--Bill Gates 

posted @ Friday, June 27, 2008 11:07 AM | Feedback (0)

Wednesday, May 28, 2008 #

activerecord and executereader exceptions

About once a day I was getting the following error from an ASP.Net web page that uses ActiveRecord:

Exception Details: System.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)

I would subsequently get this error upon refreshing the page:

Exception Details: System.InvalidOperationException: ExecuteReader requires an open and available Connection. The connection's current state is closed.

I finally figured out that the problem occurs when the database is restored.  The connections in the IIS application pool do not get destroyed when the database is restored, so when ActiveRecord (nHibernate) tries to reuse the connections it fails.  This doesn't happen to me when I'm not using ActiveRecord, so I'm not sure if this is a bug with ActiveRecord or a problem with the way I've set up the data access layer.

posted @ Wednesday, May 28, 2008 8:46 AM | Feedback (0)

Friday, April 25, 2008 #

band names for programmer geeks

Band names for programmer geeks (feel free to use these, unless they already exist and are copyrighted):

  • Asskey
  • The Lazy Loaders
  • CMYK (more for graphic artists, I know)
  • nRock
  • BSODeathmetal
  • Unicoder Manifesto
  • Fist to Five
  • Gates of Hell (that one's for Microsoft programmers specifically)

posted @ Friday, April 25, 2008 12:45 PM | Feedback (10)

Thursday, April 17, 2008 #

if geeks ruled the world

If geeks ruled the world:

  1. Professional sports teams, if they existed, would have mascots like the Orcs, the Elves, and the Supernovae. The Giants and the Pirates could keep their names, and possibly the Blue Devils (though due to statistical improbability, Duke would not be allowed to be in the Sweet 16 so often).
  2. All surnames would have to be pronounced as they are in their country of origin (e.g. Favre would be Fov-ruh and Mao Tse-Tung would be unpronounceable).
  3. Wars would occur between the cybergeeks and the envirogeeks. The weapons would consist of twenty-sided dice and solar-powered Laser Tag guns.
  4. There would be KSL programs (Klingon as a Second Language).
  5. I would be a very high-ranking officer!

posted @ Thursday, April 17, 2008 4:15 AM | Feedback (1)

Thursday, April 10, 2008 #

ssas: define reference and materialize

Apparently you have to watch out when you select Materialize in a referenced dimension in SSAS 2005.  I just ran into a situation where data was getting duplicated for no good reason, and unchecking Materialize fixed it.

http://www.biblogs.com/2006/12/23/materialize-option-in-a-reference-dimension/

posted @ Thursday, April 10, 2008 10:25 AM | Feedback (6)

Wednesday, April 09, 2008 #

granularity error in SSAS MDX drillthrough query

I was trying to create an MDX drillthrough this morning in my SSAS 2005 cube, and I got this error:

Errors from the SQL query module: The attribute 'Applicant Name' in the dimension 'Dim Candidate' is outside the granularity of the measure group 'Fact Requisitions' and cannot be returned as a column.

I only got one result from Google for that error message and it wasn't helpful at all.  After trying a million different things with partitions and actions and whatnot, I finally figured out the problem:  I was trying to return drillthrough data from a fact table other than the one containing the default measure.  Once I threw in a measure (in the SELECT part of the query, not the RETURN) from the non-default fact table, everything worked great!

posted @ Wednesday, April 09, 2008 10:44 AM | Feedback (0)

Monday, February 11, 2008 #

adding a fact table to a SSAS 2005 cube

So you're trying to add a fact table to a cube that you've already created, but you can't figure out how to do so without recreating the cube from scratch?  Here's what you do:  In the Measures pane in the Cube Structure tab, right-click and select New Measure Group.  Then select the fact table, and voila!  (This is assuming you've already put the fact table in the data source view.)

addendum:  Looks like the standard way to add a dimension to the cube is to right-click on the cube name in the Dimensions window in the Cube Structure tab and select Add Cube Dimension.

 

posted @ Monday, February 11, 2008 9:28 AM | Feedback (1)

Wednesday, February 06, 2008 #

SSAS cube: "attribute key not found" error

I just spent over an hour trying to figure out why my data tables were correct but I was getting an error about an attribute key not being found (i.e. an unlinkable foreign key).   I finally figured out that processing one dimension at a time before processing the cube can get fix whatever is out of sync.  [Right-click on the dimension in Solution Explorer to process it separately.]

posted @ Wednesday, February 06, 2008 11:05 AM | Feedback (2)

Friday, February 01, 2008 #

CPU percent limit in .Net

Why doesn't the .Net framework have anything that lets you set a maximum CPU usage for an application?  Is it something Windows can't handle?  I'd really like to be able to say, "I don't care if this app gets stuck in a loop or whatever, it will never get above 25% CPU."

posted @ Friday, February 01, 2008 11:29 AM | Feedback (1)

Friday, January 25, 2008 #

SQL Server 2005 splash screen

Is the SQL Server 2005 splash screen supposed to look like Arkanoid or like Tetris?

posted @ Friday, January 25, 2008 12:38 PM | Feedback (0)

Wednesday, December 26, 2007 #

RadGrid and grouping message

If you're using telerik's RadGrid and you're seeing a message in the UI that says "Drag a column header and drop it here to group by that column" and you want to hide that message, here's what you do:

myRadGrid.GroupPanel.Text = "";

This page just confused me rather than helping me:

http://www.telerik.com/community/forums/thread/b311D-mdedg.aspx

posted @ Wednesday, December 26, 2007 12:06 PM | Feedback (0)

Wednesday, November 21, 2007 #

fastest way to show SQL data in a web page

I'm curious what people think is that fastest way to show SQL Server data in a web page.  Assuming you create the virtual web in IIS yourself, I'm hoping somebody knows of something that lets you create an xml file with connection settings and a query file, then the product automagically puts the data in a grid on the web page.  Granted once you're used to Visual Studio it doesn't take terribly long to do such a thing, but I'd still like something faster, maybe something that can automagically create graphs too.

posted @ Wednesday, November 21, 2007 11:45 AM | Feedback (1)

Tuesday, October 30, 2007 #

come on people

I've said it before and I'll say it again: setup and login are not verbs!  If you want to use them as verbs you must split them into set up and log in.  It really fascinates me how often I see these terms used incorrectly, though if English is not your first language that's a pretty good excuse.  Oh, and the same goes for backup and back up.

posted @ Tuesday, October 30, 2007 5:54 AM | Feedback (5)