Parameterised SQL Reports in SharePoint

So, I’ve developed a parameterised report and surfaced it inside a SharePoint site using the Report Viewer Web Part.

Now the user has this ‘nice’ pane on the side of the report to supply the parameter value….

report_viewer_parameter_pane

How do I provide parameter values without requiring user intervention? Just follow these easy steps.

Put the page hosting my web part into edit mode:

edit_page

Next click on the edit button for the Report Viewer Web Part, we see the connect to option, but it’s disabled. :o(

edit_menu_no_connection

A connectable web part to provide the parameter(s) is needed…

Click on one of the Add a Web Part headers.

add_a_web_part

Luckily OOTB there are a bunch of Filter Web Parts which we can use for just this purpose! I chose to use the Query String (URL) Filter. 

add_web_parts_screen

Now open the tool pane.

query_string_filter_unconfigured

Configure the filter web part.

query_string_filter_configuration

The web part is now configured but not connected.

query_string_filter_configured

Now you need to connect the web parts, note that you can choose to connect the web parts from either end.

query_string_filter_connect

OR

edit_menu_with_connection

The connection between the web parts needs to be configured.

connection_configuration

Now the screen looks like this:

parameters_required

Once the courseCode query string parameter is supplied the report will be generated using that parameter value.

parameters_supplied

I hope this helps some one else out there.

Posted in Deployment, Reporting Services, SharePoint | Leave a comment

Developing SQL Reports: Useful Resources

OK, so I promised more on the reporting services front. This post is just a quick follow up on that with a few resources, a.k.a blog posts from smart cookies, that I found VERY useful.

A great 3 part intro on how to build your reports using the Report Designer in Visual Studio: http://www.simple-talk.com/sql/learn-sql-server/beginning-sql-server-2005-reporting-services-part-1/

Tips on formatting from fellow Intergenite, Jo: http://notethat.blogspot.com/2007/10/reporting-services-tips-tricks-and.html.

Sahil Malik’s intro to SSRS and SharePoint: http://blah.winsmarts.com/2007-12-SharePoint_and_SQL_Server_Reporting_Services.aspx

Posted in Development, Intergen, Reporting Services, SharePoint | Leave a comment

Installing SSRS in SharePoint Integrated Mode

Oops, nearly two weeks since a post! That’s a bit of an indicator of how busy I’ve been of late…

Anyway, I had to set up up SQL Server Reporting Services in SharePoint Integrated mode.

Not too difficult on the whole, I’d done it before and found it pretty painless. Just follow the “Configuring Reporting Services for SharePoint 3.0 Integration” article on MSDN and it all just works… last time….

This time I found a few issues, firstly I couldn’t actually access the report server virtual directory by browsing to the url I’d set up for my reporting site using IWA. I was getting a “HTTP Error 401.1 – Unauthorized: Access is denied due to invalid credentials” message 😐 Luckily I found a great KB article that gave me a workaround.

So next it was on to installing the SharePoint addin and configuring it, no troubles, until I was up to the last step of configuring Reporting Services inside SharePoint where upon I received the An unexpected error occurred while connecting to the report server. Verify that the report server is available and configured for SharePoint integrated mode. –> The request failed with HTTP status 502: Proxy Error ( Internet Control Message Protocol (ICMP) network is unreachable. For more information about this event, see ISA Server Help. ).” error message 😦

WTF?? I’m working in a VM environment where ISA is not present, checking my “Internet Options” shows that I’m just using the LAN connection, not using a proxy server and not auto-detecting. Where on earth is this proxy error and mention of ISA coming from?

After some log trawling and interpreting it turns out that SharePoint has a config setting that allows it to auto-detect any proxy-servers…

<system.net>
    <defaultProxy>
        <proxy autoDetect="true" />
    </defaultProxy>
</system.net>

So what was happening was my VM hosted SharePoint instance was detecting our corporate proxy server then trying to route requests for the reporting server through said proxy server which had no idea where my reporting site URL was supposed resolve to.

Toggling the autoDetect element to false solved my issues. I had to repeat this step for the site that was being used surface the reports via the Report Viewer web part.

-Gavin

p.s more posts on the reporting services front to follow 😉

Posted in Deployment, Reporting Services, SharePoint | Leave a comment

Need to resize a VHD?

I do most of my development using virtual machines now and according to all the information that I’ve seen fixed sized disks perform better, this great until like me you start to run out of space on the VM you’re using….

So in my hunt to find a good utility to re-size my vhd I stumbled across a tool called VHD Resizer. It’s very easy to use and creates a copy of your original VHD in a new VHD file of a size that you choose 🙂

Download the tool here, download requires registration.

Edit: Oh yeah, you’ll need to use a tool like Partition Manager to allocate that space into your VHD afterwards.

Posted in General, Tools | Leave a comment

VSeWSS 1.0 and solution.xml

So, I have a project that I’m still working on that is using VSeWSS 1.0 project templates.

I just got bitten by an issue I knew about from prior experience 😐

With this version VSeWSS creates a file called solution.xml in the root project folder, this appears to be used as offline storage for the settings for the Visual Studio Project that are edited through the SharePoint Solution tab in the Project Properties page i.e. it’s written to when you close the Visual Studio Solution. Cool, that seems to be a reasonable and valid approach.

The problem arrises when you put it under source control….. Now the file on disk is marked as read only. Now when you’re closing the Visual Studio Solution the file that Visual Studio is trying to write to a read only file and can’t, so the settings changes that you made are lost 😦

The work around? Simple, include the solution.xml file in the Visual Studio Project, check it out before you close the Visual Studio Solution using File > Close Solution, then check in the solution.xml file to share your changes with the rest of the team and you’re golden! 🙂

Posted in Development, Visual Studio, VSeWSS | Leave a comment

VSeWSS Deployment Issue

Ok, here at Intergen we are working on the VSeWSS 1.1 User Guide. As part of this we have to create code samples in both C# and VB.NET for all the code that we produce. No big deal really.

Except that when you attempt to deploy the second version of the code you get the message:

“This solution contains two assemblies with the same name, or the SharePoint server already has an assembly with the specified name.”

Huh? What’s going on here was my first reaction. After applying a little thought to it I realised that there was a solution package added and deployed to the SharePoint server that had same name as the one I was attempting to deploy. This solution package also contained assemblies of the exact same names as those that I was trying to deploy this time, in my case the C# version had been done first.

So knowing a little of what happens at packing and deployment time I opened up a file browser and looked in the bin\debug folder of the current project. Had the packaging worked I would have found a .wsp file and a setup.bat file, neither of these was present so the check that throws up this message must be run prior to packaging the .wsp file for our VB.NET version.

Luckily I had the setup.bat file from the C# version! So I just ran setup.bat /uninstall which will remove the solution package for which it was generated.

However, should you not have that file, it’s still pretty easy to get around this problem, it just requires a little stsadm fu!

Open up cmd and run these commands:

C:

cd "\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN"

stsadm -o enumsolutions

Now examine the XML output to see if you have a .wsp in that list that matches the name of the .wsp that will be created and deployed by VSeWSS for the project that you’re working on. If you do you’re in business!

stsadm -o retractsolution -name <Solution name> -url <virtual server url> -local

stsadm -o deletesolution -name <Solution name>

Note: do this with care! If the solution you remove is not on that you’ve developed then you might break other features in your SharePoint instance.

Posted in Deployment, Development, SharePoint, VSeWSS | Leave a comment

SPQuery is not reusable.

So I’m writing some code to assemble some information about items in a list.

My original approach was this:

SPQuery query = new SPQuery();
query.Query = GenerateLodgedSubmissionsQuery(studentId, activityId);
SPListItemCollection submittedItems = submissionsList.GetItems(query);
response.SubmittedFiles = CreateFileDetailsList(submittedItems, false);
if (0 < submittedItems.Count)
{
	response.ActivityName = submittedItems[0]["ActivityName"].ToString();
	response.ActivityId = submittedItems[0]["ActivityId"].ToString();
}
query.Query = GenerateReturnedSubmissionsQuery(studentId, activityId);
SPListItemCollection returnedItems = submissionsList.GetItems(query);

The problem here was that the second call to GetListItems was returning the exact same results as the first call, despite having changed the Query property of the SPQuery object.

After much second guessing of my CAML query generation code and ensuring that the SPQuery.Query had infact changed I tried making the second GetListItems call with a new SPQuery object:

SPQuery query = new SPQuery();
query.Query = GenerateLodgedSubmissionsQuery(studentId, activityId);
SPListItemCollection submittedItems = submissionsList.GetItems(query);
response.SubmittedFiles = CreateFileDetailsList(submittedItems, false);
if (0 < submittedItems.Count)
{
	response.ActivityName = submittedItems[0]["ActivityName"].ToString();
	response.ActivityId = submittedItems[0]["ActivityId"].ToString();
}
SPQuery returnedItemsQuery = new SPQuery();
returnedItemsQuery.Query = GenerateReturnedSubmissionsQuery(studentId, activityId);
SPListItemCollection returnedItems = submissionsList.GetItems(returnedItemsQuery);

Now I finally saw the results that I was looking for.

Posted in Development, SharePoint | Leave a comment

Intergenite delivers in browser viewer for docx

Here at Intergen I have the good fortune of working with lots of very tallented people. 

One of them, James Newton-King, has developed a means of viewing Microsoft Word 2007 documents in a web browser, on any platform!

His solution, called TextGlow capitalises on the OOXML format used for docx files and is built using Silverlight 2.0. For more info read James’ post: http://james.newtonking.com/archive/2008/03/06/silverlight-2-0-ooxml-textglow.aspx

Posted in General, Intergen, OpenXML | Leave a comment

Deploying Timer Jobs

So I’m working on a Timer Job for SharePoint at the moment, I found that the post that Andrew Connell has made describing the development process is very good, read it here: http://www.andrewconnell.com/blog/articles/CreatingCustomSharePointTimerJobs.aspx

Anyway I was trying to debug my job by attaching to the OWSTIMER process and it appeared that the process was running an old version of my code. 😐 It appears that to ensure that the newly deployed version of the DLL that you have deployed to the GAC you need to restart the OWSTIMER process.

So  I’ve included that into my script to deploy and everything is happy again. Below is a sample deployment script for your reference.

net stop sptimerv3
rd /s /q "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\MyTimerJob"
mkdir "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\MyTimerJob"
copy /Y feature.xml "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\MyTimerJob\"
gacutil /u MyTimerJob
gacutil /i bin\debug\MyTimerJob.dll
pushd %programfiles%\common files\microsoft shared\web server extensions\12\bin
stsadm -o deactivatefeature -filename MyTimerJob\feature.xml -url http://col/ -force
stsadm -o uninstallfeature -filename MyTimerJob\feature.xml -force
stsadm -o installfeature -filename MyTimerJob\feature.xml -force
stsadm -o activatefeature -filename MyTimerJob\feature.xml -url http://col/ -force
popd
net start sptimerv3

Posted in Deployment, SharePoint | Leave a comment

Version Control is NOT Source Control!

Warning: Rant ahead!

So a question popped up on the MSDN SharePoint developers forum about how to use integrate WSS and Visual Studio in order to save files edited in Visual Studio direct into WSS including using Check In/ Check Out.

After myself and one other suggested using real Source Control tools the OP rejected our advice rejecting TFS as too complex and that SharePoint provided all that they needed being:

“a team of 3 database developers taking care of our SQL databases. Working results mostly are .txt files to control the sql jobs and interfaces”

Below follows my reaction:

<rant>

Version Control is not Source Control.
Version control tracks the changes against a single file.
Source control allows track changesets, ie Dev A checked in these n files at y time, they edited these lines.
I suppose you could publish a list as a published link and use that as a network storage location to save to. I strongly recommend using a real source control system over SharePoint version control. Even for ‘just database scripts’….
Say you have a need to set up a mirror of the current configuration (ignore data) that you have from a point in time a month ago for some reason (this DOES happen), now your DBA have changed many files in the mean time. How do you get the scripts to set that up easily? Using WSS and Version Control it’s going to be hard. Using a Source Control product (even VSS) is better as you can pull the state of the source database at a given point in time.
Version Control doesn’t handle forks or merges.
To use WSS as a source code repository is wrong.
Can you do it? Yes.
Should you? I strongly say NO!
By all means use WSS for collaboration and communication, just for the love of all that is good and right don’t use if for Source Control.
Use VSS, use SubVersion, use CVS, use TFS, hell even use RCS!

Sure TFS might be overkill in this situation, but I’d suggest that using WSS as Source Control is something of an anti-pattern.

<rant />

Posted in Best Practice, SharePoint | Leave a comment