Monday, June 30, 2008

DataSet.WriteXml() removes null columns

I have discovered one very annoying feature of the dataset.
When using the WriteXml() method to dump its contents to an XML file it will remove columns it doesn't think you need. I believe it removes all columns where all the values are set to null, however I haven't tested enough to know if it is simply taking a top sampling.

My work around was to check all the values for null and set them to a default value if so. It would be nice if WriteXml() gave us an option to leave the column schema alone. I didn't want the full schema written to the top of the file in this case, so I don't know if that would have made a difference.

Friday, June 20, 2008

Cannot use local variable [variablename] before it is declared

I recently ran into a little issue that I would almost call a bug in Visual Studio 2008.

Technically my code ended up being the issue, however the error VS gave me was very misleading.

I had a method with two input parameters which were used throughout the method.
about 2/3 rd's of the way through I accidentally put this line
obj.var
essentially I referenced an attribute on a custom object without using the value for anything and without ending the line with a semicolon (C#). I received this error and almost every instance of my parameter variables were underlined with it:
"Cannot use local variable [variablename] before it is declared".

My problems with this error were:
1. it is completely false.
2. with every variable highlighted I forgot about my bad line and set about figuring out what the issue could be towards the top of my method to cause such a bad problem.
3. Normally VS will keep missing ; errors constrained to the errant line and the one following it, this time it said there was an error in lines far above where the actual error was.

Tuesday, June 17, 2008

Reporting Services matrix alternating column colors

Since the matrix has dynamic columns the value for its background color has to be calculated rather than simply applied through the tools GUI. I figured it would be simple using RowNumber(Nothing), but I got this error when I tried:

Error 1 ... The BackgroundColor expression for the textbox ... has a scope parameter that is not valid for RunningValue, RowNumber or Previous. The scope parameter must be set to a string constant that is equal to the name of a containing group within the matrix ...

After fighting with it for a bit I searched msn and found this:

[quote]
The RowNumber function can’t be used in the whole matrix. But it can be used in the groups. So please replace the nothing with the name of the rows group. For example: =IIF(RowNumber(“rows_group_name”) Mod 2,"gray","white")
[/quote]

That ended up working great for me, however it appears that if you have a more complicated matrix you might need to take some additional tips from this page:
Green-Bar Matrix

Thursday, June 12, 2008

CSS hack for viewing reporting services in FireFox

**** CSS Fix For FireFox ***

Source Page

Add the following CSS to this file:
C:\Program Files\Microsoft SQL Server\MSSQL.2\Reporting Services\ReportManager\Styles\ReportingServices.css

/* Fix report IFRAME height for Firefox */

.DocMapAndReportFrame
{
min-height: 860px;
min-width: 1024px;
}

Run older extentions on new versions of firefox

[quote url=Here]
The key to the fix is to prevent Firefox from checking its version number before it tries to load extensions. To do this, you will need to set a new preference value. Point your browser at the URL "about:config", then right-click on the preferences list to bring up the contextual menu. You should see an option that says "New." Select that, and choose "Boolean." When it asks you for the preference name, type "extensions.checkCompatibility" (without the quotes). You have to enter the name exactly. For the value, choose "false."
[/quote]

Don't forget to restart the browser after applying the fix.